// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-/*
- FIXME FIXME FIXME:
- - extract different backends in different files (better yet, make backends
- dynamically loadable...), they have nothing to do with each other and
- this file is huge and also separate the standard contents from our code
- itself
- */
+// FIXME FIXME FIXME:
+// extract different backends in different files (better yet, make backends
+// dynamically loadable...), they have nothing to do with each other and this
+// file is huge and also separate the standard contents from our code itself
+
struct IActiveMovie2 : public IActiveMovie
{
STDMETHOD(IsSoundCardEnabled)(VARIANT_BOOL __RPC_FAR *pbSoundCard) PURE;
struct IActiveMovie2 : public IActiveMovie
{
STDMETHOD(IsSoundCardEnabled)(VARIANT_BOOL __RPC_FAR *pbSoundCard) PURE;
virtual wxLongLong GetDownloadProgress()
{
wxLongLong progress, total;
DoGetDownloadProgress(&progress, &total);
return progress;
}
virtual wxLongLong GetDownloadProgress()
{
wxLongLong progress, total;
DoGetDownloadProgress(&progress, &total);
return progress;
}
virtual wxLongLong GetDownloadTotal()
{
wxLongLong progress, total;
virtual wxLongLong GetDownloadTotal()
{
wxLongLong progress, total;
wxDynamicLibrary m_dllQuartz;
LPAMGETERRORTEXT m_lpAMGetErrorText;
wxString GetErrorString(HRESULT hrdsv);
wxDynamicLibrary m_dllQuartz;
LPAMGETERRORTEXT m_lpAMGetErrorText;
wxString GetErrorString(HRESULT hrdsv);
static Boolean MCFilterProc (MovieController theController,
short action, void *params, LONG_PTR refCon);
static Boolean MCFilterProc (MovieController theController,
short action, void *params, LONG_PTR refCon);
- wxSize m_bestSize; //Original movie size
- Movie m_movie; //QT Movie handle/instance
- bool m_bVideo; //Whether or not we have video
- bool m_bPlaying; //Whether or not movie is playing
- wxTimer* m_timer; //Load or Play timer
- wxQuickTimeLibrary m_lib; //DLL to load functions from
- ComponentInstance m_pMC; //Movie Controller
+ wxSize m_bestSize; // Original movie size
+ Movie m_movie; // QT Movie handle/instance
+ bool m_bVideo; // Whether or not we have video
+ bool m_bPlaying; // Whether or not movie is playing
+ wxTimer* m_timer; // Load or Play timer
+ wxQuickTimeLibrary m_lib; // DLL to load functions from
+ ComponentInstance m_pMC; // Movie Controller
m_qtb->m_ctrl->Connect(m_qtb->m_ctrl->GetId(),
wxEVT_ERASE_BACKGROUND,
wxEraseEventHandler(wxQTMediaEvtHandler::OnEraseBackground),
m_qtb->m_ctrl->Connect(m_qtb->m_ctrl->GetId(),
wxEVT_ERASE_BACKGROUND,
wxEraseEventHandler(wxQTMediaEvtHandler::OnEraseBackground),
- if( m_lpAMGetErrorText != NULL &&
- (*m_lpAMGetErrorText)(hrdsv, szError, MAX_ERROR_TEXT_LEN) == 0)
+ if ( m_lpAMGetErrorText != NULL &&
+ (*m_lpAMGetErrorText)(hrdsv, szError, MAX_ERROR_TEXT_LEN) == 0)
- if(m_parent->m_pAM->QueryInterface(IID_IActiveMovie2,
- (void**)&pAM2) == 0 &&
- pAM2->get_ReadyState(&nState) == 0)
+ if (m_parent->m_pAM->QueryInterface(IID_IActiveMovie2, (void**)&pAM2) == 0
+ && pAM2->get_ReadyState(&nState) == 0)
- if(m_parent->GetState() == wxMEDIASTATE_STOPPED &&
- //NB: Stop events could get triggered by the interface
- //if ShowPlayerControls is enabled,
- //so we need this hack here to make an attempt
- //at it not getting sent - but its far from ideal -
- //they can still get sent in some cases
- m_parent->GetPosition() == m_parent->GetDuration())
+ // NB: Stop events could get triggered by the interface
+ // if ShowPlayerControls is enabled,
+ // so we need this hack here to make an attempt
+ // at it not getting sent - but its far from ideal -
+ // they can still get sent in some cases
+ if (m_parent->GetState() == wxMEDIASTATE_STOPPED &&
+ m_parent->GetPosition() == m_parent->GetDuration())
// The following is an alternative way - but it doesn't seem
// to work with the IActiveMovie control - it probably processes
// its own events
// The following is an alternative way - but it doesn't seem
// to work with the IActiveMovie control - it probably processes
// its own events
- //
- while( m_pME->GetEvent(&evCode, &evParam1, &evParam2, 0) == 0 )
+ while ( m_pME->GetEvent(&evCode, &evParam1, &evParam2, 0) == 0 )
- //Even though this makes a messagebox this
- //is windows where we can do gui stuff in seperate
- //threads :)
+ // Even though this makes a messagebox, this is Windows,
+ // where we can do GUI stuff in separate threads :)
wxFAIL_MSG(m_pBE->GetErrorString(hr));
}
// If this is the end of the clip, notify handler
wxFAIL_MSG(m_pBE->GetErrorString(hr));
}
// If this is the end of the clip, notify handler
- wxAMMediaBackend* m_pBE; //Backend pointer
- IMediaEvent* m_pME; //To determine when to send stop event
+ wxAMMediaBackend* m_pBE; // Backend pointer
+ IMediaEvent* m_pME; // To determine when to send stop event
//---------------------------------------------------------------------------
// wxAMMediaBackend Constructor
//---------------------------------------------------------------------------
// wxAMMediaBackend Constructor
//---------------------------------------------------------------------------
wxAMMediaBackend::~wxAMMediaBackend()
{
//---------------------------------------------------------------------------
wxAMMediaBackend::~wxAMMediaBackend()
{
//---------------------------------------------------------------------------
void wxAMMediaBackend::Clear()
{
//---------------------------------------------------------------------------
void wxAMMediaBackend::Clear()
{
- // Now determine which (if any) media player interface is
- // available - IMediaPlayer or IActiveMovie
- if( ::CoCreateInstance(CLSID_MediaPlayer, NULL,
+ // determine which (if any) media player interface
+ // is available - IMediaPlayer or IActiveMovie
+ if ( ::CoCreateInstance(CLSID_MediaPlayer, NULL,
m_pAM->QueryInterface(IID_IMediaPlayer, (void**)&m_pMP);
}
else
{
m_pMP->QueryInterface(IID_IActiveMovie, (void**)&m_pAM);
}
m_pAM->QueryInterface(IID_IMediaPlayer, (void**)&m_pMP);
}
else
{
m_pMP->QueryInterface(IID_IActiveMovie, (void**)&m_pAM);
}
// Create window
// By default wxWindow(s) is created with a border -
// so we need to get rid of those
//
// Since we don't have a child window like most other
// backends, we don't need wxCLIP_CHILDREN
// Create window
// By default wxWindow(s) is created with a border -
// so we need to get rid of those
//
// Since we don't have a child window like most other
// backends, we don't need wxCLIP_CHILDREN
if ( !ctrl->wxControl::Create(parent, id, pos, size,
(style & ~wxBORDER_MASK) | wxBORDER_NONE,
validator, name) )
if ( !ctrl->wxControl::Create(parent, id, pos, size,
(style & ~wxBORDER_MASK) | wxBORDER_NONE,
validator, name) )
m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
m_pAX = new wxActiveXContainer(ctrl,
m_pMP ? IID_IMediaPlayer : IID_IActiveMovie,
m_pAM);
m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
m_pAX = new wxActiveXContainer(ctrl,
m_pMP ? IID_IMediaPlayer : IID_IActiveMovie,
m_pAM);
// TODO: Unsure what actual effect this has
m_pMP->put_WindowlessVideo(VARIANT_TRUE);
}
else
m_pAM->put_MovieWindowSize(amvDoubleOriginalSize);
// TODO: Unsure what actual effect this has
m_pMP->put_WindowlessVideo(VARIANT_TRUE);
}
else
m_pAM->put_MovieWindowSize(amvDoubleOriginalSize);
//---------------------------------------------------------------------------
bool wxAMMediaBackend::Load(const wxURI& location)
{
//---------------------------------------------------------------------------
bool wxAMMediaBackend::Load(const wxURI& location)
{
{
pPlay->put_UseHTTPProxy(VARIANT_TRUE);
pPlay->put_HTTPProxyHost(wxBasicString(proxy.GetServer()).Get());
{
pPlay->put_UseHTTPProxy(VARIANT_TRUE);
pPlay->put_HTTPProxyHost(wxBasicString(proxy.GetServer()).Get());
//---------------------------------------------------------------------------
bool wxAMMediaBackend::DoLoad(const wxString& location)
{
//---------------------------------------------------------------------------
bool wxAMMediaBackend::DoLoad(const wxString& location)
{
- // Play the movie the normal way through the embedded
- // WMP. Supposively Open is better in theory because
+ // Play the movie the normal way through the embedded WMP.
+ // Supposedly, Open is better in theory because
hr = m_pMP->Open( wxBasicString(location).Get() );
else
hr = m_pAM->put_FileName( wxBasicString(location).Get() );
hr = m_pMP->Open( wxBasicString(location).Get() );
else
hr = m_pAM->put_FileName( wxBasicString(location).Get() );
m_pAM->get_ImageSourceWidth((long*)&m_bestSize.x);
m_pAM->get_ImageSourceHeight((long*)&m_bestSize.y);
m_pAM->get_ImageSourceWidth((long*)&m_bestSize.x);
m_pAM->get_ImageSourceHeight((long*)&m_bestSize.y);
// Note that IMediaPlayer doesn't have a statusbar by
// default but IActiveMovie does - so lets try to keep
// the interface consistant
// Note that IMediaPlayer doesn't have a statusbar by
// default but IActiveMovie does - so lets try to keep
// the interface consistant
{
// Actually try to play the movie, even though it may not be loaded yet.
HRESULT hr = m_pAM->Run();
{
// Actually try to play the movie, even though it may not be loaded yet.
HRESULT hr = m_pAM->Run();
- //h,m,s,milli - outdur is in 1 second (double)
+ // h,m,s,milli - outdur is in 1 second (double)
//---------------------------------------------------------------------------
double wxAMMediaBackend::GetVolume()
{
//---------------------------------------------------------------------------
double wxAMMediaBackend::GetVolume()
{
//---------------------------------------------------------------------------
bool wxAMMediaBackend::SetVolume(double dVolume)
{
//---------------------------------------------------------------------------
bool wxAMMediaBackend::SetVolume(double dVolume)
{
- //pow(10.0, -80.0) to correct 0 == -INF
- long lVolume = (long)(2000.0 * log10(pow(10.0, -80.0)+dVolume));
+ // pow(10.0, -80.0) to correct 0 == -INF
+ long lVolume = (long)(2000.0 * log10( pow( 10.0, -80.0) + dVolume ) );
- //h,m,s,milli - outdur is in 1 second (double)
+ // h,m,s,milli - outdur is in 1 second (double)
// windows - so we provide the declarations for the types we use here
//---------------------------------------------------------------------------
// windows - so we provide the declarations for the types we use here
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// wxMCIMediaBackend Constructor
//---------------------------------------------------------------------------
// wxMCIMediaBackend Constructor
//---------------------------------------------------------------------------
wxMCIMediaBackend::~wxMCIMediaBackend()
{
//---------------------------------------------------------------------------
wxMCIMediaBackend::~wxMCIMediaBackend()
{
{
mciSendCommand(m_hDev, MCI_CLOSE, 0, 0);
DestroyWindow(m_hNotifyWnd);
{
mciSendCommand(m_hDev, MCI_CLOSE, 0, 0);
DestroyWindow(m_hNotifyWnd);
// Create window
// By default wxWindow(s) is created with a border -
// so we need to get rid of those, and create with
// wxCLIP_CHILDREN, so that if the driver/backend
// is a child window, it refereshes properly
// Create window
// By default wxWindow(s) is created with a border -
// so we need to get rid of those, and create with
// wxCLIP_CHILDREN, so that if the driver/backend
// is a child window, it refereshes properly
if ( !ctrl->wxControl::Create(parent, id, pos, size,
(style & ~wxBORDER_MASK) | wxBORDER_NONE | wxCLIP_CHILDREN,
validator, name) )
return false;
m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
if ( !ctrl->wxControl::Create(parent, id, pos, size,
(style & ~wxBORDER_MASK) | wxBORDER_NONE | wxCLIP_CHILDREN,
validator, name) )
return false;
m_ctrl = wxStaticCast(ctrl, wxMediaCtrl);
//---------------------------------------------------------------------------
bool wxMCIMediaBackend::Load(const wxString& fileName)
{
//---------------------------------------------------------------------------
bool wxMCIMediaBackend::Load(const wxString& fileName)
{
{
mciSendCommand(m_hDev, MCI_CLOSE, 0, 0);
DestroyWindow(m_hNotifyWnd);
m_hNotifyWnd = NULL;
}
{
mciSendCommand(m_hDev, MCI_CLOSE, 0, 0);
DestroyWindow(m_hNotifyWnd);
m_hNotifyWnd = NULL;
}
- //
- //Opens a file and has MCI select a device. Normally you'd put
- //MCI_OPEN_TYPE in addition to MCI_OPEN_ELEMENT - however if you
- //omit this it tells MCI to select the device instead. This is
- //good because we have no reliable way of "enumerating" the devices
- //in MCI
- //
+ // Opens a file and has MCI select a device. Normally you'd put
+ // MCI_OPEN_TYPE in addition to MCI_OPEN_ELEMENT - however if you
+ // omit this it tells MCI to select the device instead. This is good
+ // because we have no reliable way of "enumerating" the devices in MCI
MCI_OPEN_PARMS openParms;
openParms.lpstrElementName = (wxChar*) fileName.c_str();
if ( mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT,
(DWORD)(LPVOID)&openParms) != 0)
MCI_OPEN_PARMS openParms;
openParms.lpstrElementName = (wxChar*) fileName.c_str();
if ( mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT,
(DWORD)(LPVOID)&openParms) != 0)
MCI_SET_PARMS setParms;
setParms.dwCallback = 0;
setParms.dwTimeFormat = MCI_FORMAT_MILLISECONDS;
if (mciSendCommand(m_hDev, MCI_SET, MCI_SET_TIME_FORMAT,
(DWORD)(LPVOID)&setParms) != 0)
MCI_SET_PARMS setParms;
setParms.dwCallback = 0;
setParms.dwTimeFormat = MCI_FORMAT_MILLISECONDS;
if (mciSendCommand(m_hDev, MCI_SET, MCI_SET_TIME_FORMAT,
(DWORD)(LPVOID)&setParms) != 0)
MCI_DGV_WINDOW_PARMS windowParms;
windowParms.hWnd = (HWND)m_ctrl->GetHandle();
m_bVideo = (mciSendCommand(m_hDev, MCI_WINDOW,
MCI_DGV_WINDOW_PARMS windowParms;
windowParms.hWnd = (HWND)m_ctrl->GetHandle();
m_bVideo = (mciSendCommand(m_hDev, MCI_WINDOW,
// Note that wxCanvasClassName is already registered
// and used by all wxWindows and normal wxControls
// Note that wxCanvasClassName is already registered
// and used by all wxWindows and normal wxControls
bool bOK = ( mciSendCommand(m_hDev, MCI_PLAY, MCI_NOTIFY,
(DWORD)(LPVOID)&playParms) == 0 );
bool bOK = ( mciSendCommand(m_hDev, MCI_PLAY, MCI_NOTIFY,
(DWORD)(LPVOID)&playParms) == 0 );
mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPVOID)&statusParms);
mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPVOID)&statusParms);
-#else /* wxUSE_LONGLONG_WX */
- /* no way to return it in one piece */
- wxASSERT( where.GetHi()==0 );
+#else // wxUSE_LONGLONG_WX
+ // no way to return it in one piece
+ wxASSERT( where.GetHi() == 0 );
- if( mciSendCommand(m_hDev, MCI_SEEK, MCI_TO,
+ if ( mciSendCommand(m_hDev, MCI_SEEK, MCI_TO,
if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPSTR)&statusParms) != 0)
if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPSTR)&statusParms) != 0)
if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPSTR)&statusParms) != 0)
if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPSTR)&statusParms) != 0)
audioParms.dwValue = (DWORD) (dVolume * 1000.0);
audioParms.dwOver = 0;
audioParms.lpstrAlgorithm = NULL;
audioParms.lpstrQuality = NULL;
audioParms.dwValue = (DWORD) (dVolume * 1000.0);
audioParms.dwOver = 0;
audioParms.lpstrAlgorithm = NULL;
audioParms.lpstrQuality = NULL;
- if (mciSendCommand(m_hDev, 0x0873, //MCI_SETAUDIO
- //MCI_DGV_SETAUDIO+(_ITEM | _VALUE)
+ if (mciSendCommand(m_hDev, 0x0873, // MCI_SETAUDIO
+ // MCI_DGV_SETAUDIO + (_ITEM | _VALUE)
0x00800000L | 0x01000000L,
(DWORD)(LPSTR)&audioParms) != 0)
0x00800000L | 0x01000000L,
(DWORD)(LPSTR)&audioParms) != 0)
if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPSTR)&statusParms) != 0)
if (mciSendCommand(m_hDev, MCI_STATUS, MCI_STATUS_ITEM,
(DWORD)(LPSTR)&statusParms) != 0)
//
// Moves the window to a location
//---------------------------------------------------------------------------
//
// Moves the window to a location
//---------------------------------------------------------------------------
-void wxMCIMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y),
- int w, int h)
+void wxMCIMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
- //wxStackWalker will crash and burn here on assert
- //and mci doesn't like 0 and 0 for some reason (out of range )
- //so just don't it in that case
- if(w || h)
+ // wxStackWalker will crash and burn here on assert
+ // and MCI doesn't like 0 and 0 for some reason (out of range)
+ // so just don't it in that case
+ if (w || h)
//---------------------------------------------------------------------------
wxSize wxMCIMediaBackend::GetVideoSize() const
{
//---------------------------------------------------------------------------
wxSize wxMCIMediaBackend::GetVideoSize() const
{
(DWORD)(LPSTR)&whereParms) );
return wxSize(whereParms.rc.right, whereParms.rc.bottom);
}
(DWORD)(LPSTR)&whereParms) );
return wxSize(whereParms.rc.right, whereParms.rc.bottom);
}
//---------------------------------------------------------------------------
bool wxMCIMediaBackend::SetPlaybackRate(double WXUNUSED(dRate))
{
//---------------------------------------------------------------------------
bool wxMCIMediaBackend::SetPlaybackRate(double WXUNUSED(dRate))
{
MCI_WAVE_SET_SAMPLESPERSEC
MCI_DGV_SET_PARMS setParms;
setParms.dwSpeed = (DWORD) (dRate * 1000.0);
return (mciSendCommand(m_hDev, MCI_SET,
MCI_WAVE_SET_SAMPLESPERSEC
MCI_DGV_SET_PARMS setParms;
setParms.dwSpeed = (DWORD) (dRate * 1000.0);
return (mciSendCommand(m_hDev, MCI_SET,
- wxMCIVERIFY( mciSendCommand(m_hDev, MCI_SEEK,
- MCI_SEEK_TO_START, 0) );
-
+ wxMCIVERIFY( mciSendCommand(m_hDev, MCI_SEEK, MCI_SEEK_TO_START, 0) );
QueueFinishEvent();
}
}
}
return DefWindowProc(hWnd, nMsg, wParam, lParam);
}
QueueFinishEvent();
}
}
}
return DefWindowProc(hWnd, nMsg, wParam, lParam);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
IMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend, wxMediaBackend)
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
IMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend, wxMediaBackend)
{
m_pLib->MoviesTask(m_movie, 0);
//kMovieLoadStatePlayable
{
m_pLib->MoviesTask(m_movie, 0);
//kMovieLoadStatePlayable
- // Handle the stop event - if the movie has reached
- // the end, notify our handler
+ // Handle the stop event - if the movie has reached
+ // the end, notify our handler
EventRecord theEvent;
pThis->m_lib.NativeEventToMacEvent(&msg, &theEvent);
pThis->m_lib.MCIsPlayerEvent(pThis->m_pMC, &theEvent);
EventRecord theEvent;
pThis->m_lib.NativeEventToMacEvent(&msg, &theEvent);
pThis->m_lib.MCIsPlayerEvent(pThis->m_pMC, &theEvent);
//---------------------------------------------------------------------------
wxQTMediaBackend::~wxQTMediaBackend()
{
//---------------------------------------------------------------------------
wxQTMediaBackend::~wxQTMediaBackend()
{
if ( !ctrl->wxControl::Create(parent, id, pos, size,
(style & ~wxBORDER_MASK) | wxBORDER_NONE,
validator, name) )
if ( !ctrl->wxControl::Create(parent, id, pos, size,
(style & ~wxBORDER_MASK) | wxBORDER_NONE,
validator, name) )
// can use it as a WindowRef
m_lib.CreatePortAssociation(m_ctrl->GetHWND(), NULL, 0L);
// can use it as a WindowRef
m_lib.CreatePortAssociation(m_ctrl->GetHWND(), NULL, 0L);
//---------------------------------------------------------------------------
bool wxQTMediaBackend::Load(const wxString& fileName)
{
//---------------------------------------------------------------------------
bool wxQTMediaBackend::Load(const wxString& fileName)
{
- if (m_lib.NativePathNameToFSSpec ((char*) (const char*) fileName.mb_str(),
- &sfFile, 0) != noErr)
- return false;
+ err = m_lib.NativePathNameToFSSpec(
+ (char*) (const char*) fileName.mb_str(),
+ &sfFile, 0);
+ result = (err == noErr);
- if (m_lib.OpenMovieFile (&sfFile, &movieResFile, fsRdPerm) != noErr)
- return false;
+ if (result)
+ {
+ err = m_lib.OpenMovieFile(&sfFile, &movieResFile, fsRdPerm);
+ result = (err == noErr);
+ }
- NULL
- ); //wasChanged
-
- //m_lib.GetMoviesStickyError() because it may not find the
- //proper codec and play black video and other strange effects,
- //not to mention mess up the dynamic backend loading scheme
- //of wxMediaCtrl - so it just does what the QuickTime player does
- if(err == noErr && m_lib.GetMoviesStickyError() == noErr)
- {
- m_lib.CloseMovieFile (movieResFile);
-
- FinishLoad();
- return true;
+ NULL ); // wasChanged
+ result = (err == noErr && m_lib.GetMoviesStickyError() == noErr);
+
+ // check m_lib.GetMoviesStickyError() because it may not find the
+ // proper codec and play black video and other strange effects,
+ // not to mention mess up the dynamic backend loading scheme
+ // of wxMediaCtrl - so it just does what the QuickTime player does
+ if (result)
+ {
+ m_lib.CloseMovieFile(movieResFile);
+ FinishLoad();
+ }
//---------------------------------------------------------------------------
// wxQTMediaBackend::PPRMProc (static)
//---------------------------------------------------------------------------
// wxQTMediaBackend::PPRMProc (static)
long lTime = pBE->m_lib.GetMovieTime(theMovie,NULL);
Fixed rate = pBE->m_lib.GetMoviePreferredRate(theMovie);
long lTime = pBE->m_lib.GetMovieTime(theMovie,NULL);
Fixed rate = pBE->m_lib.GetMoviePreferredRate(theMovie);
pBE->m_timer = new wxQTLoadTimer(pBE->m_movie, pBE, &pBE->m_lib);
pBE->m_timer->Start(MOVIE_DELAY);
}
pBE->m_timer = new wxQTLoadTimer(pBE->m_movie, pBE, &pBE->m_lib);
pBE->m_timer->Start(MOVIE_DELAY);
}
//---------------------------------------------------------------------------
// wxQTMediaBackend::Load (URL Version)
//
//---------------------------------------------------------------------------
// wxQTMediaBackend::Load (URL Version)
//
//---------------------------------------------------------------------------
bool wxQTMediaBackend::Load(const wxURI& location)
{
//---------------------------------------------------------------------------
bool wxQTMediaBackend::Load(const wxURI& location)
{
OSErr err = m_lib.NewMovieFromDataRef(&m_movie, newMovieActive |
newMovieAsyncOK
/*|newMovieIdleImportOK*/,
OSErr err = m_lib.NewMovieFromDataRef(&m_movie, newMovieActive |
newMovieAsyncOK
/*|newMovieIdleImportOK*/,
timeNow = m_lib.GetMovieTime(m_movie, NULL);
wxASSERT(m_lib.GetMoviesError() == noErr);
timeNow = m_lib.GetMovieTime(m_movie, NULL);
wxASSERT(m_lib.GetMoviesError() == noErr);
- //
- // Note that the callback here is optional,
- // but without it PrePrerollMovie can be buggy
- // (see Apple ml). Also, some may wonder
- // why we need this at all - this is because
- // Apple docs say QuickTime streamed movies
- // require it if you don't use a Movie Controller,
- // which we don't by default.
+ // Note that the callback here is optional,
+ // but without it PrePrerollMovie can be buggy
+ // (see Apple ml). Also, some may wonder
+ // why we need this at all - this is because
+ // Apple docs say QuickTime streamed movies
+ // require it if you don't use a Movie Controller,
+ // which we don't by default.
//
m_lib.PrePrerollMovie(m_movie, timeNow, playRate,
(WXFARPROC)wxQTMediaBackend::PPRMProc,
(void*)this);
//
m_lib.PrePrerollMovie(m_movie, timeNow, playRate,
(WXFARPROC)wxQTMediaBackend::PPRMProc,
(void*)this);
//---------------------------------------------------------------------------
// wxQTMediaBackend::FinishLoad
//
//---------------------------------------------------------------------------
// wxQTMediaBackend::FinishLoad
//
// Create the playing/streaming timer
m_timer = new wxQTPlayTimer(m_movie, (wxQTMediaBackend*) this, &m_lib);
wxASSERT(m_timer);
// Create the playing/streaming timer
m_timer = new wxQTPlayTimer(m_movie, (wxQTMediaBackend*) this, &m_lib);
wxASSERT(m_timer);
m_lib.GetMovieNaturalBoundsRect (m_movie, &outRect);
wxASSERT(m_lib.GetMoviesError() == noErr);
m_bestSize.x = outRect.right - outRect.left;
m_bestSize.y = outRect.bottom - outRect.top;
m_lib.GetMovieNaturalBoundsRect (m_movie, &outRect);
wxASSERT(m_lib.GetMoviesError() == noErr);
m_bestSize.x = outRect.right - outRect.left;
m_bestSize.y = outRect.bottom - outRect.top;
m_lib.SetMovieTimeScale(m_movie, 1000);
wxASSERT(m_lib.GetMoviesError() == noErr);
m_lib.SetMovieTimeScale(m_movie, 1000);
wxASSERT(m_lib.GetMoviesError() == noErr);
return m_lib.GetMoviesError() == noErr;
}
//---------------------------------------------------------------------------
// wxQTMediaBackend::GetPlaybackRate
//
return m_lib.GetMoviesError() == noErr;
}
//---------------------------------------------------------------------------
// wxQTMediaBackend::GetPlaybackRate
//
//---------------------------------------------------------------------------
double wxQTMediaBackend::GetPlaybackRate()
{
//---------------------------------------------------------------------------
double wxQTMediaBackend::GetPlaybackRate()
{
//---------------------------------------------------------------------------
// wxQTMediaBackend::SetPlaybackRate
//
//---------------------------------------------------------------------------
// wxQTMediaBackend::SetPlaybackRate
//
//---------------------------------------------------------------------------
bool wxQTMediaBackend::SetPlaybackRate(double dRate)
{
m_lib.SetMovieRate(m_movie, (Fixed) (dRate * 0x10000));
//---------------------------------------------------------------------------
bool wxQTMediaBackend::SetPlaybackRate(double dRate)
{
m_lib.SetMovieRate(m_movie, (Fixed) (dRate * 0x10000));
//---------------------------------------------------------------------------
bool wxQTMediaBackend::SetPosition(wxLongLong where)
{
//---------------------------------------------------------------------------
bool wxQTMediaBackend::SetPosition(wxLongLong where)
{
- //NB: For some reason SetMovieTime does not work
- //correctly with the Quicktime Windows SDK (6)
- //From Muskelkatermann at the wxForum
- //http://www.solidsteel.nl/users/wxwidgets/viewtopic.php?t=2957
- //RN - note that I have not verified this but there
- //is no harm in calling SetMovieTimeValue instead
+ // NB: For some reason SetMovieTime does not work
+ // correctly with the Quicktime Windows SDK (6)
+ // From Muskelkatermann at the wxForum
+ // http://www.solidsteel.nl/users/wxwidgets/viewtopic.php?t=2957
+ // RN - note that I have not verified this but there
+ // is no harm in calling SetMovieTimeValue instead
#if 0
TimeRecord theTimeRecord;
memset(&theTimeRecord, 0, sizeof(TimeRecord));
#if 0
TimeRecord theTimeRecord;
memset(&theTimeRecord, 0, sizeof(TimeRecord));
//---------------------------------------------------------------------------
// wxQTMediaBackend::GetState
//
//---------------------------------------------------------------------------
// wxQTMediaBackend::GetState
//
//---------------------------------------------------------------------------
wxMediaState wxQTMediaBackend::GetState()
{
//---------------------------------------------------------------------------
wxMediaState wxQTMediaBackend::GetState()
{
//---------------------------------------------------------------------------
bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
{
//---------------------------------------------------------------------------
bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags)
{
wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxWndProc);
m_lib.DisposeMovieController(m_pMC);
m_pMC = NULL;
wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxWndProc);
m_lib.DisposeMovieController(m_pMC);
m_pMC = NULL;
m_lib.MCDoAction(m_pMC, 32, (void*)true); //mcActionSetKeysEnabled
m_lib.MCSetActionFilterWithRefCon(m_pMC,
(WXFARPROC)wxQTMediaBackend::MCFilterProc, (void*)this);
m_lib.MCDoAction(m_pMC, 32, (void*)true); //mcActionSetKeysEnabled
m_lib.MCSetActionFilterWithRefCon(m_pMC,
(WXFARPROC)wxQTMediaBackend::MCFilterProc, (void*)this);
- m_bestSize.y += 16; //movie controller height
-
- //
- // By default the movie controller uses its own color
- // pallette for the movie which can be bad on some files -
- // so turn it off. Also turn off its frame/border for
- // the movie
- //
- // Also we take care of a couple of the interface flags here
- //
+ m_bestSize.y += 16; // movie controller height
+
+ // By default the movie controller uses its own colour palette
+ // for the movie which can be bad on some files, so turn it off.
+ // Also turn off its frame/border for the movie
+ // Also take care of a couple of the interface flags here
- mcFlags |= ( //(1<<0)/*mcFlagSuppressMovieFrame*/ |
- (1<<3)/*mcFlagsUseWindowPalette*/
- | ((flags & wxMEDIACTRLPLAYERCONTROLS_STEP)
- ? 0 : (1<<1)/*mcFlagSuppressStepButtons*/)
- | ((flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME)
- ? 0 : (1<<2)/*mcFlagSuppressSpeakerButton*/)
- // | (1<<4) /*mcFlagDontInvalidate*/ //if we take care of repainting ourselves
- );
+
+ mcFlags |=
+ // (1<< 0) /*mcFlagSuppressMovieFrame*/ |
+ (1<< 3) /*mcFlagsUseWindowPalette*/
+ | ((flags & wxMEDIACTRLPLAYERCONTROLS_STEP)
+ ? 0 : (1<< 1) /*mcFlagSuppressStepButtons*/)
+ | ((flags & wxMEDIACTRLPLAYERCONTROLS_VOLUME)
+ ? 0 : (1<< 2) /*mcFlagSuppressSpeakerButton*/)
+// | (1<< 4) /*mcFlagDontInvalidate*/ // if we take care of repainting ourselves
+ ;
+
- //intercept the wndproc of our control window
- wxSetWindowProc((HWND)m_ctrl->GetHWND(),
- wxQTMediaBackend::QTWndProc);
+ // intercept the wndproc of our control window
+ wxSetWindowProc((HWND)m_ctrl->GetHWND(), wxQTMediaBackend::QTWndProc);
//
// Callback for when the movie controller recieves a message
//---------------------------------------------------------------------------
//
// Callback for when the movie controller recieves a message
//---------------------------------------------------------------------------
- switch(action)
- {
- case 8: //play button triggered - MC will set movie to opposite state
- //of current - playing ? paused : playing
+ switch (action)
+ {
+ case 8:
+ // play button triggered - MC will set movie to opposite state
+ // of current - playing ? paused : playing
+ if (pThis)
- // NB: Sometimes it doesn't redraw properly -
- // if you click on the button but don't move the mouse
- // the button will not change its state until you move
- // mcActionDraw and Refresh/Update combo do nothing
- // to help this unfortunately
- break;
- default:
- break;
- }
+ // NB: Sometimes it doesn't redraw properly -
+ // if you click on the button but don't move the mouse
+ // the button will not change its state until you move
+ // mcActionDraw and Refresh/Update combo do nothing
+ // to help this unfortunately
+ break;
+
+ case 1:
+ // don't process idle events
+ break;
+
+ default:
+ break;
//---------------------------------------------------------------------------
void wxQTMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
{
//---------------------------------------------------------------------------
void wxQTMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y), int w, int h)
{
w = 320;
Rect theRect = {0, 0, (short)h, (short)w};
w = 320;
Rect theRect = {0, 0, (short)h, (short)w};
else
{
Rect theRect = {0, 0, (short)h, (short)w};
else
{
Rect theRect = {0, 0, (short)h, (short)w};
-// TODO: We may be repainting too much here - under what exact circumstances
-// do we need this? I think Move also repaints correctly for the Movie
+// TODO: We may be repainting too much here - under what exact circumstances
+// do we need this? I think Move also repaints correctly for the Movie
// Controller, so in that instance we don't need this either
//---------------------------------------------------------------------------
void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
// Controller, so in that instance we don't need this either
//---------------------------------------------------------------------------
void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
m_pLib.MCDoAction(m_qtb->m_pMC, 2 /*mcActionDraw*/,
m_pLib.GetNativeWindowPort(m_hwnd));
}
m_pLib.MCDoAction(m_qtb->m_pMC, 2 /*mcActionDraw*/,
m_pLib.GetNativeWindowPort(m_hwnd));
}
- m_pLib.BeginUpdate(port);
- m_pLib.UpdateMovie(m_qtb->m_movie);
- wxASSERT(m_pLib.GetMoviesError() == noErr);
- m_pLib.EndUpdate(port);
- }
- else // no movie
- {
- // let the system repaint the window
- evt.Skip();
- }
+ m_pLib.BeginUpdate(port);
+ m_pLib.UpdateMovie(m_qtb->m_movie);
+ wxASSERT(m_pLib.GetMoviesError() == noErr);
+ m_pLib.EndUpdate(port);
+ }
+ else
+ {
+ // no movie
+ // let the system repaint the window
+ evt.Skip();