2004-11-14 18:13:18 -05:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2004-11-11 00:37:05 -05:00
%% Name: mediactrl.tex
%% Purpose: wxMediaCtrl docs
%% Author: Ryan Norton <wxprojects@comcast.net>
%% Modified by:
%% Created: 11/7/2004
%% RCS-ID: $Id$
%% Copyright: (c) Ryan Norton
%% License: wxWindows license
2004-11-14 18:13:18 -05:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2004-11-11 00:37:05 -05:00
\section { \class { wxMediaCtrl} } \label { wxmediactrl}
2004-11-14 18:13:18 -05:00
wxMediaCtrl is a class that allows a way to convieniently display types of
media, such as videos, audio files, natively through native codecs.
2004-11-11 04:32:49 -05:00
2004-11-14 18:13:18 -05:00
wxMediaCtrl uses native backends to render media, for example on Windows
there is a ActiveMovie/DirectShow backend, and on Macintosh there is a
QuickTime backend.
2004-11-11 04:32:49 -05:00
2004-11-11 00:37:05 -05:00
\wxheading { Derived from}
\helpref { wxControl} { wxcontrol}
\wxheading { Include files}
<wx/mediactrl.h>
\latexignore { \rtfignore { \wxheading { Members} } }
2004-11-14 18:13:18 -05:00
\membersection { Rendering media} \label { renderingmediawxmediactrl}
2005-02-03 06:11:36 -05:00
Depending upon the backend, wxMediaCtrl can render
2004-11-14 18:13:18 -05:00
and display pretty much any kind of media that the native system can -
such as an image, mpeg video, or mp3 (without license restrictions -
sense it relies on native system calls that may not technically
have mp3 decoding available, for example, it falls outside the
realm of licensing restrictions).
For general operation, all you need to do is call
\helpref { wxMediaCtrl::Load} { wxmediactrlload} to load the file
you want to render, then call \helpref { wxMediaCtrl::Play} { wxmediactrlplay}
to show the video/audio of the media.
More complex operations are generally more heavily dependant on the
capabilities of the backend. For example, QuickTime cannot set
the playback rate of certain streaming media - while DirectShow is
slightly more flexible in that regard.
\membersection { Operation} \label { operationwxmediactrl}
When wxMediaCtrl plays a file, it plays until the stop position
is reached (currently the end of the file/stream). Right before
it hits the end of the stream, it fires off a EVT\_ MEDIA\_ STOP
event to its parent window, at which point the event handler
can choose to veto the event, preventing the stream from actually
stopping.
Example:
\begin { verbatim}
//connect to the media event
this->Connect(wxMY_ ID, wxEVT_ MEDIA_ STOP, (wxObjectEventFunction)
(wxEventFunction)(wxMediaEventFunction) & MyFrame::OnMediaStop);
//...
void MyFrame::OnMediaStop(const wxMediaEvent& evt)
{
if(bUserWantsToSeek)
{
m_ mediactrl->SetPosition(
m_ mediactrl->GetDuration() << 1
);
evt.Veto();
}
}
\end { verbatim}
When wxMediaCtrl stops, either by the EVT\_ MEDIA\_ STOP not being
vetoed, or by manually calling
\helpref { wxMediaCtrl::Stop} { wxmediactrlstop} , where it actually
stops is not at the beginning, rather, but at the beginning of
the stream. That is, when it stops and play is called, playback
is gauranteed to start at the beginning of the media. This is
because some streams are not seekable, and when stop is called
on them they return to the beginning, thus wxMediaCtrl tries
to keep consistant for all types of media.
\membersection { Choosing a backend} \label { choosingbackendwxmediactrl}
Generally, you should almost certainly leave this part up to
wxMediaCtrl - but if you need a certain backend for a particular
reason, such as QuickTime for playing .mov files, all you need
to do to choose a specific backend is to pass the
name of the backend class to
\helpref { wxMediaCtrl::Create} { wxmediactrlcreate} .
The following are valid backend identifiers -
\twocolwidtha { 7cm}
\begin { twocollist} \itemsep =0pt
\twocolitem { { \bf wxMEDIABACKEND\_ DIRECTSHOW} } {
Use ActiveMovie/DirectShow. Requires wxUSE\_ DIRECTSHOW to be
enabled, requires linkage with the static library strmiids.lib,
and is available on Windows Only.}
\twocolitem { { \bf wxMEDIABACKEND\_ QUICKTIME} } {
2005-02-03 06:11:36 -05:00
Use QuickTime. Windows and Mac Only. WARNING: On Mac Systems lower than OSX 10.2 this defaults to emulating window positioning and suffers from several bugs, including not working correctly embedded in a wxNotebook. }
2004-11-14 18:13:18 -05:00
\twocolitem { { \bf wxMEDIABACKEND\_ MCI} } {
Use Media Command Interface. Windows Only. }
2005-02-11 20:30:39 -05:00
\twocolitem { { \bf wxMEDIABACKEND\_ GSTREAMER} } {
Use GStreamer. Unix Only. }
2004-11-14 18:13:18 -05:00
\end { twocollist}
2004-11-11 00:37:05 -05:00
\membersection { wxMediaCtrl::wxMediaCtrl} \label { wxmediactrlwxmediactrl}
2004-11-11 04:32:49 -05:00
\func { } { wxMediaCtrl} { \void }
2004-11-11 00:37:05 -05:00
2004-11-11 04:32:49 -05:00
Default constructor - you \tt { must} call Create before calling any other methods
of wxMediaCtrl.
2004-11-11 00:37:05 -05:00
2004-11-14 18:13:18 -05:00
\func { } { wxMediaCtrl} {
\param { wxWindow* } { parent} ,
\param { const wxString\& } { fileName = wxT("")} ,
\param { wxWindowID } { id} ,
\param { const wxPoint\& } { pos = wxDefaultPosition} ,
\param { const wxSize\& } { size = wxDefaultSize} ,
\param { long } { style = 0} ,
\param { const wxString\& } { szBackend = wxT("")} ,
\param { const wxValidator& } { validator = wxDefaultValidator} ,
\param { const wxString\& } { name = wxPanelNameStr}
}
2004-11-11 00:37:05 -05:00
2004-11-14 18:13:18 -05:00
Constructor that calls \helpref { Create} { wxmediactrlcreate} . You may prefer to call \helpref { Create} { wxmediactrlcreate} directly to check to see if wxMediaCtrl is available on the system.
2004-11-11 00:37:05 -05:00
\docparam { parent} { parent of this control. Must not be NULL.}
\docparam { id} { id to use for events}
2004-11-14 18:13:18 -05:00
\docparam { fileName} { If not empty, the path of a file to open.}
2004-11-11 00:37:05 -05:00
\docparam { pos} { Position to put control at.}
\docparam { size} { Size to put the control at and to stretch movie to.}
\docparam { style} { Optional styles.}
2004-11-14 18:13:18 -05:00
\docparam { szBackend} { Name of backend you want to use, leave blank to make
wxMediaCtrl figure it out.}
\docparam { validator} { validator to use.}
2004-11-11 00:37:05 -05:00
\docparam { name} { Window name.}
\membersection { wxMediaCtrl::Create} \label { wxmediactrlcreate}
2004-11-14 18:13:18 -05:00
\func { bool} { Create} {
\param { wxWindow* } { parent} ,
\param { const wxString\& } { fileName = wxT("")} ,
\param { wxWindowID } { id} ,
\param { const wxPoint\& } { pos = wxDefaultPosition} ,
\param { const wxSize\& } { size = wxDefaultSize} ,
\param { long } { style = 0} ,
\param { const wxString\& } { szBackend = wxT("")} ,
\param { const wxValidator& } { validator = wxDefaultValidator} ,
\param { const wxString\& } { name = wxPanelNameStr}
}
2004-11-11 00:37:05 -05:00
2004-11-14 18:13:18 -05:00
Creates this control. Returns \tt { false} if it can't load the movie located at \tt { fileName} or it cannot load one of its native backends.
If you specify a file to open via \tt { fileName} and you don't specify a backend to use, wxMediaCtrl tries each of its backends until one that can render the path referred to by \tt { fileName} can be found.
2004-11-11 00:37:05 -05:00
\docparam { parent} { parent of this control. Must not be NULL.}
\docparam { id} { id to use for events}
2004-11-14 18:13:18 -05:00
\docparam { fileName} { If not empty, the path of a file to open.}
2004-11-11 00:37:05 -05:00
\docparam { pos} { Position to put control at.}
\docparam { size} { Size to put the control at and to stretch movie to.}
\docparam { style} { Optional styles.}
2004-11-14 18:13:18 -05:00
\docparam { szBackend} { Name of backend you want to use, leave blank to make
wxMediaCtrl figure it out.}
\docparam { validator} { validator to use.}
2004-11-11 00:37:05 -05:00
\docparam { name} { Window name.}
2004-12-17 11:07:21 -05:00
\membersection { wxMediaCtrl::Length} \label { wxmediactrlgetduration}
2004-11-11 00:37:05 -05:00
2004-12-17 11:07:21 -05:00
\func { wxFileOffset} { GetDuration} { \void }
2004-11-11 00:37:05 -05:00
2004-11-11 04:32:49 -05:00
Obtains the length - the total amount of time the movie has in milliseconds.
2004-11-11 00:37:05 -05:00
2004-12-17 11:07:21 -05:00
\membersection { wxMediaCtrl::Tell} \label { wxmediactrlgetposition}
2004-11-11 00:37:05 -05:00
2004-12-17 11:07:21 -05:00
\func { wxFileOffset} { GetPosition} { \void }
2004-11-11 00:37:05 -05:00
2004-11-11 04:32:49 -05:00
Obtains the current position in time within the movie in milliseconds.
2004-11-11 00:37:05 -05:00
\membersection { wxMediaCtrl::GetState} \label { wxmediactrlgetstate}
\func { wxMediaCtrlState} { GetState} { \void }
Obtains the state the playback of the movie is in -
\twocolwidtha { 7cm}
\begin { twocollist} \itemsep =0pt
\twocolitem { { \bf wxMEDIASTATE\_ STOPPED} } { The movie has stopped.}
\twocolitem { { \bf wxMEDIASTATE\_ PAUSED} } { The movie is paused.}
\twocolitem { { \bf wxMEDIASTATE\_ PLAYING} } { The movie is currently playing.}
\end { twocollist}
\membersection { wxMediaCtrl::Load} \label { wxmediactrlload}
\func { bool} { Load} { \param { const wxString\& } { fileName} }
2004-11-11 04:32:49 -05:00
Loads the file that \tt { fileName} refers to. Returns false if loading fails.
2004-11-11 00:37:05 -05:00
\membersection { wxMediaCtrl::Pause} \label { wxmediactrlpause}
\func { bool} { Pause} { \void }
Pauses playback of the movie.
\membersection { wxMediaCtrl::Play} \label { wxmediactrlplay}
\func { bool} { Play} { \void }
Resumes playback of the movie.
2004-12-17 11:07:21 -05:00
\membersection { wxMediaCtrl::Seek} \label { wxmediactrlsetposition}
2004-11-11 00:37:05 -05:00
2004-12-17 11:07:21 -05:00
\func { wxFileOffset} { SetPosition} { \param { wxFileOffset } { where} , \param { wxSeekMode } { mode} }
2004-11-11 00:37:05 -05:00
Seeks to a position within the movie.
\membersection { wxMediaCtrl::Stop} \label { wxmediactrlstop}
\func { bool} { Stop} { \void }
2004-11-11 04:32:49 -05:00
Stops the media.
2004-11-14 18:13:18 -05:00
See \helpref { Operation} { operationwxmediactrl} for an overview of how stopping works.