[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 14715
  • Last Modified:

How do I create a Windows Media Player playlist in VB.net?

I have a Windows Media Player control on a form, and when I call AXWindowsMediaPlayer1.url = "etc" it plays the song fine.

However, I am unsure how to add another file to the playlist (I believe the current playlist which is created when you play a file is called "Now Playing".)

Does anyone know how to add files to a playlist in visual basic 2005?

Thanks
0
BIGZIPZ1
Asked:
BIGZIPZ1
  • 5
  • 4
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
I've created a PlayList before using code like this:

            Dim Playlist As WMPLib.IWMPPlaylist = axWindowsMediaPlayer1.newPlaylist("MyPlayList", "")

            Playlist.appendItem(axWindowsMediaPlayer1.newMedia("c:\somePath\song1.mp3"))
            Playlist.appendItem(axWindowsMediaPlayer1.newMedia("c:\somePath\song2.mp3"))
            ' etc...

            axWindowsMediaPlayer1.currentPlaylist = Playlist
            axWindowsMediaPlayer1.Ctlcontrols.play()
0
 
BIGZIPZ1Author Commented:
Hey there Idle_Mind, I tried your code and it shows no errors in the code editor, but on running the program it crashes with this message:

"An error occurred creating the form. See Exception.InnerException for details.  The error is: Object reference not set to an instance of an object."

Any idea what that could mean?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
That could be anything...  =\

Try commenting pieces of code out until it goes away...that may help determine where the problem is.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
BIGZIPZ1Author Commented:
Hi, I have found out the line where the program crashes, it is on this code:

Dim Playlist As WMPLib.IWMPPlaylist = AxWindowsMediaPlayer1.newPlaylist("MyPlayList", "")

Should it go in a specific place in the editor? I normally have my integers and things at the top of the Public Class Form1 section.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Try declaring it in the same place as your other variables:

    Dim Playlist As WMPLib.IWMPPlaylist

But create the Playlist in the LOAD event:

    Playlist = AxWindowsMediaPlayer1.newPlaylist("MyPlayList", "")
0
 
BIGZIPZ1Author Commented:
Thanks alot!
0
 
BIGZIPZ1Author Commented:
hey it worked! God I love ee.com :D Thanks!
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Glad to hear it...    =)
0
 
paisleymCommented:
Great, now what is the difference for media

Marcelle
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Hi paisleym,

It looks like you left off part of your question?...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now