VB.Net Creating a MP3 playlist that goes to next song using MediaPlayer COM reference (WMP.dll) -


i have vb.net (community 2013) windows form app has buttons open mp3 directly, open , list contents of folder (listing mp3s) , putting them list box. second part focusing on. currently, user double clicks song listed folder contents, , adds separate list box working "playlist". user can open folder, double click songs , add playlist. right now, playlist allow double click 1 song , play correctly. however, cannot figure out how move next song in list automatically. know logic of getting selected index increase in list box , how tell play song, getting detect precise time when current song ends (using mediaplayer.playstate) tricky. tried following code hangs in infinite loop believe (high cpu usage , no audio).

intplaylen = lisboxplaylist.items.count         'variable intplaylen set  length of playlist. intplayind = lisboxplaylist.selectedindex       'variable inplayind index (current position) in playlist.      if intplaylen > 0                                      'if playlist length @ least 1         intind integer = intplayind (intplaylen - 1)  'for loop counts current index (selected pos. first line in sub) total length             lisboxplaylist.selectedindex = intind             strcurrplaying = lisboxplaylist.selecteditem        'current file path pulled listbox's current selection , put string             mplayer.open(strcurrplaying)                        'media player opens file             mplayer.play()                                      'media player plays file             intplaystate = mplayer.playstate             until intplaystate = 1                           'this loops sets variable intplaystate current status of media player,                 intplaystate = mplayer.playstate                'and stops when state 1 (which means stopped)                 intind += 1             loop         next      end if 

any ideas on how can have check mediaplayer.playstate (https://msdn.microsoft.com/en-us/library/windows/desktop/dd564085%28v=vs.85%29.aspx?f=255&mspperror=-2147217396) without getting stuck in while loop?

thanks!! haven't programmed in vb since college (10+ years ago) , fun project of mine. other experience have had since writing os deployment app winpe in vb.net worked pretty well. logic throwing me off!


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

Bubble Sort Manually a Linked List in Java -

asp.net mvc - SSO between MVCForum and Umbraco7 -