Results 1 to 2 of 2

Thread: [RESOLVED] Play next song in Windows Media Player 11.0

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Resolved [RESOLVED] Play next song in Windows Media Player 11.0

    Hi,

    Way back in 2002 I used this code to play the next song in the song list in Windows Media Player under Windows XP. However, that code no longer seems to work under Windows Vista or Windows 7. Does anyone have a solution to this problem?

    Edit:

    The "EndofStream" does not seem to work in Vista or Windows 7 I will check this again after I have installed the latest Windows updates.

    vb Code:
    1. Private Sub MediaPlayer1_EndOfStream(ByVal Result As Long)
    2. 'If MediaPlayer1.Controls.currentPositionString >= MediaPlayer1.currentMedia.durationString Then
    3. MsgBox ("This is working!")
    4. 'End If
    5. End Sub

    Thanks,

    Nightwalker
    Last edited by Nightwalker83; Apr 14th, 2011 at 10:43 PM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  2. #2

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Play next song in Windows Media Player

    I solved the problem by storing the item position of frmSetup.Lstsongs in a variable:

    vb Code:
    1. Private Sub Form_Load()
    2. 'Integer index of the song to be played
    3.  s = 0
    4. End Sub

    Sending the variable to the function:

    vb Code:
    1. Private Sub mnuPlay_Click()
    2. 'If cancel then close the program
    3. 'Else choose and play a song
    4. Music1.ShowOpen
    5. frmSetup.Lstsongs.AddItem Music1.FileName
    6. Repeat:
    7.  x = MsgBox("Do you want to add more songs?", vbYesNo)
    8. If x = vbYes Then
    9. Music1.ShowOpen
    10. frmSetup.Songopt(1).Value = True
    11. frmSetup.Lstsongs.AddItem Music1.FileName
    12. GoTo Repeat
    13. ElseIf x = vbNo Then
    14. play (s)
    15. End If
    16. End Sub

    The "play" function:

    vb Code:
    1. Private Function play(s)
    2.  frmSetup.Lstsongs.Selected(s) = True
    3.  MediaPlayer1.URL = frmSetup.Lstsongs.Text
    4. End Function

    Finally checking inside a timer to check if the player had stopped, there was more than one song in the list and whether or not s was greater than the value of the number of songs in the listbox. If all those conditions were met then I would add 1 to the value of s and send the new value back to the play function.

    vb Code:
    1. Private Sub tmrDuration_Timer()
    2. If MediaPlayer1.playState = wmppsStopped And frmSetup.Songopt(1).Value = True And Not s > frmSetup.Lstsongs.ListCount Then
    3. 'Play the next song in the list
    4.  s = s + 1
    5. play (s)
    6. End If
    7. End Sub
    Last edited by Nightwalker83; Apr 14th, 2011 at 10:45 PM. Reason: Fixed spelling!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width