\docparam{parent}{parent of this control. Must not be NULL.}
\docparam{id}{id to use for events}
-\docparam{fileName}{File the movie is located at.}
+\docparam{fileName}{If not empty, loads this file and starts playing it immediately.}
\docparam{label}{Control label - possible caption for the movie.}
\docparam{pos}{Position to put control at.}
\docparam{size}{Size to put the control at and to stretch movie to.}
\docparam{parent}{parent of this control. Must not be NULL.}
\docparam{id}{id to use for events}
-\docparam{fileName}{File the movie is located at.}
+\docparam{fileName}{If not empty, loads this file and starts playing it immediately.}
\docparam{label}{Control label - possible caption for the movie.}
\docparam{pos}{Position to put control at.}
\docparam{size}{Size to put the control at and to stretch movie to.}
Obtains the length - the total amount of time the movie has
+\membersection{wxMovieCtrl::Load}\label{wxmoviectrlload}
+
+\func{bool}{Load}{\param{const wxString\& }{fileName}}
+
+Loads the file that \tt{fileName} refers to.
+
+Unlike Create, you must manually call Play() to start playing the file.
\membersection{wxMovieCtrl::Pause}\label{wxmoviectrlpause}
class wxMovieCtrl : public wxControl
{
public:
- wxMovieCtrl()
+ wxMovieCtrl() : m_bLoaded(false)
{ }
wxMovieCtrl(wxWindow* parent, wxWindowID id, const wxString& fileName, const wxString& label = wxT(""),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
- long style = 0, const wxString& name = wxPanelNameStr)
+ long style = 0, const wxString& name = wxPanelNameStr) : m_bLoaded(false)
{ Create(parent, id, fileName, label, pos, size, style, name); }
~wxMovieCtrl();
double GetPlaybackRate();
bool SetPlaybackRate(double dRate);
+ bool Load(const wxString& fileName);
+
#if wxUSE_DATETIME
bool Seek(const wxTimeSpan& where);
wxTimeSpan Tell();
void OnSize(wxSizeEvent& evt);
wxSize DoGetBestSize() const;
bool InitQT();
+ void Cleanup();
+
+ bool m_bLoaded;
struct MovieRecord* m_movie;
wxSize m_bestSize;
class wxMovieCtrl : public wxControl
{
public:
- wxMovieCtrl()
+ wxMovieCtrl() : m_bLoaded(false)
{ }
wxMovieCtrl(wxWindow* parent, wxWindowID id, const wxString& fileName, const wxString& label = wxT(""),
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
- long style = 0, const wxString& name = wxPanelNameStr)
+ long style = 0, const wxString& name = wxPanelNameStr) : m_bLoaded(false)
{ Create(parent, id, fileName, label, pos, size, style, name); }
~wxMovieCtrl();
bool Play();
bool Pause();
bool Stop();
+
+ bool Load(const wxString& fileName);
wxMovieCtrlState GetState();
protected:
void OnSize(wxSizeEvent& evt);
wxSize DoGetBestSize() const;
+ void Cleanup();
+
bool m_bVideo;
+ bool m_bLoaded;
//msw-specific - we need to overload the window proc
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
const wxString& label, const wxPoint& pos, const wxSize& size,
long WXUNUSED(style), const wxString& name)
{
+ //do some window stuff
+ if ( !wxControl::Create(parent, id, pos, size, wxNO_BORDER, wxDefaultValidator, name) )
+ return false;
+
+ //Set our background color to black by default
+ SetBackgroundColour(*wxBLACK);
+
+ if(!fileName.empty())
+ {
+ if (!Load(fileName))
+ return false;
+
+ SetLabel(label);
+
+ if(!Play())
+ return false;
+ }
+ else
+ wxControl::SetLabel(label);
+
+ return true;
+}
+
+bool wxMovieCtrl::Load(const wxString& fileName)
+{
+ if(m_bLoaded)
+ Cleanup();
+
if ( !InitQT() )
return false;
wxEVT_SIZE,
(wxObjectEventFunction) (wxEventFunction) (wxSizeEventFunction) &wxMovieCtrl::OnSize );
- //do some window stuff
- if ( !wxControl::Create(parent, id, pos, size, wxNO_BORDER, wxDefaultValidator, name) )
- return false;
-
- //Set our background color to black by default
- SetBackgroundColour(*wxBLACK);
-
//reparent movie
#ifdef __WXMSW__
CreatePortAssociation(this->GetHWND(), NULL, 0L);
#endif
, nil);
- //go!
- SetLabel(label);
- Play();
-
return true;
}
+
bool wxMovieCtrl::Play()
{
::StartMovie(m_movie);
return wxMOVIECTRL_PAUSED;
}
-wxMovieCtrl::~wxMovieCtrl()
+void wxMovieCtrl::Cleanup()
{
- if (m_timer)
- {
- delete m_timer;
+ //soldier in OnSize
+ this->Disconnect( wxID_ANY,
+ wxEVT_SIZE,
+ (wxObjectEventFunction) (wxEventFunction) (wxSizeEventFunction) &wxMovieCtrl::OnSize );
- StopMovie(m_movie);
- DisposeMovie(m_movie);
-
- //Note that ExitMovies() is not neccessary, but
- //the docs are fuzzy on whether or not TerminateQTML is
- ExitMovies();
+ delete m_timer;
- #ifndef __WXMAC__
- TerminateQTML();
- #endif
- }
+ StopMovie(m_movie);
+ DisposeMovie(m_movie);
+
+ //Note that ExitMovies() is not neccessary, but
+ //the docs are fuzzy on whether or not TerminateQTML is
+ ExitMovies();
+
+#ifndef __WXMAC__
+ TerminateQTML();
+#endif
+}
+
+wxMovieCtrl::~wxMovieCtrl()
+{
+ if(m_bLoaded)
+ Cleanup();
}
wxSize wxMovieCtrl::DoGetBestSize() const
const wxString& label, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
{
+ //do some window stuff - ORDER IS IMPORTANT
+ //base create
+ if ( !wxControl::Create(parent, id, pos, size, wxNO_BORDER | wxCLIP_CHILDREN, wxDefaultValidator, name) )
+ return false;
+
+ //Set our background color to black by default
+ SetBackgroundColour(*wxBLACK);
+
+ if(!fileName.empty())
+ {
+ if (!Load(fileName))
+ return false;
+
+ SetLabel(label);
+
+ if(!Play())
+ return false;
+ }
+ else
+ wxControl::SetLabel(label);
+
+ return true;
+}
+
+bool wxMovieCtrl::Load(const wxString& fileName)
+{
+ if(m_bLoaded)
+ Cleanup();
+
//cast helpers
IGraphBuilder*& pGB = (IGraphBuilder*&) m_pGB;
IMediaControl*& pMC = (IMediaControl*&) m_pMC;
m_bestSize.x = nSX;
m_bestSize.y = nSY;
-
- //do some window stuff - ORDER IS IMPORTANT
- //base create
- if ( !wxControl::Create(parent, id, pos, size, wxNO_BORDER | wxCLIP_CHILDREN, wxDefaultValidator, name) )
- return false;
-
- //TODO: Connect() here instead of message maps
-
- //Set our background color to black by default
- SetBackgroundColour(*wxBLACK);
-
if (m_bVideo)
{
wxDSVERIFY( pVW->put_Owner((OAHWND)this->GetHandle()) );
//set the time format
wxDSVERIFY( pMS->SetTimeFormat(&TIME_FORMAT_MEDIA_TIME) );
- SetLabel(label);
- Play();
-
+ m_bLoaded = true;
return true;
}
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
}
-wxMovieCtrl::~wxMovieCtrl()
+void wxMovieCtrl::Cleanup()
{
+ if(m_bVideo)
+ this->Disconnect( wxID_ANY,
+ wxEVT_SIZE,
+ (wxObjectEventFunction) (wxEventFunction) (wxSizeEventFunction) &wxMovieCtrl::OnSize );
+
//cast helpers
IGraphBuilder*& pGB = (IGraphBuilder*&) m_pGB;
IMediaControl*& pMC = (IMediaControl*&) m_pMC;
SAFE_RELEASE(pGB);
}
+wxMovieCtrl::~wxMovieCtrl()
+{
+ if (m_bLoaded)
+ Cleanup();
+}
+
wxSize wxMovieCtrl::DoGetBestSize() const
{
return m_bestSize;