// Name: wx/mediactrl.h
// Purpose: wxMediaCtrl class
// Author: Ryan Norton <wxprojects@comcast.net>
-// Modified by:
+// Modified by:
// Created: 11/07/04
// RCS-ID: $Id$
// Copyright: (c) Ryan Norton
#define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
#define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
+// ----------------------------------------------------------------------------
+//
+// wxMediaEvent
+//
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxMediaEvent : public wxNotifyEvent
+{
+public:
+ // ------------------------------------------------------------------------
+ // wxMediaEvent Constructor
+ //
+ // Normal constructor, much the same as wxNotifyEvent
+ // ------------------------------------------------------------------------
+ wxMediaEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
+ : wxNotifyEvent(commandType, id)
+ { }
+
+ // ------------------------------------------------------------------------
+ // wxMediaEvent Copy Constructor
+ //
+ // Normal copy constructor, much the same as wxNotifyEvent
+ // ------------------------------------------------------------------------
+ wxMediaEvent(const wxMediaEvent &clone)
+ : wxNotifyEvent(clone)
+ { }
+
+ // ------------------------------------------------------------------------
+ // wxMediaEvent::Clone
+ //
+ // Allocates a copy of this object.
+ // Required for wxEvtHandler::AddPendingEvent
+ // ------------------------------------------------------------------------
+ virtual wxEvent *Clone() const
+ { return new wxMediaEvent(*this); }
+
+
+ // Put this class on wxWidget's RTTI table
+ DECLARE_DYNAMIC_CLASS(wxMediaEvent)
+};
+
// ----------------------------------------------------------------------------
//
// wxMediaCtrl
wxMediaCtrl() : m_imp(NULL), m_bLoaded(false), m_bLoop(false)
{ }
- wxMediaCtrl(wxWindow* parent, wxWindowID id,
+ wxMediaCtrl(wxWindow* parent, wxWindowID id,
const wxString& fileName = wxT(""),
- const wxPoint& pos = wxDefaultPosition,
+ const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = 0,
+ long style = 0,
const wxString& szBackend = wxT(""),
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxT("mediaCtrl"))
: m_imp(NULL), m_bLoaded(false), m_bLoop(false)
- { Create(parent, id, fileName, pos, size, style,
+ { Create(parent, id, fileName, pos, size, style,
szBackend, validator, name); }
- wxMediaCtrl(wxWindow* parent, wxWindowID id,
+ wxMediaCtrl(wxWindow* parent, wxWindowID id,
const wxURI& location,
- const wxPoint& pos = wxDefaultPosition,
+ const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = 0,
+ long style = 0,
const wxString& szBackend = wxT(""),
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxT("mediaCtrl"))
: m_imp(NULL), m_bLoop(false)
- { Create(parent, id, location, pos, size, style,
+ { Create(parent, id, location, pos, size, style,
szBackend, validator, name); }
~wxMediaCtrl();
bool Create(wxWindow* parent, wxWindowID id,
const wxString& fileName = wxT(""),
- const wxPoint& pos = wxDefaultPosition,
+ const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = 0,
+ long style = 0,
const wxString& szBackend = wxT(""),
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxT("mediaCtrl"));
bool Create(wxWindow* parent, wxWindowID id,
const wxURI& location,
- const wxPoint& pos = wxDefaultPosition,
+ const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = 0,
+ long style = 0,
const wxString& szBackend = wxT(""),
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxT("mediaCtrl"));
bool DoCreate(wxClassInfo* instance,
wxWindow* parent, wxWindowID id,
- const wxPoint& pos = wxDefaultPosition,
+ const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = 0,
+ long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxT("mediaCtrl"));
wxLongLong GetDuration();
protected:
- void OnMediaFinished(const class wxMediaEvent& evt);
+ void OnMediaFinished(wxMediaEvent& evt);
virtual void DoMoveWindow(int x, int y, int w, int h);
wxSize DoGetBestSize() const;
virtual ~wxMediaBackend();
- virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
- wxWindow* WXUNUSED(parent),
- wxWindowID WXUNUSED(id),
- const wxPoint& WXUNUSED(pos),
+ virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
+ wxWindow* WXUNUSED(parent),
+ wxWindowID WXUNUSED(id),
+ const wxPoint& WXUNUSED(pos),
const wxSize& WXUNUSED(size),
- long WXUNUSED(style),
+ long WXUNUSED(style),
const wxValidator& WXUNUSED(validator),
const wxString& WXUNUSED(name))
{ return false; }
- virtual bool Play()
+ virtual bool Play()
{ return false; }
- virtual bool Pause()
+ virtual bool Pause()
{ return false; }
- virtual bool Stop()
+ virtual bool Stop()
{ return false; }
- virtual bool Load(const wxString& WXUNUSED(fileName))
+ virtual bool Load(const wxString& WXUNUSED(fileName))
{ return false; }
- virtual bool Load(const wxURI& WXUNUSED(location))
+ virtual bool Load(const wxURI& WXUNUSED(location))
{ return false; }
- virtual bool SetPosition(wxLongLong WXUNUSED(where))
+ virtual bool SetPosition(wxLongLong WXUNUSED(where))
{ return 0; }
- virtual wxLongLong GetPosition()
+ virtual wxLongLong GetPosition()
{ return 0; }
- virtual wxLongLong GetDuration()
+ virtual wxLongLong GetDuration()
{ return 0; }
- virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
- int WXUNUSED(w), int WXUNUSED(h))
+ virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
+ int WXUNUSED(w), int WXUNUSED(h))
{ }
- virtual wxSize GetVideoSize() const
+ virtual wxSize GetVideoSize() const
{ return wxSize(0,0); }
- virtual double GetPlaybackRate()
+ virtual double GetPlaybackRate()
{ return 0.0; }
- virtual bool SetPlaybackRate(double WXUNUSED(dRate))
+ virtual bool SetPlaybackRate(double WXUNUSED(dRate))
{ return false; }
virtual wxMediaState GetState()
DECLARE_CLASS(wxMediaBackend)
};
-// ----------------------------------------------------------------------------
-//
-// wxMediaEvent
-//
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxMediaEvent : public wxNotifyEvent
-{
-public:
- // ------------------------------------------------------------------------
- // wxMediaEvent Constructor
- //
- // Normal constructor, much the same as wxNotifyEvent
- // ------------------------------------------------------------------------
- wxMediaEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
- : wxNotifyEvent(commandType, id)
- { }
-
- // ------------------------------------------------------------------------
- // wxMediaEvent Copy Constructor
- //
- // Normal copy constructor, much the same as wxNotifyEvent
- // ------------------------------------------------------------------------
- wxMediaEvent(const wxMediaEvent &clone)
- : wxNotifyEvent(clone)
- { }
-
- // ------------------------------------------------------------------------
- // wxMediaEvent::Clone
- //
- // Allocates a copy of this object.
- // Required for wxEvtHandler::AddPendingEvent
- // ------------------------------------------------------------------------
- virtual wxEvent *Clone() const
- { return new wxMediaEvent(*this); }
-
-
- // Put this class on wxWidget's RTTI table
- DECLARE_DYNAMIC_CLASS(wxMediaEvent)
-};
-
//Event ID to give to our events
#define wxMEDIA_FINISHED_ID 13000
#define wxMEDIA_STOP_ID 13001
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// MediaPlayer
//
-// This is a simple example of how to use all the funtionality of
+// This is a simple example of how to use all the funtionality of
// the wxMediaCtrl class in wxWidgets.
//
// To use this sample, simply select Open File from the file menu,
#include "wx/textdlg.h" //for getting user text from OpenURL
// ----------------------------------------------------------------------------
-// Bail out if the user doesn't want one of the
+// Bail out if the user doesn't want one of the
// things we need
// ----------------------------------------------------------------------------
// the wxApp exists, and thus will crash the application if you try it.
//
// IMPLEMENT_APP does this, and also implements the platform-specific entry
-// routine, such as main or WinMain(). Use IMPLEMENT_APP_NO_MAIN if you do
+// routine, such as main or WinMain(). Use IMPLEMENT_APP_NO_MAIN if you do
// not desire this behavior.
// ----------------------------------------------------------------------------
IMPLEMENT_APP(MyApp)
wxMenu *menuFile = new wxMenu;
wxMenu *helpMenu = new wxMenu;
- helpMenu->Append(wxID_ABOUT,
- _T("&About...\tF1"),
+ helpMenu->Append(wxID_ABOUT,
+ _T("&About...\tF1"),
_T("Show about dialog"));
menuFile->Append(wxID_OPENFILE, _T("&Open File"), _T("Open a File"));
menuFile->Append(wxID_PAUSE, _T("P&ause"), _T("Pause playback"));
menuFile->Append(wxID_STOP, _T("&Stop"), _T("Stop playback"));
menuFile->AppendSeparator();
- menuFile->AppendCheckItem(wxID_LOOP,
- _T("&Loop"),
+ menuFile->AppendCheckItem(wxID_LOOP,
+ _T("&Loop"),
_T("Loop Selected Media"));
menuFile->AppendSeparator();
- menuFile->Append(wxID_EXIT,
- _T("E&xit\tAlt-X"),
+ menuFile->Append(wxID_EXIT,
+ _T("E&xit\tAlt-X"),
_T("Quit this program"));
wxMenuBar *menuBar = new wxMenuBar();
ResetStatus();
SetStatusText(m_basestatus);
#endif // wxUSE_STATUSBAR
-
+
//
// Connect events.
- //
+ //
// There are two ways in wxWidgets to use events -
// Message Maps and Connections.
//
// END_EVENT_TABLE()
//
// Where MyFrame is the class with the DECLARE_MESSAGE_MAP
- // in it. EVT_XXX(XXX) are each of your handlers, such
+ // in it. EVT_XXX(XXX) are each of your handlers, such
// as EVT_MENU for menu events and the XXX inside
// is the parameters to the event macro - in the case
// of EVT_MENU the menu id and then the function to call.
//
// The third is the function handler for the event -
// You need to cast it to the specific event handler
- // type, then to a wxEventFunction, then to a
+ // type, then to a wxEventFunction, then to a
// wxObjectEventFunction - I.E.
// (wxObjectEventFunction)(wxEventFunction)
// (wxCommandEventFunction) &MyFrame::MyHandler
//
- // The fourth is an optional userdata param -
+ // The fourth is an optional userdata param -
// this is of historical relevance only and is
// there only for backwards compatability.
//
// The fifth is the context in which to call the
// handler - by default (this param is optional)
// this. For example in your event handler
- // if you were to call "this->MyFunc()"
+ // if you were to call "this->MyFunc()"
// it would literally do this->MyFunc. However,
// if you were to pass myHandler as the fifth
// parameter, for instance, you would _really_
//
// Menu events
//
- this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnQuit);
-
- this->Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+
+ this->Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnAbout);
- this->Connect(wxID_LOOP, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_LOOP, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnLoop);
- this->Connect(wxID_OPENFILE, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_OPENFILE, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnOpenFile);
- this->Connect(wxID_PLAY, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_PLAY, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnPlay);
- this->Connect(wxID_PAUSE, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_PAUSE, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnPause);
- this->Connect(wxID_STOP, wxEVT_COMMAND_MENU_SELECTED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_STOP, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnStop);
//
// Slider events
//
- this->Connect(wxID_SLIDER, wxEVT_COMMAND_SLIDER_UPDATED,
- (wxObjectEventFunction) (wxEventFunction)
+ this->Connect(wxID_SLIDER, wxEVT_COMMAND_SLIDER_UPDATED,
+ (wxObjectEventFunction) (wxEventFunction)
(wxCommandEventFunction) &MyFrame::OnSeek);
//
// Media Control events
//
- this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_STOP,
- (wxObjectEventFunction) (wxEventFunction)
- (wxCommandEventFunction) &MyFrame::OnMediaStop);
+ this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_STOP,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxMediaEventFunction) &MyFrame::OnMediaStop);
//
// End of Events
// ----------------------------------------------------------------------------
// MyFrame Destructor
//
-// 1) Deletes child objects implicitly
+// 1) Deletes child objects implicitly
// 2) Delete our timer explicitly
// ----------------------------------------------------------------------------
MyFrame::~MyFrame()
// ----------------------------------------------------------------------------
// MyFrame::ResetStatus
//
-// Here we just make a simple status string with some useful info about
+// Here we just make a simple status string with some useful info about
// the media that we won't change later - such as the length of the media.
//
// We then append some other info that changes in MyTimer::Notify, then
-// set the status bar to this text.
+// set the status bar to this text.
//
// In real applications, you'd want to find a better way to do this,
// such as static text controls (wxStaticText).
-//
-// We display info here in seconds (wxMediaCtrl uses milliseconds - that's why
+//
+// We display info here in seconds (wxMediaCtrl uses milliseconds - that's why
// we divide by 1000).
//
// We also reset our loop counter here.
// ----------------------------------------------------------------------------
// MyFrame::OnAbout
-//
+//
// Called from help->about.
// Gets some info about this application.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// MyFrame::OnPlay
-//
+//
// Called from file->play.
// Resumes the media if it is paused or stopped.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// MyFrame::OnPause
-//
+//
// Called from file->pause.
// Pauses the media in-place.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// MyFrame::OnStop
-//
+//
// Called from file->stop.
// Where it stops depends on whether you can seek in the
// media control or not - if you can it stops and seeks to the beginning,
// ----------------------------------------------------------------------------
// MyFrame::OnSeek
-//
+//
// Called from file->seek.
// Called when the user moves the slider -
// seeks to a position within the media
// ----------------------------------------------------------------------------
// MyFrame::OnMediaStop
-//
+//
// Called when the media is about to stop playing.
// Here we just increase our loop counter
// ----------------------------------------------------------------------------
//
// 1) Update our slider with the position were are in in the media
// 2) Update our status bar with the base text from MyFrame::ResetStatus,
-// append some non-static (changing) info to it, then set the
+// append some non-static (changing) info to it, then set the
// status bar text to that result
// ----------------------------------------------------------------------------
void MyTimer::Notify()
virtual ~wxAMMediaBackend();
- virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
+ virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
wxWindowID id,
- const wxPoint& pos,
+ const wxPoint& pos,
const wxSize& size,
- long style,
+ long style,
const wxValidator& validator,
const wxString& name);
bool m_bVideo;
- static LRESULT CALLBACK NotifyWndProc(HWND hWnd, UINT nMsg,
+ static LRESULT CALLBACK NotifyWndProc(HWND hWnd, UINT nMsg,
WPARAM wParam, LPARAM lParam);
-
- LRESULT CALLBACK OnNotifyWndProc(HWND hWnd, UINT nMsg,
+
+ LRESULT CALLBACK OnNotifyWndProc(HWND hWnd, UINT nMsg,
WPARAM wParam, LPARAM lParam);
wxControl* m_ctrl;
- IGraphBuilder* m_pGB;
+ IGraphBuilder* m_pGB;
IMediaControl* m_pMC;
IMediaEventEx* m_pME;
IVideoWindow* m_pVW;
wxMCIMediaBackend();
~wxMCIMediaBackend();
- virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
+ virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
wxWindowID id,
- const wxPoint& pos,
+ const wxPoint& pos,
const wxSize& size,
- long style,
+ long style,
const wxValidator& validator,
const wxString& name);
virtual double GetPlaybackRate();
virtual bool SetPlaybackRate(double dRate);
- static LRESULT CALLBACK NotifyWndProc(HWND hWnd, UINT nMsg,
+ static LRESULT CALLBACK NotifyWndProc(HWND hWnd, UINT nMsg,
WPARAM wParam, LPARAM lParam);
- LRESULT CALLBACK OnNotifyWndProc(HWND hWnd, UINT nMsg,
+ LRESULT CALLBACK OnNotifyWndProc(HWND hWnd, UINT nMsg,
WPARAM wParam, LPARAM lParam);
MCIDEVICEID m_hDev; //Our MCI Device ID/Handler
wxQTMediaBackend();
~wxQTMediaBackend();
- virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
+ virtual bool CreateControl(wxControl* ctrl, wxWindow* parent,
wxWindowID id,
- const wxPoint& pos,
+ const wxPoint& pos,
const wxSize& size,
- long style,
+ long style,
const wxValidator& validator,
const wxString& name);
// wxAMMediaBackend Constructor
//
// Sets m_hNotifyWnd to NULL to signify that we haven't loaded anything yet
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
wxAMMediaBackend::wxAMMediaBackend() : m_hNotifyWnd(NULL)
{
}
//---------------------------------------------------------------------------
// wxAMMediaBackend Destructor
//
-// Cleans up everything
-//---------------------------------------------------------------------------
+// Cleans up everything
+//---------------------------------------------------------------------------
wxAMMediaBackend::~wxAMMediaBackend()
{
if (m_hNotifyWnd)
// so we just create a normal control with a black background.
//
// We also check to see if ActiveMovie is installed
-//---------------------------------------------------------------------------
-bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
+//---------------------------------------------------------------------------
+bool wxAMMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
wxWindowID id,
- const wxPoint& pos,
+ const wxPoint& pos,
const wxSize& size,
- long style,
+ long style,
const wxValidator& validator,
const wxString& name)
-{
+{
//create our filter graph
HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void**)&m_pGB);
//Set our background color to black by default
//
ctrl->SetBackgroundColour(*wxBLACK);
-
+
m_ctrl = ctrl;
return true;
}
// wxAMMediaBackend::Load (file version)
//
// Creates an Active Movie filter graph from a file or url
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
bool wxAMMediaBackend::Load(const wxString& fileName)
{
if(m_hNotifyWnd)
wxAMVERIFY( m_pGB->QueryInterface(IID_IBasicAudio, (void**)&m_pBA) );
wxAMVERIFY( m_pGB->QueryInterface(IID_IBasicVideo, (void**)&m_pBV) );
- //We could tell if the media has audio or not by
+ //We could tell if the media has audio or not by
//something like
//-----
//long lVolume;
//
//Obtain the _actual_ size of the movie & remember it
//
- long nX,
+ long nX,
nY;
m_bestSize.x = m_bestSize.y = 0;
- m_bVideo = SUCCEEDED( m_pVW->GetWindowPosition( &nX,
+ m_bVideo = SUCCEEDED( m_pVW->GetWindowPosition( &nX,
&nY,
(long*)&m_bestSize.x,
(long*)&m_bestSize.y) );
//
// Create a hidden window and register to handle
// directshow events for this graph
- // Note that wxCanvasClassName is already registered
+ // Note that wxCanvasClassName is already registered
// and used by all wxWindows and normal wxControls
- //
+ //
m_hNotifyWnd = ::CreateWindow
(
wxCanvasClassName,
return false;
}
-
- ::SetWindowLongPtr(m_hNotifyWnd, GWLP_WNDPROC,
+
+ ::SetWindowLongPtr(m_hNotifyWnd, GWLP_WNDPROC,
(LONG_PTR)wxAMMediaBackend::NotifyWndProc);
::SetWindowLong(m_hNotifyWnd, GWL_USERDATA,
(LONG) this);
- wxAMVERIFY( m_pME->SetNotifyWindow((OAHWND)m_hNotifyWnd,
+ wxAMVERIFY( m_pME->SetNotifyWindow((OAHWND)m_hNotifyWnd,
WM_GRAPHNOTIFY, 0) );
//
// Loads media from a URL. Interestingly enough DirectShow
// appears (?) to escape the URL for us, at least on normal
// files
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
bool wxAMMediaBackend::Load(const wxURI& location)
{
return Load(location.BuildUnescapedURI());
// wxAMMediaBackend::Play
//
// Plays the stream. If it is non-seekable, it will restart it.
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
bool wxAMMediaBackend::Play()
{
return SUCCEEDED( m_pMC->Run() );
// wxAMMediaBackend::Pause
//
// Pauses the stream.
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
bool wxAMMediaBackend::Pause()
{
return SUCCEEDED( m_pMC->Pause() );
// wxAMMediaBackend::Stop
//
// Stops the stream.
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
bool wxAMMediaBackend::Stop()
{
bool bOK = SUCCEEDED( m_pMC->Stop() );
//---------------------------------------------------------------------------
// wxAMMediaBackend::SetPosition
//
-// 1) Translates the current position's time to directshow time,
+// 1) Translates the current position's time to directshow time,
// which is in a scale of 100 nanoseconds
// 2) Sets the play position of the IMediaSeeking interface -
// passing NULL as the stop position means to keep the old
// stop position
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
bool wxAMMediaBackend::SetPosition(wxLongLong where)
{
LONGLONG pos = ((LONGLONG)where.GetValue()) * 10000;
//
// 1) Obtains the current play and stop positions from IMediaSeeking
// 2) Returns the play position translated to our time base
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
wxLongLong wxAMMediaBackend::GetPosition()
{
LONGLONG outCur, outStop;
//
// 1) Obtains the duration of the media from the IMediaSeeking interface
// 2) Converts that value to our time base, and returns it
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
wxLongLong wxAMMediaBackend::GetDuration()
{
LONGLONG outDuration;
// Obtains the state from the IMediaControl interface.
// Note that it's enumeration values for stopping/playing
// etc. are the same as ours, so we just do a straight cast.
-// TODO: MS recommends against INFINITE here for
+// TODO: MS recommends against INFINITE here for
// IMediaControl::GetState- do it in stages
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
wxMediaState wxAMMediaBackend::GetState()
{
HRESULT hr;
//
// Pretty simple way of obtaining the playback rate from
// the IMediaSeeking interface
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
double wxAMMediaBackend::GetPlaybackRate()
{
double dRate;
//
// Sets the playback rate of the media - DirectShow is pretty good
// about this, actually
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
bool wxAMMediaBackend::SetPlaybackRate(double dRate)
{
return SUCCEEDED( m_pMS->SetRate(dRate) );
//---------------------------------------------------------------------------
// wxAMMediaBackend::NotifyWndProc
//
-// Here we check to see if DirectShow tells us we've reached the stop
+// Here we check to see if DirectShow tells us we've reached the stop
// position in our stream - if it has, it may not actually stop
// the stream - which we need to do...
-//---------------------------------------------------------------------------
-LRESULT CALLBACK wxAMMediaBackend::NotifyWndProc(HWND hWnd, UINT nMsg,
- WPARAM wParam,
+//---------------------------------------------------------------------------
+LRESULT CALLBACK wxAMMediaBackend::NotifyWndProc(HWND hWnd, UINT nMsg,
+ WPARAM wParam,
LPARAM lParam)
{
wxAMMediaBackend* backend = (wxAMMediaBackend*)
return backend->OnNotifyWndProc(hWnd, nMsg, wParam, lParam);
}
-LRESULT CALLBACK wxAMMediaBackend::OnNotifyWndProc(HWND hWnd, UINT nMsg,
- WPARAM wParam,
+LRESULT CALLBACK wxAMMediaBackend::OnNotifyWndProc(HWND hWnd, UINT nMsg,
+ WPARAM wParam,
LPARAM lParam)
{
if (nMsg == WM_GRAPHNOTIFY)
{
- LONG evCode,
- evParam1,
+ LONG evCode,
+ evParam1,
evParam2;
//
//Interestingly enough, DirectShow does not actually stop
//the filters - even when it reaches the end!
wxVERIFY( Stop() );
-
+
//send the event to our child
- wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
+ wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
m_ctrl->GetId());
m_ctrl->ProcessEvent(theEvent);
}
//---------------------------------------------------------------------------
// wxAMMediaBackend::Cleanup
//
-// 1) Hide/disowns the video window (MS says bad things will happen if
+// 1) Hide/disowns the video window (MS says bad things will happen if
// you don't)
// 2) Releases all the directshow interfaces we use
// TODO: Maybe there's a way to redirect the IGraphBuilder each time
// we load, rather then creating and destroying the interfaces
// each time?
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
void wxAMMediaBackend::Cleanup()
{
// Hide then disown the window
SAFE_RELEASE(m_pBV);
SAFE_RELEASE(m_pVW);
SAFE_RELEASE(m_pGB);
-
+
// Get rid of our hidden Window
DestroyWindow(m_hNotifyWnd);
m_hNotifyWnd = NULL;
// wxAMMediaBackend::GetVideoSize
//
// Obtains the cached original video size
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
wxSize wxAMMediaBackend::GetVideoSize() const
{
return m_bestSize;
// wxAMMediaBackend::Move
//
// Resizes the IVideoWindow to the size of the control window
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
void wxAMMediaBackend::Move(int x, int y, int w, int h)
{
if(m_hNotifyWnd && m_bVideo)
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// wxMCIMediaBackend
-//
+//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Simulation for <digitalv.h>
//
// Mingw and possibly other compilers don't have the digitalv.h header
-// that is needed to have some essential features of mci work with
+// that is needed to have some essential features of mci work with
// windows - so we provide the declarations for the types we use here
//---------------------------------------------------------------------------
#ifdef MCI_USE_OFFEXT
POINT ptOffset;
POINT ptExtent;
-#else
+#else
RECT rc;
#endif
} MCI_DGV_RECT_PARMS;
} MCI_DGV_WINDOW_PARMS;
typedef struct {
- DWORD_PTR dwCallback;
- DWORD dwTimeFormat;
- DWORD dwAudio;
- DWORD dwFileFormat;
- DWORD dwSpeed;
-} MCI_DGV_SET_PARMS;
+ DWORD_PTR dwCallback;
+ DWORD dwTimeFormat;
+ DWORD dwAudio;
+ DWORD dwFileFormat;
+ DWORD dwSpeed;
+} MCI_DGV_SET_PARMS;
//---------------------------------------------------------------------------
// wxMCIMediaBackend Constructor
// Here we just tell wxMediaCtrl that mci does exist (which it does, on all
// msw systems, at least in some form dating back to win16 days)
//---------------------------------------------------------------------------
-bool wxMCIMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
+bool wxMCIMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
wxWindowID id,
- const wxPoint& pos,
+ const wxPoint& pos,
const wxSize& size,
- long style,
+ long style,
const wxValidator& validator,
const wxString& name)
{
//
//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
+ //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,
+ if ( mciSendCommand(0, MCI_OPEN, MCI_OPEN_ELEMENT,
(DWORD)(LPVOID)&openParms) != 0)
return false;
MCI_DGV_WINDOW_PARMS windowParms;
windowParms.hWnd = (HWND)m_ctrl->GetHandle();
- m_bVideo = (mciSendCommand(m_hDev, MCI_WINDOW,
+ m_bVideo = (mciSendCommand(m_hDev, MCI_WINDOW,
0x00010000L, //MCI_DGV_WINDOW_HWND
(DWORD)(LPVOID)&windowParms) == 0);
//
// Create a hidden window and register to handle
// MCI events
- // Note that wxCanvasClassName is already registered
+ // Note that wxCanvasClassName is already registered
// and used by all wxWindows and normal wxControls
- //
+ //
m_hNotifyWnd = ::CreateWindow
(
wxCanvasClassName,
return false;
}
-
- ::SetWindowLong(m_hNotifyWnd, GWL_WNDPROC,
+
+ ::SetWindowLong(m_hNotifyWnd, GWL_WNDPROC,
(LONG)wxMCIMediaBackend::NotifyWndProc);
::SetWindowLong(m_hNotifyWnd, GWL_USERDATA,
// 1) Certain drivers will crash and burn if we don't pass them an
// MCI_PLAY_PARMS, despite the documentation that says otherwise...
// 2) There is a MCI_RESUME command, but MCI_PLAY does the same thing
-// and will resume from a stopped state also, so there's no need to
+// and will resume from a stopped state also, so there's no need to
// call both, for example
//---------------------------------------------------------------------------
bool wxMCIMediaBackend::Play()
MCI_PLAY_PARMS playParms;
playParms.dwCallback = (DWORD)m_hNotifyWnd;
- return ( mciSendCommand(m_hDev, MCI_PLAY, MCI_NOTIFY,
+ return ( mciSendCommand(m_hDev, MCI_PLAY, MCI_NOTIFY,
(DWORD)(LPVOID)&playParms) == 0 );
}
// wxMCIMediaBackend::Pause
//
// Pauses the MCI device - nothing special
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
bool wxMCIMediaBackend::Pause()
{
return (mciSendCommand(m_hDev, MCI_PAUSE, MCI_WAIT, 0) == 0);
// wxMCIMediaBackend::Stop
//
// Stops the MCI device & seeks to the beginning as wxMediaCtrl docs outline
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
bool wxMCIMediaBackend::Stop()
{
return (mciSendCommand(m_hDev, MCI_STOP, MCI_WAIT, 0) == 0) &&
// since we use direct comparisons with MCI_MODE_PLAY and
// MCI_MODE_PAUSE, we don't care if the MCI_STATUS call
// fails or not
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
wxMediaState wxMCIMediaBackend::GetState()
{
MCI_STATUS_PARMS statusParms;
// wxMCIMediaBackend::SetPosition
//
// Here we set the position of the device in the stream.
-// Note that MCI actually stops the device after you seek it if the
+// Note that MCI actually stops the device after you seek it if the
// device is playing/paused, so we need to play the file after
-// MCI seeks like normal APIs would
-//---------------------------------------------------------------------------
+// MCI seeks like normal APIs would
+//---------------------------------------------------------------------------
bool wxMCIMediaBackend::SetPosition(wxLongLong where)
{
MCI_SEEK_PARMS seekParms;
seekParms.dwCallback = 0;
- seekParms.dwTo = where.GetValue();
+ seekParms.dwTo = (DWORD)where.GetValue();
//device was playing?
bool bReplay = GetState() == wxMEDIASTATE_PLAYING;
- if( mciSendCommand(m_hDev, MCI_SEEK, MCI_TO,
+ if( mciSendCommand(m_hDev, MCI_SEEK, MCI_TO,
(DWORD)(LPVOID)&seekParms) != 0)
return false;
//
// Gets the position of the device in the stream using the current
// time format... nothing special here...
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
wxLongLong wxMCIMediaBackend::GetPosition()
{
MCI_STATUS_PARMS statusParms;
// wxMCIMediaBackend::GetDuration
//
// Gets the duration of the stream... nothing special
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
wxLongLong wxMCIMediaBackend::GetDuration()
{
MCI_STATUS_PARMS statusParms;
// wxMCIMediaBackend::Move
//
// Moves the window to a location
-//---------------------------------------------------------------------------
-void wxMCIMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y),
+//---------------------------------------------------------------------------
+void wxMCIMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y),
int w, int h)
{
if (m_hNotifyWnd && m_bVideo)
putParms.rc.right = w;
putParms.rc.bottom = h;
- wxMCIVERIFY( mciSendCommand(m_hDev, MCI_PUT,
+ wxMCIVERIFY( mciSendCommand(m_hDev, MCI_PUT,
0x00040000L, //MCI_DGV_PUT_DESTINATION
(DWORD)(LPSTR)&putParms) );
}
// wxMCIMediaBackend::GetVideoSize
//
// Gets the original size of the movie for sizers
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
wxSize wxMCIMediaBackend::GetVideoSize() const
{
if(m_bVideo)
{
MCI_DGV_RECT_PARMS whereParms; //ifdefed MCI_DGV_WHERE_PARMS
- wxMCIVERIFY( mciSendCommand(m_hDev, MCI_WHERE,
+ wxMCIVERIFY( mciSendCommand(m_hDev, MCI_WHERE,
0x00020000L, //MCI_DGV_WHERE_SOURCE
(DWORD)(LPSTR)&whereParms) );
-
+
return wxSize(whereParms.rc.right, whereParms.rc.bottom);
}
return wxSize(0,0);
// wxMCIMediaBackend::GetPlaybackRate
//
// TODO
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
double wxMCIMediaBackend::GetPlaybackRate()
{
return 1.0;
// wxMCIMediaBackend::SetPlaybackRate
//
// TODO
-//---------------------------------------------------------------------------
+//---------------------------------------------------------------------------
bool wxMCIMediaBackend::SetPlaybackRate(double WXUNUSED(dRate))
{
/*
MCI_DGV_SET_PARMS setParms;
setParms.dwSpeed = (DWORD) (dRate * 1000.0);
- return (mciSendCommand(m_hDev, MCI_SET,
+ return (mciSendCommand(m_hDev, MCI_SET,
0x00020000L, //MCI_DGV_SET_SPEED
(DWORD)(LPSTR)&setParms) == 0);
*/
//---------------------------------------------------------------------------
// [static] wxMCIMediaBackend::MSWWindowProc
//
-// Here we process a message when MCI reaches the stopping point
+// Here we process a message when MCI reaches the stopping point
// in the stream
-//---------------------------------------------------------------------------
-LRESULT CALLBACK wxMCIMediaBackend::NotifyWndProc(HWND hWnd, UINT nMsg,
- WPARAM wParam,
+//---------------------------------------------------------------------------
+LRESULT CALLBACK wxMCIMediaBackend::NotifyWndProc(HWND hWnd, UINT nMsg,
+ WPARAM wParam,
LPARAM lParam)
{
wxMCIMediaBackend* backend = (wxMCIMediaBackend*)
return backend->OnNotifyWndProc(hWnd, nMsg, wParam, lParam);
}
-LRESULT CALLBACK wxMCIMediaBackend::OnNotifyWndProc(HWND hWnd, UINT nMsg,
- WPARAM wParam,
+LRESULT CALLBACK wxMCIMediaBackend::OnNotifyWndProc(HWND hWnd, UINT nMsg,
+ WPARAM wParam,
LPARAM lParam)
{
if(nMsg == MM_MCINOTIFY)
if(theEvent.IsAllowed())
{
- wxMCIVERIFY( mciSendCommand(m_hDev, MCI_SEEK,
+ wxMCIVERIFY( mciSendCommand(m_hDev, MCI_SEEK,
MCI_SEEK_TO_START, 0) );
//send the event to our child
- wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
+ wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
m_ctrl->GetId());
m_ctrl->ProcessEvent(theEvent);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// wxQTMediaBackend
-//
+//
// TODO: Use a less cludgy way to pause/get state/set state
// TODO: Dynamically load from qtml.dll
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if (!m_bPaused)
{
if(!IsMovieDone(m_movie))
- MoviesTask(m_movie, MOVIE_DELAY);
+ MoviesTask(m_movie, MOVIE_DELAY);
else
{
- wxMediaEvent theEvent(wxEVT_MEDIA_STOP,
+ wxMediaEvent theEvent(wxEVT_MEDIA_STOP,
m_parent->m_ctrl->GetId());
m_parent->m_ctrl->ProcessEvent(theEvent);
wxASSERT(::GetMoviesError() == noErr);
//send the event to our child
- wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
+ wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
m_parent->m_ctrl->GetId());
m_parent->m_ctrl->ProcessEvent(theEvent);
}
// 1) Intializes QuickTime
// 2) Creates the control window
//---------------------------------------------------------------------------
-bool wxQTMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
+bool wxQTMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
wxWindowID id,
- const wxPoint& pos,
+ const wxPoint& pos,
const wxSize& size,
- long style,
+ long style,
const wxValidator& validator,
const wxString& name)
{
// 1) Get an FSSpec from the Windows path name
// 2) Open the movie
// 3) Obtain the movie instance from the movie resource
-// 4)
+// 4)
//---------------------------------------------------------------------------
bool wxQTMediaBackend::Load(const wxString& fileName)
{
short movieResFile;
FSSpec sfFile;
- if (NativePathNameToFSSpec ((char*) (const char*) fileName.mb_str(),
+ if (NativePathNameToFSSpec ((char*) (const char*) fileName.mb_str(),
&sfFile, 0) != noErr)
return false;
-
+
if (OpenMovieFile (&sfFile, &movieResFile, fsRdPerm) != noErr)
return false;
BlockMove(theURI.mb_str(), *theHandle, theURI.length() + 1);
//create the movie from the handle that refers to the URI
- err = NewMovieFromDataRef(&m_movie, newMovieActive,
- NULL, theHandle,
+ err = NewMovieFromDataRef(&m_movie, newMovieActive,
+ NULL, theHandle,
URLDataHandlerSubType);
DisposeHandle(theHandle);
m_bestSize.x = outRect.right - outRect.left;
m_bestSize.y = outRect.bottom - outRect.top;
-
+
//reparent movie/*AudioMediaCharacteristic*/
- if(GetMovieIndTrackType(m_movie, 1,
- VisualMediaCharacteristic,
- movieTrackCharacteristic |
+ if(GetMovieIndTrackType(m_movie, 1,
+ VisualMediaCharacteristic,
+ movieTrackCharacteristic |
movieTrackEnabledOnly) != NULL)
{
CreatePortAssociation(m_ctrl->GetHWND(), NULL, 0L);
-
- SetMovieGWorld(m_movie,
- (CGrafPtr) GetNativeWindowPort(m_ctrl->GetHWND()),
+
+ SetMovieGWorld(m_movie,
+ (CGrafPtr) GetNativeWindowPort(m_ctrl->GetHWND()),
nil);
}
::StopMovie(m_movie);
if(::GetMoviesError() != noErr)
return false;
-
+
::GoToBeginningOfMovie(m_movie);
return ::GetMoviesError() == noErr;
}
//---------------------------------------------------------------------------
wxMediaState wxQTMediaBackend::GetState()
{
- if ( !m_timer || (m_timer->IsRunning() == false &&
+ if ( !m_timer || (m_timer->IsRunning() == false &&
m_timer->GetPaused() == false) )
return wxMEDIASTATE_STOPPED;