allow multiple movie loading as per Julian's suggestion. DOC.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30339 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -38,7 +38,7 @@ Contructors
|
|||||||
|
|
||||||
\docparam{parent}{parent of this control. Must not be NULL.}
|
\docparam{parent}{parent of this control. Must not be NULL.}
|
||||||
\docparam{id}{id to use for events}
|
\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{label}{Control label - possible caption for the movie.}
|
||||||
\docparam{pos}{Position to put control at.}
|
\docparam{pos}{Position to put control at.}
|
||||||
\docparam{size}{Size to put the control at and to stretch movie to.}
|
\docparam{size}{Size to put the control at and to stretch movie to.}
|
||||||
@@ -55,7 +55,7 @@ Creates this control. Returns \tt{false} if it can't load the movie located at
|
|||||||
|
|
||||||
\docparam{parent}{parent of this control. Must not be NULL.}
|
\docparam{parent}{parent of this control. Must not be NULL.}
|
||||||
\docparam{id}{id to use for events}
|
\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{label}{Control label - possible caption for the movie.}
|
||||||
\docparam{pos}{Position to put control at.}
|
\docparam{pos}{Position to put control at.}
|
||||||
\docparam{size}{Size to put the control at and to stretch movie to.}
|
\docparam{size}{Size to put the control at and to stretch movie to.}
|
||||||
@@ -90,6 +90,13 @@ Obtains the state the playback of the movie is in -
|
|||||||
|
|
||||||
Obtains the length - the total amount of time the movie has
|
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}
|
\membersection{wxMovieCtrl::Pause}\label{wxmoviectrlpause}
|
||||||
|
|
||||||
|
@@ -26,12 +26,12 @@ enum wxMovieCtrlState
|
|||||||
class wxMovieCtrl : public wxControl
|
class wxMovieCtrl : public wxControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxMovieCtrl()
|
wxMovieCtrl() : m_bLoaded(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
wxMovieCtrl(wxWindow* parent, wxWindowID id, const wxString& fileName, const wxString& label = wxT(""),
|
wxMovieCtrl(wxWindow* parent, wxWindowID id, const wxString& fileName, const wxString& label = wxT(""),
|
||||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
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); }
|
{ Create(parent, id, fileName, label, pos, size, style, name); }
|
||||||
|
|
||||||
~wxMovieCtrl();
|
~wxMovieCtrl();
|
||||||
@@ -49,6 +49,8 @@ public:
|
|||||||
double GetPlaybackRate();
|
double GetPlaybackRate();
|
||||||
bool SetPlaybackRate(double dRate);
|
bool SetPlaybackRate(double dRate);
|
||||||
|
|
||||||
|
bool Load(const wxString& fileName);
|
||||||
|
|
||||||
#if wxUSE_DATETIME
|
#if wxUSE_DATETIME
|
||||||
bool Seek(const wxTimeSpan& where);
|
bool Seek(const wxTimeSpan& where);
|
||||||
wxTimeSpan Tell();
|
wxTimeSpan Tell();
|
||||||
@@ -59,6 +61,9 @@ protected:
|
|||||||
void OnSize(wxSizeEvent& evt);
|
void OnSize(wxSizeEvent& evt);
|
||||||
wxSize DoGetBestSize() const;
|
wxSize DoGetBestSize() const;
|
||||||
bool InitQT();
|
bool InitQT();
|
||||||
|
void Cleanup();
|
||||||
|
|
||||||
|
bool m_bLoaded;
|
||||||
|
|
||||||
struct MovieRecord* m_movie;
|
struct MovieRecord* m_movie;
|
||||||
wxSize m_bestSize;
|
wxSize m_bestSize;
|
||||||
|
@@ -26,12 +26,12 @@ enum wxMovieCtrlState
|
|||||||
class wxMovieCtrl : public wxControl
|
class wxMovieCtrl : public wxControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxMovieCtrl()
|
wxMovieCtrl() : m_bLoaded(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
wxMovieCtrl(wxWindow* parent, wxWindowID id, const wxString& fileName, const wxString& label = wxT(""),
|
wxMovieCtrl(wxWindow* parent, wxWindowID id, const wxString& fileName, const wxString& label = wxT(""),
|
||||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
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); }
|
{ Create(parent, id, fileName, label, pos, size, style, name); }
|
||||||
|
|
||||||
~wxMovieCtrl();
|
~wxMovieCtrl();
|
||||||
@@ -44,6 +44,8 @@ public:
|
|||||||
bool Pause();
|
bool Pause();
|
||||||
bool Stop();
|
bool Stop();
|
||||||
|
|
||||||
|
bool Load(const wxString& fileName);
|
||||||
|
|
||||||
wxMovieCtrlState GetState();
|
wxMovieCtrlState GetState();
|
||||||
|
|
||||||
double GetPlaybackRate();
|
double GetPlaybackRate();
|
||||||
@@ -60,7 +62,10 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void OnSize(wxSizeEvent& evt);
|
void OnSize(wxSizeEvent& evt);
|
||||||
wxSize DoGetBestSize() const;
|
wxSize DoGetBestSize() const;
|
||||||
|
void Cleanup();
|
||||||
|
|
||||||
bool m_bVideo;
|
bool m_bVideo;
|
||||||
|
bool m_bLoaded;
|
||||||
|
|
||||||
//msw-specific - we need to overload the window proc
|
//msw-specific - we need to overload the window proc
|
||||||
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||||
|
@@ -130,6 +130,34 @@ bool wxMovieCtrl::Create(wxWindow* parent, wxWindowID id, const wxString& fileNa
|
|||||||
const wxString& label, const wxPoint& pos, const wxSize& size,
|
const wxString& label, const wxPoint& pos, const wxSize& size,
|
||||||
long WXUNUSED(style), const wxString& name)
|
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() )
|
if ( !InitQT() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -186,13 +214,6 @@ bool wxMovieCtrl::Create(wxWindow* parent, wxWindowID id, const wxString& fileNa
|
|||||||
wxEVT_SIZE,
|
wxEVT_SIZE,
|
||||||
(wxObjectEventFunction) (wxEventFunction) (wxSizeEventFunction) &wxMovieCtrl::OnSize );
|
(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
|
//reparent movie
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
CreatePortAssociation(this->GetHWND(), NULL, 0L);
|
CreatePortAssociation(this->GetHWND(), NULL, 0L);
|
||||||
@@ -206,13 +227,10 @@ bool wxMovieCtrl::Create(wxWindow* parent, wxWindowID id, const wxString& fileNa
|
|||||||
#endif
|
#endif
|
||||||
, nil);
|
, nil);
|
||||||
|
|
||||||
//go!
|
|
||||||
SetLabel(label);
|
|
||||||
Play();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool wxMovieCtrl::Play()
|
bool wxMovieCtrl::Play()
|
||||||
{
|
{
|
||||||
::StartMovie(m_movie);
|
::StartMovie(m_movie);
|
||||||
@@ -290,23 +308,31 @@ wxMovieCtrlState wxMovieCtrl::GetState()
|
|||||||
return wxMOVIECTRL_PAUSED;
|
return wxMOVIECTRL_PAUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxMovieCtrl::Cleanup()
|
||||||
|
{
|
||||||
|
//soldier in OnSize
|
||||||
|
this->Disconnect( wxID_ANY,
|
||||||
|
wxEVT_SIZE,
|
||||||
|
(wxObjectEventFunction) (wxEventFunction) (wxSizeEventFunction) &wxMovieCtrl::OnSize );
|
||||||
|
|
||||||
|
delete m_timer;
|
||||||
|
|
||||||
|
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()
|
wxMovieCtrl::~wxMovieCtrl()
|
||||||
{
|
{
|
||||||
if (m_timer)
|
if(m_bLoaded)
|
||||||
{
|
Cleanup();
|
||||||
delete m_timer;
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxMovieCtrl::DoGetBestSize() const
|
wxSize wxMovieCtrl::DoGetBestSize() const
|
||||||
|
@@ -51,6 +51,35 @@ bool wxMovieCtrl::Create(wxWindow* parent, wxWindowID id, const wxString& fileNa
|
|||||||
const wxString& label, const wxPoint& pos, const wxSize& size,
|
const wxString& label, const wxPoint& pos, const wxSize& size,
|
||||||
long style, const wxString& name)
|
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
|
//cast helpers
|
||||||
IGraphBuilder*& pGB = (IGraphBuilder*&) m_pGB;
|
IGraphBuilder*& pGB = (IGraphBuilder*&) m_pGB;
|
||||||
IMediaControl*& pMC = (IMediaControl*&) m_pMC;
|
IMediaControl*& pMC = (IMediaControl*&) m_pMC;
|
||||||
@@ -95,17 +124,6 @@ bool wxMovieCtrl::Create(wxWindow* parent, wxWindowID id, const wxString& fileNa
|
|||||||
m_bestSize.x = nSX;
|
m_bestSize.x = nSX;
|
||||||
m_bestSize.y = nSY;
|
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)
|
if (m_bVideo)
|
||||||
{
|
{
|
||||||
wxDSVERIFY( pVW->put_Owner((OAHWND)this->GetHandle()) );
|
wxDSVERIFY( pVW->put_Owner((OAHWND)this->GetHandle()) );
|
||||||
@@ -117,9 +135,7 @@ bool wxMovieCtrl::Create(wxWindow* parent, wxWindowID id, const wxString& fileNa
|
|||||||
//set the time format
|
//set the time format
|
||||||
wxDSVERIFY( pMS->SetTimeFormat(&TIME_FORMAT_MEDIA_TIME) );
|
wxDSVERIFY( pMS->SetTimeFormat(&TIME_FORMAT_MEDIA_TIME) );
|
||||||
|
|
||||||
SetLabel(label);
|
m_bLoaded = true;
|
||||||
Play();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,8 +293,13 @@ WXLRESULT wxMovieCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPar
|
|||||||
return wxControl::MSWWindowProc(nMsg, wParam, lParam);
|
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
|
//cast helpers
|
||||||
IGraphBuilder*& pGB = (IGraphBuilder*&) m_pGB;
|
IGraphBuilder*& pGB = (IGraphBuilder*&) m_pGB;
|
||||||
IMediaControl*& pMC = (IMediaControl*&) m_pMC;
|
IMediaControl*& pMC = (IMediaControl*&) m_pMC;
|
||||||
@@ -305,6 +326,12 @@ wxMovieCtrl::~wxMovieCtrl()
|
|||||||
SAFE_RELEASE(pGB);
|
SAFE_RELEASE(pGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxMovieCtrl::~wxMovieCtrl()
|
||||||
|
{
|
||||||
|
if (m_bLoaded)
|
||||||
|
Cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
wxSize wxMovieCtrl::DoGetBestSize() const
|
wxSize wxMovieCtrl::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
return m_bestSize;
|
return m_bestSize;
|
||||||
|
Reference in New Issue
Block a user