Solved

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

Posted on 2007-11-23
10
14,266 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 86

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 86

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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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 86

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
 

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 86

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 86

Expert Comment

by:Mike Tomlinson
ID: 21507622
Hi paisleym,

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

689 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