Solved

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

Posted on 2007-11-23
10
13,941 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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
 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb. Net application freezes 9 48
Assigning handler to UserControls in flowlayoutpanel 4 23
Modal Popup Extender control 1 22
Write to a printer using vb.net 9 30
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 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