MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

Music Player - PowerBuilder

Published on 08 September 16
0
1
// We can play sound using Windows Media Player - OLE Object in PowerBuilder
1/ Open a window, click on Create Ole Control
2/ Under Create new tab , select windows media player
3/ In the below image the block color box is the one ole object and name it as ole_mp and disable visible property( we are not showing the object at run time)
4/ Create a list box and name it llb_1
5/ as shown in the below image create buttons for Previous song, play,pause/play,next song, exit
6/ In this example I am just iterating to a fixed folder say C:\users\desktop\songs
in this folder I am going to keep all the files,
7/ This application will list the .mp3 files only, if you want you can do the modifications as per your wish.

Music Player - PowerBuilder - Image 1
// In the window open event
// Object :: w_music_player
// event :: Open
// We are adding the .mp3 files list to the listbox control

uint li_filetype
string ls_file_pattern,ls_filepath

li_filetype=39
ls_filepath="C:\Users\desktop\songs\"
ls_file_pattern = "*.mp3" // Should not have any spaces before *
ls_file_pattern=ls_filepath+ls_file_pattern
llb_1.Reset ()
if llb_1.DirList ( ls_file_pattern, 0 ) then
llb_1.SelectItem (1)
else
Messagebox ("Not able to read the files : ", ls_file_pattern)
end if
// Object : Previous song button
// Event :: Clicked

String ls_song_name
integer li_1,li_2

li_1=llb_1.selectedindex( )

if li_1>1 then
li_2=integer(li_1)-1
llb_1.selectitem(li_2)
ls_song_name=llb_1.selecteditem( )
else
llb_1.selectitem( li_1)
ls_song_name=llb_1.selecteditem( )
end if

ole_mp.object.URL='C:\Users\desktop\songs\'+ls_song_name

ole_mp.Object.Controls.Play( )

// Object :: Play Buttion
// event :: clicked event

ole_mp.Object.Settings.AutoStart = FALSE

String ls_song_name
int i

i=llb_1.selectedindex( )
if i>0 then
ls_song_name=llb_1.selecteditem( )
end if

ole_mp.object.URL='C:\Users\desktop\songs\'+ls_song_name

ole_mp.Object.Controls.Play( )
cb_2.text="||"

// Object :: Pause Button
//Event :: Clicked event

Long ll_state
ll_state = ole_mp.Object.PlayState

CHOOSE CASE ll_state
CASE 2
//ole_mp is paused
ole_mp.Object.Controls.Play( )
cb_2.text="||"
CASE 3
//ole_mp is playing
ole_mp.Object.Controls.Pause( )
cb_2.text="->"
CASE ELSE
//no action needed... The ELSE statement itself isn't needed

END CHOOSE

// Object :: Next Song Button
//Event :: Clicked

String ls_song_name
integer li_1,li_2


li_1=llb_1.selectedindex( )

if li_1>=1 then
li_2=integer(li_1)+1
llb_1.selectitem(li_2)
ls_song_name=llb_1.selecteditem( )
else
llb_1.selectitem( li_1)
ls_song_name=llb_1.selecteditem( )
end if

ole_mp.object.URL='C:\Users\Desktop\songs\'+ls_song_name

ole_mp.Object.Controls.Play( )

// Object :: Exit Button
// Event :: Clicked

destroy ole_mp;
Halt close

/* End of the Coding Part */
/* Find the output window in the below image */
/* It did worked for me . Hope it will work for you :) */
Music Player - PowerBuilder - Image 2
This blog is listed under Development & Implementations Community

Post a Comment

Please notify me the replies via email.

Important:
  • We hope the conversations that take place on MyTechLogy.com will be constructive and thought-provoking.
  • To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
  • Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
You may also be interested in
 
Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url

Back to Top