[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 14901
  • 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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