[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Media Player Open File never finishes loading

I created a reference to MediaPlayer and tried to open a file wait for it to complete loading and play it.   Here is what I got.  For some reason it never finishes loading before Media.Open ReadyState = mpReadyStateUninitialized and after ReadyState = mpReadyStateLoading and it never gets to mpReadyStateComplete it continues in the loading state.   Any suggestions would be appreciated.

Corey2
                Public Media as mediaplayer.mediaplayer

      Private Sub CmdStartClick(sender As System.Object, e As System.EventArgs)

            media.Open("C:\New Stories (Highway Blues).wma")
            
            do while media.ReadyState <> media.ReadyState.mpReadyStateComplete
                  system.Windows.Forms.Application.DoEvents
            Loop
            media.Play
      End Sub
0
Corey Scheich
Asked:
Corey Scheich
  • 6
  • 4
1 Solution
 
S-TwilleyCommented:
where are you getting hte mediaplayer object from (what library/reference)
0
 
armoghanCommented:
Try this sample code.
http://www.codeproject.com/cs/media/directshowmediaplayer.asp

it is in C# but can be easily converted to VB.nET
0
 
Corey ScheichDeveloperAuthor Commented:
"where are you getting hte mediaplayer object from (what library/reference)"

I am getting it from a COM reference to the WMPCore.dll

Include WMPCore
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
S-TwilleyCommented:
I imported WMPLib instead (add the windows media control to your form temporarily to import the library and then remove):

    Dim mplayer As New WMPLib.WindowsMediaPlayer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim thisMP3 As WMPLib.IWMPMedia = mplayer.newMedia("F:\Music\Yuu.mp2")
        mplayer.currentPlaylist.appendItem(thisMP3)
        mplayer.controls.play()
    End Sub

=========

and this worked for me... so you can either use that, or try to use it to get yours to work
0
 
S-TwilleyCommented:
(you can obviously remove the windows media player control once it's imported the wmplib reference... i just add the control to import the library... bit of a quick cheat i guess)
0
 
Corey ScheichDeveloperAuthor Commented:
"(you can obviously remove the windows media player control once it's imported the wmplib reference... i just add the control to import the library... bit of a quick cheat i guess)"

I have done exactly that with other form objects just to get the right library.  Thank you.  I will check it out tonight.

Corey2
0
 
Corey ScheichDeveloperAuthor Commented:
I failed miserably last night.  I'm not using Visual Studio so I couldn't find windows media control to easily add it to the form.  I tried every COM object on the list that seems it might be WMP and none of them are the DLL you speak of.  Could you maybe find the file name of the dll and I could search for it that way.  I come really close with IWMPmedia it is included in most of the dlls i referenced.  I couldn't create a media object though.  mplayer.newmedia(filename) didn't work Newmedia not a public member of Mediaplayer.mediaplayer or WMPocx.imediaplayer2 or what ever the heck else I tried.  Is there another way to create the object.

Corey2
0
 
S-TwilleyCommented:
Right click on the toolbox and goto Add..

Select COM components

scroll down to  "Windows Media Player"... if its not there,  
    the file name on my PC is "C:\Windows\System32\wmp.dll"
0
 
Corey ScheichDeveloperAuthor Commented:
Darn I swear I tried that one.  I guess I didn't look close enough.  I'll check again tonight.

Thank you

Corey2
0
 
Corey ScheichDeveloperAuthor Commented:
Ok sorry it has been a while.  It looks like that must be added in one of the later versions of WMP I currently have 9 I think.  Anyway that .dll is nowhere to be found I will have to download a later version to follow this code.
0
 
Corey ScheichDeveloperAuthor Commented:
This hasn't been abandoned.  It apears that to use S-Twilley's suggestion I need to have MediaPlayer 9 or better.  Currently I don't.  I plan on loading it soon and testing, there just isn't enough time in a day.

Corey2
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!

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