Solved

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

Posted on 2007-11-23
10
13,752 Views
Last Modified: 2011-09-20
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
Comment
Question by:BIGZIPZ1
  • 5
  • 4
10 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 20341513
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
 

Author Comment

by:BIGZIPZ1
ID: 20341628
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
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 20341665
That could be anything...  =\

Try commenting pieces of code out until it goes away...that may help determine where the problem is.
0
 

Author Comment

by:BIGZIPZ1
ID: 20341680
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
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 20341752
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Closing Comment

by:BIGZIPZ1
ID: 31410726
Thanks alot!
0
 

Author Comment

by:BIGZIPZ1
ID: 20341796
hey it worked! God I love ee.com :D Thanks!
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 20341922
Glad to hear it...    =)
0
 
LVL 4

Expert Comment

by:paisleym
ID: 21507577
Great, now what is the difference for media

Marcelle
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 21507622
Hi paisleym,

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now