BUG with WxMediaCtrl wxEVT_MEDIA_LOADED?  [SOLVED]

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.

BUG with WxMediaCtrl wxEVT_MEDIA_LOADED?

Postby knightmare0 » Wed Apr 02, 2008 2:24 am

I think there is a bug with wxEVT_MEDIA_LOADED. When I call play under this event nothing happens.


Code: Select all

void ImageEditorBFrm::WxButton4Click(wxCommandEvent& event)
{
    WxMediaCtrl1->Load("test.avi");
}

void ImageEditorBFrm::WxMediaCtrl1MediaLoaded1(wxMediaEvent& event)
{
    WxMediaCtrl1->Play();
}






anyone know whats wrong? It compiles but just wont work.
knightmare0
Experienced Solver
Experienced Solver
 
Posts: 65
Joined: Sat Mar 29, 2008 9:18 pm

Postby JimFairway » Wed Apr 02, 2008 2:42 am

Hi,

I've used it under Windows with good results.
I presume you have the following line somewhere inside a BEGIN_EVENT_TABLE macro in your code?

Code: Select all
   EVT_MEDIA_LOADED(wxID_ANY,ImageEditorBFrm::WxMediaCtrl1MediaLoaded1)


Jim
OS: Vista SP1, wxWidgets 2.8.7.
JimFairway
wxWorld Domination!
wxWorld Domination!
 
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Postby knightmare0 » Wed Apr 02, 2008 3:23 am

yes, I have tried both



Code: Select all
   EVT_MEDIA_LOADED(wxID_ANY,ImageEditorBFrm::WxMediaCtrl1MediaLoaded1)



and

Code: Select all
   EVT_MEDIA_LOADED(ID_WXMEDIACTRL1,ImageEditorBFrm::WxMediaCtrl1MediaLoaded1)



Just wont auto play somehow, I have to add another button to click play lol.
knightmare0
Experienced Solver
Experienced Solver
 
Posts: 65
Joined: Sat Mar 29, 2008 9:18 pm

  [SOLVED]

Postby knightmare0 » Wed Apr 02, 2008 3:35 am

welll this is interesting.... if I add the following code, then it will play.



Code: Select all
void ImageEditorBFrm::WxButton4Click(wxCommandEvent& event)
{
    WxMediaCtrl1->Load("test.avi");

   wxMessageBox(wxT("Test!"));

    WxMediaCtrl1->Play();

}



anyone having the same problem?
knightmare0
Experienced Solver
Experienced Solver
 
Posts: 65
Joined: Sat Mar 29, 2008 9:18 pm

Postby JimFairway » Wed Apr 02, 2008 11:40 am

Hi,

Are you running on Windows?
Have you tried the sample program?

Like I said, it works just fine for me.

Could you post more of your code?

Jim
OS: Vista SP1, wxWidgets 2.8.7.
JimFairway
wxWorld Domination!
wxWorld Domination!
 
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Hi

Postby knightmare0 » Thu Apr 03, 2008 12:24 am

Yes, Im running on Windows, but I went around the problem by using a timer.


Code: Select all
void ImageEditorBFrm::WxTimer1Timer(wxTimerEvent& event)
{

    if(WxMediaCtrl1->GetState() == wxMEDIASTATE_PLAYING){
    WxTimer1->Stop();
}
    else {
        WxMediaCtrl1->Play();
}
}
knightmare0
Experienced Solver
Experienced Solver
 
Posts: 65
Joined: Sat Mar 29, 2008 9:18 pm

Postby JimFairway » Thu Apr 03, 2008 1:46 am

Hi,

If you're happy with your workaround, you should close this one off.
Otherwise, posting some code may help as I'm not sure why it doesn't work for you, given that the sample works, and I use in my app without issue.

Jim
OS: Vista SP1, wxWidgets 2.8.7.
JimFairway
wxWorld Domination!
wxWorld Domination!
 
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Same problem

Postby stobesel » Tue Jun 30, 2009 8:36 pm

Hi, I'm having the exact same problem using wxWidgets 2.8.10

Using the exact same code snippet as the original poster, the event does not fire.

Being somewhat new to wxWidgets, I don't even now where to start...

Thanks!
stobesel
In need of some credit
In need of some credit
 
Posts: 2
Joined: Tue Jun 30, 2009 8:30 pm

Follow-up

Postby stobesel » Tue Jun 30, 2009 8:48 pm

Oddly, the Load appears to firing an EVT_MEDIA_STOP; not sure if it's supposed to.
stobesel
In need of some credit
In need of some credit
 
Posts: 2
Joined: Tue Jun 30, 2009 8:30 pm

Postby forrestcupp » Fri Jul 03, 2009 2:35 am

It's my experience that the Loaded event works in XP, but it doesn't work in Vista. I have a bug ticket submitted for this.

For those of you who have it working in Windows, are you using Vista or XP? And those who can't get it to work, are you in Vista?

If that is the case, we're probably out of luck until they get it fixed. That's interesting that you said it's throwing a stop event.

The only reason the message box thing worked is because it gave it time to load. That doesn't help if you need to play it immediately. This is a heck of a thing to not work.
forrestcupp
Earned some good credits
Earned some good credits
 
Posts: 102
Joined: Thu Dec 28, 2006 5:12 pm
Location: Indiana, US

Postby Tony0945 » Sat Aug 14, 2010 2:37 am

This is over a year old, but I don't see a solution. I am having the same problem in Linux. Works with a messagebox, doesn't work without. As a kludge, I have included wxSleep(1) after the Load() is called. There must be something wrong with the event, like maybe it is falsely triggered. But once you miss a Play(), it will never play again.
Tony0945
Experienced Solver
Experienced Solver
 
Posts: 57
Joined: Wed Oct 21, 2009 4:02 pm

Postby ngpaton » Fri Oct 15, 2010 11:14 am

Hi,

Just got this problem myself and in my case it looks like the handling in mediactrl_am.cpp wxAMMediaEvtHandler::OnActiveX() for the ReadyStateChange (0xfffffd9f) event is not correct.

According to the windows docs for this event (http://msdn.microsoft.com/en-us/library/ms985677) the media should be playable if the parameter is equal to 3 or 4.

The code however does this:

Code: Select all
    if(event.ParamCount() >= 1)
    {
        long eventParam = event[0].GetInteger(); // NGP to see value
        if(eventParam == 0)
        {
            m_bLoadEventSent = false;
        }
        // Originally this was >= 3 here but on 3 we can't get the
        // size of the video (will error) - however on 4
        // it won't play on downloaded things until it is
        // completely downloaded so we use the lesser of two evils...
        else if(eventParam == 3 &&
            !m_bLoadEventSent)
        {
            m_bLoadEventSent = true;
            m_amb->FinishLoad();
        }
    }


I changed the code slightly so I could see the parameter value easier. So this will trigger the finish load handling when the param is equal to 3. But in the cases I've seen with local files (not tested streaming) the state jumps over 3 (interactive) and goes straight to 4 (complete). The comment above the check does not make sense. Looks like this has been here since the first version of the file from Feb 2006. The order of states that I saw when loading a WAV file was 1, 0, 4, 1, 4 slightly odd order. Anyway the following change causes it to work as expected for the cases I have tested:

Code: Select all
    if(event.ParamCount() >= 1)
    {
        long eventParam = event[0].GetInteger(); // NGP to see value
        if(eventParam == 0)
        {
            // Uninitialised state. Prevent any event being
            // sent without going through the loading state
            m_bLoadEventSent = true;
        }
        else if (eventParam == 1)
        {
            // Loading state. Allow finish load to be sent
            // if either interactive (3) or complete (4) state
            // is reached.
            m_bLoadEventSent = false;
        }
        else if(eventParam >= 3 &&
            !m_bLoadEventSent)
        {
            m_bLoadEventSent = true;
            m_amb->FinishLoad();
        }
    }


I now get the wxEVT_MEDIA_LOADED event fired correctly and can start playing the media from the event handler.

Cheers

Nigel
ngpaton
Knows some wx things
Knows some wx things
 
Posts: 25
Joined: Tue May 20, 2008 8:23 am


Return to C++ Development

Who is online

Users browsing this forum: No registered users and 8 guests