Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems getting windows media player events down 1

Status
Not open for further replies.

AncientTiger

Programmer
Jul 5, 2001
238
US
Ok, I've worked with this control in the past, and it almost always confuses me for some reason.

I'm trying to build a simple app that's a music playlist player. I've got a "playlist" that is a listview control with a list of songs (file path for each in the .tag element), and a media player control.

I'm wanting the media control to trigger a "scrolling" script after the end of each song, but for some reason, it's just not working.

Here's what I've got so far:

Public Sub SCROLLLIST()
SI = TUNELIST.SelectedItem.Index
LC = TUNELIST.ListItems.Count
If SI = LC Then
SI = 1
Else
SI = SI + 1
End If

TUNELIST.ListItems(SI).Selected = True
DoEvents
PLAYSELECTED
DoEvents
End Sub

Public Sub PLAYSELECTED()
SI = TUNELIST.SelectedItem.Index '<<-the playlist listview
FPATH = TUNELIST.ListItems(SI).Tag
PLAYER.URL = FPATH
End Sub

Private Sub PLAYER_StatusChange()
If PLAYER.Status = "Stopped" Then
SCROLLLIST
End If
End Sub


The event is triggering, and the scrolling playlist is working, but the URL isn't loading into the control the way it should. Is there some way to reset the control? The player loads and plays the first song in the list when the app loads, but it won't play the next song when the first is finished.


------------------------------------
[yinyang] Over 20 years of programming, and still learning every day! [yinyang]
 
Check you have the right SI at the point where you get the next item. Count starts at 1 whereas Index starts at 0

I had a similar problem with movies so I used a 1 second timer initially with Enabled set to false to creat a delay so the player would finish the previous item properly.

Public Sub PLAYSELECTED()
'Start timer
Timer1.enabled=true
End Sub

Private Sub Timer1_Timer()
'Play after 1 second
SI = TUNELIST.SelectedItem.Index
Label1.caption=SI 'indicate which item
FPATH = TUNELIST.ListItems(SI).Tag
PLAYER.URL = FPATH
Timer1.Enabled=false
End Sub
 
Actually, I was able to get it to work by giving the Player's statuschange event more time to get through it's various changes...


Public Sub PLAYSELECTED()
SI = TUNELIST.SelectedItem.Index '<<-the playlist listview
FPATH = TUNELIST.ListItems(SI).Tag
PLAYER.URL = FPATH
ET = TIMER+2
WHILE TIMER <= ET
DOEVENTS
WEND

End Sub

Private Sub PLAYER_StatusChange()
If PLAYER.Status = "Stopped" Then
SCROLLLIST
End If
End Sub


Thanks for the suggestion tho!

------------------------------------
[yinyang] Over 20 years of programming, and still learning every day! [yinyang]
 
Yes that works however it locks up your app for 2 seconds whereas using a timer doesnt.
It can make other video or animations stutter.
You probably dont need more than 1/4 second unless you want a pause on purpose
 
With the DoEvents statement embedded between the loop, I notice no affect at all on the playing of the MP3's, but it might affect video differently, dunno...

Either way, thanks for the help! :D

------------------------------------
[yinyang] Over 20 years of programming, and still learning every day! [yinyang]
 
While your loop is happening you will probably have silence anyway so it will only affect other things, like another player doing something or something moving on the screen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top