1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxMediaCtrl docs
4 %% Author: Ryan Norton <wxprojects@comcast.net>
8 %% Copyright: (c) Ryan Norton
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxMediaCtrl
}}\label{wxmediactrl
}
14 wxMediaCtrl is a class that allows a way to convieniently display types of
15 media, such as videos, audio files, natively through native codecs.
17 wxMediaCtrl uses native backends to render media, for example on Windows
18 there is a ActiveMovie/DirectShow backend, and on Macintosh there is a
21 \wxheading{Derived from
}
23 \helpref{wxControl
}{wxcontrol
}
25 \wxheading{Include files
}
29 \latexignore{\rtfignore{\wxheading{Members
}}}
31 \membersection{Rendering media
}\label{renderingmediawxmediactrl
}
33 Depending upon the backend, wxMediaCtrl can render
34 and display pretty much any kind of media that the native system can -
35 such as an image, mpeg video, or mp3 (without license restrictions -
36 since it relies on native system calls that may not technically
37 have mp3 decoding available, for example, it falls outside the
38 realm of licensing restrictions).
40 For general operation, all you need to do is call
41 \helpref{wxMediaCtrl::Load
}{wxmediactrlload
} to load the file
42 you want to render, catch the EVT
\_MEDIA\_LOADED event,
43 and then call
\helpref{wxMediaCtrl::Play
}{wxmediactrlplay
}
44 to show the video/audio of the media in that event.
46 More complex operations are generally more heavily dependant on the
47 capabilities of the backend. For example, QuickTime cannot set
48 the playback rate of certain streaming media - while DirectShow is
49 slightly more flexible in that regard.
51 \membersection{Operation
}\label{operationwxmediactrl
}
53 When wxMediaCtrl plays a file, it plays until the stop position
54 is reached (currently the end of the file/stream). Right before
55 it hits the end of the stream, it fires off a EVT
\_MEDIA\_STOP
56 event to its parent window, at which point the event handler
57 can choose to veto the event, preventing the stream from actually
62 //connect to the media event
63 this->Connect(wxMY_ID, wxEVT_MEDIA_STOP, (wxObjectEventFunction)
64 (wxEventFunction)(wxMediaEventFunction) &MyFrame::OnMediaStop);
67 void MyFrame::OnMediaStop(const wxMediaEvent& evt)
71 m_mediactrl->SetPosition(
72 m_mediactrl->GetDuration() <<
1
79 When wxMediaCtrl stops, either by the EVT
\_MEDIA\_STOP not being
80 vetoed, or by manually calling
81 \helpref{wxMediaCtrl::Stop
}{wxmediactrlstop
}, where it actually
82 stops is not at the beginning, rather, but at the beginning of
83 the stream. That is, when it stops and play is called, playback
84 is gauranteed to start at the beginning of the media. This is
85 because some streams are not seekable, and when stop is called
86 on them they return to the beginning, thus wxMediaCtrl tries
87 to keep consistant for all types of media.
89 \membersection{Choosing a backend
}\label{choosingbackendwxmediactrl
}
91 Generally, you should almost certainly leave this part up to
92 wxMediaCtrl - but if you need a certain backend for a particular
93 reason, such as QuickTime for playing .mov files, all you need
94 to do to choose a specific backend is to pass the
95 name of the backend class to
96 \helpref{wxMediaCtrl::Create
}{wxmediactrlcreate
}.
98 The following are valid backend identifiers -
100 \begin{twocollist
}\itemsep=
0pt
101 \twocolitem{{\bf wxMEDIABACKEND
\_DIRECTSHOW}}{
102 Use ActiveMovie/DirectShow. Requires wxUSE
\_DIRECTSHOW to be
103 enabled, requires linkage with the static library strmiids.lib,
104 and is available on Windows Only.
}
105 \twocolitem{{\bf wxMEDIABACKEND
\_QUICKTIME}}{
106 Use QuickTime. Windows and Mac Only. NOTE: 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.
}
107 \twocolitem{{\bf wxMEDIABACKEND
\_MCI}}{
108 Use Media Command Interface. Windows Only.
}
109 \twocolitem{{\bf wxMEDIABACKEND
\_GSTREAMER}}{
110 Use GStreamer. Unix Only.
}
113 \membersection{wxMediaCtrl::wxMediaCtrl
}\label{wxmediactrlwxmediactrl
}
115 \func{}{wxMediaCtrl
}{\void}
117 Default constructor - you
\tt{must
} call Create before calling any other methods
120 \func{}{wxMediaCtrl
}{
121 \param{wxWindow*
}{parent
},
122 \param{const wxString\&
}{fileName = wxT("")
},
123 \param{wxWindowID
}{id
},
124 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
125 \param{const wxSize\&
}{size = wxDefaultSize
},
126 \param{long
}{style =
0},
127 \param{const wxString\&
}{szBackend = wxT("")
},
128 \param{const wxValidator&
}{validator = wxDefaultValidator
},
129 \param{const wxString\&
}{name = wxPanelNameStr
}
132 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.
134 \docparam{parent
}{parent of this control. Must not be NULL.
}
135 \docparam{id
}{id to use for events
}
136 \docparam{fileName
}{If not empty, the path of a file to open.
}
137 \docparam{pos
}{Position to put control at.
}
138 \docparam{size
}{Size to put the control at and to stretch movie to.
}
139 \docparam{style
}{Optional styles.
}
140 \docparam{szBackend
}{Name of backend you want to use, leave blank to make
141 wxMediaCtrl figure it out.
}
142 \docparam{validator
}{validator to use.
}
143 \docparam{name
}{Window name.
}
146 \membersection{wxMediaCtrl::Create
}\label{wxmediactrlcreate
}
149 \param{wxWindow*
}{parent
},
150 \param{const wxString\&
}{fileName = wxT("")
},
151 \param{wxWindowID
}{id
},
152 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
153 \param{const wxSize\&
}{size = wxDefaultSize
},
154 \param{long
}{style =
0},
155 \param{const wxString\&
}{szBackend = wxT("")
},
156 \param{const wxValidator&
}{validator = wxDefaultValidator
},
157 \param{const wxString\&
}{name = wxPanelNameStr
}
160 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.
162 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.
164 \docparam{parent
}{parent of this control. Must not be NULL.
}
165 \docparam{id
}{id to use for events
}
166 \docparam{fileName
}{If not empty, the path of a file to open.
}
167 \docparam{pos
}{Position to put control at.
}
168 \docparam{size
}{Size to put the control at and to stretch movie to.
}
169 \docparam{style
}{Optional styles.
}
170 \docparam{szBackend
}{Name of backend you want to use, leave blank to make
171 wxMediaCtrl figure it out.
}
172 \docparam{validator
}{validator to use.
}
173 \docparam{name
}{Window name.
}
176 \membersection{wxMediaCtrl::Length
}\label{wxmediactrlgetduration
}
178 \func{wxFileOffset
}{GetDuration
}{\void}
180 Obtains the length - the total amount of time the movie has in milliseconds.
183 \membersection{wxMediaCtrl::Tell
}\label{wxmediactrlgetposition
}
185 \func{wxFileOffset
}{GetPosition
}{\void}
187 Obtains the current position in time within the movie in milliseconds.
190 \membersection{wxMediaCtrl::GetState
}\label{wxmediactrlgetstate
}
192 \func{wxMediaCtrlState
}{GetState
}{\void}
194 Obtains the state the playback of the movie is in -
197 \begin{twocollist
}\itemsep=
0pt
198 \twocolitem{{\bf wxMEDIASTATE
\_STOPPED}}{The movie has stopped.
}
199 \twocolitem{{\bf wxMEDIASTATE
\_PAUSED}}{The movie is paused.
}
200 \twocolitem{{\bf wxMEDIASTATE
\_PLAYING}}{The movie is currently playing.
}
204 \membersection{wxMediaCtrl::Load
}\label{wxmediactrlload
}
206 \func{bool
}{Load
}{\param{const wxString\&
}{fileName
}}
208 Loads the file that
\tt{fileName
} refers to. Returns false if loading fails.
211 \membersection{wxMediaCtrl::Load
}\label{wxmediactrlloaduri
}
213 \func{bool
}{Load
}{\param{const wxURI\&
}{location
}}
215 Loads the url that
\tt{location
} refers to. Returns false if loading fails.
217 \membersection{wxMediaCtrl::Pause
}\label{wxmediactrlpause
}
219 \func{bool
}{Pause
}{\void}
221 Pauses playback of the movie.
224 \membersection{wxMediaCtrl::Play
}\label{wxmediactrlplay
}
226 \func{bool
}{Play
}{\void}
228 Resumes playback of the movie.
231 \membersection{wxMediaCtrl::Seek
}\label{wxmediactrlsetposition
}
233 \func{wxFileOffset
}{Seek
}{\param{wxFileOffset
}{where
},
\param{wxSeekMode
}{mode
}}
235 Seeks to a position within the movie.
238 \membersection{wxMediaCtrl::Stop
}\label{wxmediactrlstop
}
240 \func{bool
}{Stop
}{\void}
244 See
\helpref{Operation
}{operationwxmediactrl
} for an overview of how stopping works.
247 \membersection{wxMediaCtrl::SetVolume
}\label{wxmediactrlsetvolume
}
249 \func{bool
}{SetVolume
}{\param{double
}{dVolume
}}
251 Sets the volume of the media from a
0.0 to
1.0 range.
254 \membersection{wxMediaCtrl::GetVolume
}\label{wxmediactrlgetvolume
}
256 \func{double
}{GetVolume
}{\void}
258 Gets the volume of the media from a
0.0 to
1.0 range.
261 \membersection{wxMediaCtrl::GetPlaybackRate
}\label{wxmediactrlgetplaybackrate
}
263 \func{double
}{GetPlaybackrate
}{\void}
265 Gets the playback rate of the media; for example
2.0 is double speed.
266 Not implemented on MCI or GStreamer.
269 \membersection{wxMediaCtrl::SetPlaybackRate
}\label{wxmediactrlsetplaybackrate
}
271 \func{bool
}{SetPlaybackrate
}{\param{double
}{dVolume
}}
273 Sets the rate that the media plays; for example
0.5 is half speed.
276 \membersection{wxMediaCtrl::ShowPlayerControls
}\label{wxmediactrlshowplayercontrols
}
278 \func{bool
}{ShowPlayerControls
}{\param{wxMediaCtrlPlayerControls
}{flags
}}
280 Normally, when you use wxMediaCtrl it is just a window for the video to
281 play in. However, platforms generally have their own media player interface,
282 like quicktime has a bar below the video with a slider etc.. If you want that native
283 interface instead of making your own use this function. There are several options
284 for the flags parameter, however you can look at the mediactrl header for these.
285 The two general flags are wxMEDIACTRLPLAYERCONTROLS
\_NONE which turns off the
286 native interface, and wxMEDIACTRLPLAYERCONTROLS
\_DEFAULT which lets wxMediaCtrl
287 decide what native controls on the interface.