Jump to content
  • Advertisement
Sign in to follow this  

Music Player

This topic is 3265 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Guys, Been a while, back with another problem :) I've made a music player and I've run into some trouble in actually playing the music after the play list has been set up. Form2 is the player, I just want it to take an array of paths to songs ("C:\Path\To\File\Song.mp3") Here is the code I've got, it's written in Visual Basic and uses the AxWindowsMediaPlayer Control...
Imports System.IO
Imports System.Reflection

Public Class Form2

    ' this just takes a list of song paths ("C:\Users\You\Music\Woo.mp3", "C:\Users\You\Music\Wooooaaaa.mp3") etc.

    Sub Initiate_Songs(ByRef Songs() As String)

        AxWindowsMediaPlayer1.settings.autoStart = True

        Dim i As Integer = 0

        While i < Songs.Length And Songs(i) <> ""

            AxWindowsMediaPlayer1.URL = Songs(i)

            While AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying
            End While

            i = i + 1

        End While

    End Sub

End Class
Here are the problems... It only plays some mp3 files, some it just doesn't play anything (there is no "connecting" and the song doesn't start... no errors shown... If it does play the song, it won't play the next one... I want it to force the computer to shut down after it's finished playing the songs (no Confirm box, just turns the computer off) and I don't know how to implement that... Can anyone help? Thanks, NuclearCarnage

Share this post

Link to post
Share on other sites
Rather than spinning in a loop waiting for the playstate to change, you should just handle the PlayStateChange event.

You should also probably have a handler for the MediaError event. This should give you an idea of why certain media items don't work.

You could potentially just queue up your mp3s into wmp's playlist (see AxWindowsMediaPlayer.currentPlaylist) and let it do the work of transitioning between files.

To shutdown windows, you'll need to p/invoke ExitWindowsEx

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!