]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/mediactrl.h
Further corrections to wxFileName docs
[wxWidgets.git] / interface / wx / mediactrl.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: mediactrl.h
e54c96f1 3// Purpose: interface of wxMediaEvent
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxMediaEvent
7c913512 11
23324ae1 12 Event wxMediaCtrl uses.
7c913512 13
23324ae1
FM
14 @library{wxmedia}
15 @category{FIXME}
16*/
17class wxMediaEvent : public wxNotifyEvent
18{
19public:
7c913512 20
23324ae1
FM
21};
22
23
e54c96f1 24
23324ae1
FM
25/**
26 @class wxMediaCtrl
7c913512
FM
27
28 wxMediaCtrl is a class for displaying types of
23324ae1 29 media, such as videos, audio files, natively through native codecs.
7c913512 30
23324ae1 31 wxMediaCtrl uses native backends to render media, for example on Windows
7c913512 32 there is a ActiveMovie/DirectShow backend, and on Macintosh there is a
23324ae1 33 QuickTime backend.
7c913512 34
23324ae1
FM
35 @library{wxmedia}
36 @category{media}
7c913512 37
e54c96f1 38 @see wxMediaEvent
23324ae1
FM
39*/
40class wxMediaCtrl : public wxControl
41{
42public:
43 //@{
44 /**
45 ,
328f5751 46 wxPoint&
3c4f71cc 47
7c913512
FM
48 @param pos = wxDefaultPosition,
49 const wxSize& size = wxDefaultSize,
50 long style = 0,
23324ae1
FM
51 const wxString& szBackend = wxT(""),
52 const wxValidatorvalidator = wxDefaultValidator,
53 const wxString& name = wxPanelNameStr
54 )
3c4f71cc 55
23324ae1
FM
56 Constructor that calls Create. You may prefer to call Create directly to check
57 to see if wxMediaCtrl is available on the system.
3c4f71cc 58
7c913512 59 parent
4cc4bfaf 60 parent of this control. Must not be @NULL.
7c913512 61 @param id
4cc4bfaf 62 id to use for events
7c913512 63 @param fileName
4cc4bfaf 64 If not empty, the path of a file to open.
7c913512 65 @param pos
4cc4bfaf 66 Position to put control at.
7c913512 67 @param size
4cc4bfaf 68 Size to put the control at and to stretch movie to.
7c913512 69 @param style
4cc4bfaf 70 Optional styles.
7c913512 71 @param szBackend
4cc4bfaf
FM
72 Name of backend you want to use, leave blank to make
73 wxMediaCtrl figure it out.
7c913512 74 @param validator
4cc4bfaf 75 validator to use.
7c913512 76 @param name
4cc4bfaf 77 Window name.
23324ae1 78 */
328f5751
FM
79 wxMediaCtrl() const;
80 wxMediaCtrl(wxWindow* parent, wxWindowID id) const;
23324ae1
FM
81 //@}
82
83 /**
84 Generally, you should almost certainly leave this part up to
85 wxMediaCtrl - but if you need a certain backend for a particular
7c913512 86 reason, such as QuickTime for playing .mov files, all you need
23324ae1 87 to do to choose a specific backend is to pass the
7c913512 88 name of the backend class to
23324ae1 89 Create().
23324ae1 90 The following are valid backend identifiers -
3c4f71cc 91
23324ae1 92 @b wxMEDIABACKEND_DIRECTSHOW
3c4f71cc
VS
93
94
23324ae1
FM
95 Use ActiveMovie/DirectShow. Uses the native ActiveMovie
96 (I.E. DirectShow) control. Default backend on Windows and
97 supported by nearly all Windows versions, even some
98 Windows CE versions. May display a windows media player
7c913512 99 logo while inactive.
3c4f71cc 100
23324ae1 101 @b wxMEDIABACKEND_QUICKTIME
3c4f71cc 102
23324ae1
FM
103 Use QuickTime. Mac Only.
104 WARNING: May not working correctly embedded in a wxNotebook.
3c4f71cc 105
23324ae1 106 @b wxMEDIABACKEND_GSTREAMER
3c4f71cc 107
23324ae1
FM
108 Use GStreamer. Unix Only. Requires GStreamer 0.8 along
109 with at the very least the xvimagesink, xoverlay, and
110 gst-play modules of gstreamer to function. You need the correct
111 modules to play the relavant files, for example the mad module
112 to play mp3s, etc.
3c4f71cc 113
23324ae1 114 @b wxMEDIABACKEND_WMP10
3c4f71cc 115
23324ae1
FM
116 Uses Windows Media Player 10 (Windows only) - works on mobile
117 machines with Windows Media Player 10 and desktop machines with
118 either Windows Media Player 9 or 10
3c4f71cc 119
23324ae1
FM
120 Note that other backends such as wxMEDIABACKEND_MCI can now be
121 found at wxCode.
122 */
123
124
125 /**
126 ,
328f5751 127 wxPoint&
3c4f71cc 128
7c913512
FM
129 @param pos = wxDefaultPosition,
130 const wxSize& size = wxDefaultSize,
131 long style = 0,
23324ae1
FM
132 const wxString& szBackend = wxT(""),
133 const wxValidatorvalidator = wxDefaultValidator,
134 const wxString& name = wxPanelNameStr
135 )
3c4f71cc 136
23324ae1
FM
137 Creates this control. Returns @false if it can't load the movie located at
138 fileName or it cannot load one of its native backends.
3c4f71cc 139
23324ae1
FM
140 If you specify a file to open via fileName and you don't specify a backend to
141 use, wxMediaCtrl tries each of its backends until one that can render the path referred to by fileName can be found.
3c4f71cc 142
7c913512 143 parent
4cc4bfaf 144 parent of this control. Must not be @NULL.
7c913512 145 @param id
4cc4bfaf 146 id to use for events
7c913512 147 @param fileName
4cc4bfaf 148 If not empty, the path of a file to open.
7c913512 149 @param pos
4cc4bfaf 150 Position to put control at.
7c913512 151 @param size
4cc4bfaf 152 Size to put the control at and to stretch movie to.
7c913512 153 @param style
4cc4bfaf 154 Optional styles.
7c913512 155 @param szBackend
4cc4bfaf
FM
156 Name of backend you want to use, leave blank to make
157 wxMediaCtrl figure it out.
7c913512 158 @param validator
4cc4bfaf 159 validator to use.
7c913512 160 @param name
4cc4bfaf 161 Window name.
23324ae1 162 */
328f5751 163 bool Create(wxWindow* parent, wxWindowID id) const;
23324ae1
FM
164
165 /**
166 Creating a backend for wxMediaCtrl is a rather simple process. Simply derive
167 from wxMediaBackendCommonBase and implement the methods you want. The methods
168 in wxMediaBackend correspond to those in wxMediaCtrl except for CreateControl
169 which does the actual creation of the control, in cases where a custom control
170 is not needed you may simply call wxControl::Create.
23324ae1 171 You need to make sure to use the DECLARE_CLASS and IMPLEMENT_CLASS macros.
23324ae1
FM
172 The only real tricky part is that you need to make sure the file in compiled
173 in, which if there are just backends in there will not happen and you may need
174 to use a force link hack (see http://www.wxwidgets.org/wiki/index.php/RTTI).
23324ae1
FM
175 This is a rather simple example of how to create a backend in the
176 wxActiveXContainer documentation.
177 */
178
179
180 /**
181 Obtains the best size relative to the original/natural size of the
182 video, if there is any. See @ref overview_videosizewxmediactrl "Video size"
183 for more information.
184 */
185 wxSize GetBestSize();
186
187 /**
188 Obtains the playback rate, or speed of the media. @c 1.0 represents normal
189 speed, while @c 2.0 represents twice the normal speed of the media, for
190 example. Not supported on the GStreamer (Unix) backend.
191 Returns 0 on failure.
192 */
193 double GetPlaybackrate();
194
195 /**
196 Obtains the state the playback of the media is in -
3c4f71cc 197
23324ae1 198 @b wxMEDIASTATE_STOPPED
3c4f71cc 199
23324ae1 200 The movie has stopped.
3c4f71cc 201
23324ae1 202 @b wxMEDIASTATE_PAUSED
3c4f71cc 203
23324ae1 204 The movie is paused.
3c4f71cc 205
23324ae1 206 @b wxMEDIASTATE_PLAYING
3c4f71cc 207
23324ae1
FM
208 The movie is currently playing.
209 */
210 wxMediaCtrlState GetState();
211
212 /**
213 Gets the volume of the media from a 0.0 to 1.0 range. Note that due to rounding
214 and other errors this may not be the exact value sent to SetVolume.
215 */
216 double GetVolume();
217
218 /**
219 Obtains the length - the total amount of time the movie has in milliseconds.
220 */
221 wxFileOffset Length();
222
223 /**
224 Loads the location that @c uri refers to with the proxy @c proxy. Not
225 implemented on most backends so it should be called with caution. Returns @false if loading fails.
226 */
227 bool Load(const wxURI& uri, const wxURI& proxy);
228
229 /**
230 Same as @ref loaduri() Load. Kept for wxPython compatability.
231 */
232 bool LoadURI(const wxURI& uri);
233
234 /**
235 Same as @ref loaduriwithproxy() Load. Kept for wxPython compatability.
236 */
237 bool LoadURIWithProxy(const wxURI& uri, const wxURI& proxy);
238
239 /**
240 When wxMediaCtrl plays a file, it plays until the stop position
241 is reached (currently the end of the file/stream). Right before
242 it hits the end of the stream, it fires off a EVT_MEDIA_STOP
243 event to its parent window, at which point the event handler
244 can choose to veto the event, preventing the stream from actually
245 stopping.
23324ae1 246 Example:
3c4f71cc 247
23324ae1 248 When wxMediaCtrl stops, either by the EVT_MEDIA_STOP not being
7c913512 249 vetoed, or by manually calling
23324ae1
FM
250 Stop(), where it actually
251 stops is not at the beginning, rather, but at the beginning of
252 the stream. That is, when it stops and play is called, playback
7c913512 253 is gauranteed to start at the beginning of the media. This is
23324ae1
FM
254 because some streams are not seekable, and when stop is called
255 on them they return to the beginning, thus wxMediaCtrl tries
256 to keep consistant for all types of media.
23324ae1
FM
257 Note that when changing the state of the media through Play()
258 and other methods, the media may not actually be in the
259 wxMEDIASTATE_PLAYING, for example. If you are relying on the
260 media being in certain state catch the event relevant to the state.
261 See wxMediaEvent for the kinds of events
262 that you can catch.
263 */
264
265
266 /**
267 Pauses playback of the movie.
268 */
269 bool Pause();
270
271 /**
272 Resumes playback of the movie.
273 */
274 bool Play();
275
276 /**
277 Normally, when you use wxMediaCtrl it is just a window for the video to
278 play in. However, some toolkits have their own media player interface.
279 For example, QuickTime generally has a bar below the video with a slider.
280 A special feature available to wxMediaCtrl, you can use the toolkit's interface
281 instead of
282 making your own by using the ShowPlayerControls()
283 function. There are several options for the flags parameter, with
284 the two general flags being wxMEDIACTRLPLAYERCONTROLS_NONE which turns off
285 the native interface, and wxMEDIACTRLPLAYERCONTROLS_DEFAULT which lets
286 wxMediaCtrl decide what native controls on the interface. Be sure to review
287 the caveats outlined in @ref overview_videosizewxmediactrl "Video size" before
288 doing so.
289 */
290
291
292 /**
293 Depending upon the backend, wxMediaCtrl can render
7c913512 294 and display pretty much any kind of media that the native system can -
23324ae1
FM
295 such as an image, mpeg video, or mp3 (without license restrictions -
296 since it relies on native system calls that may not technically
297 have mp3 decoding available, for example, it falls outside the
298 realm of licensing restrictions).
7c913512 299 For general operation, all you need to do is call
23324ae1
FM
300 Load() to load the file
301 you want to render, catch the EVT_MEDIA_LOADED event,
7c913512 302 and then call Play()
23324ae1 303 to show the video/audio of the media in that event.
23324ae1
FM
304 More complex operations are generally more heavily dependant on the
305 capabilities of the backend. For example, QuickTime cannot set
7c913512 306 the playback rate of certain streaming media - while DirectShow is
23324ae1
FM
307 slightly more flexible in that regard.
308 */
309
310
311 /**
312 Seeks to a position within the movie.
313 */
314 wxFileOffset Seek(wxFileOffset where, wxSeekMode mode);
315
316 /**
317 Sets the playback rate, or speed of the media, to that referred by @c dRate.
318 @c 1.0 represents normal speed, while @c 2.0 represents twice the normal
319 speed of the media, for example. Not supported on the GStreamer (Unix) backend.
320 Returns @true if successful.
321 */
322 bool SetPlaybackRate(double dRate);
323
324 /**
325 Sets the volume of the media from a 0.0 to 1.0 range to that referred
326 by @c dVolume. @c 1.0 represents full volume, while @c 0.5
327 represents half (50 percent) volume, for example. Note that this may not be
328 exact due to conversion and rounding errors, although setting the volume to
329 full or none is always exact. Returns @true if successful.
330 */
331 bool SetVolume(double dVolume);
332
333 /**
334 A special feature to wxMediaCtrl. Applications using native toolkits such as
335 QuickTime usually have a scrollbar, play button, and more provided to
336 them by the toolkit. By default wxMediaCtrl does not do this. However, on
337 the directshow and quicktime backends you can show or hide the native controls
338 provided by the underlying toolkit at will using ShowPlayerControls. Simply
339 calling the function with default parameters tells wxMediaCtrl to use the
340 default controls provided by the toolkit. The function takes a
341 @c wxMediaCtrlPlayerControls enumeration as follows:
3c4f71cc 342
23324ae1 343 @b wxMEDIACTRLPLAYERCONTROLS_NONE
3c4f71cc 344
23324ae1 345 No controls. return wxMediaCtrl to it's default state.
3c4f71cc 346
23324ae1 347 @b wxMEDIACTRLPLAYERCONTROLS_STEP
3c4f71cc 348
23324ae1 349 Step controls like fastfoward, step one frame etc.
3c4f71cc 350
23324ae1 351 @b wxMEDIACTRLPLAYERCONTROLS_VOLUME
3c4f71cc 352
23324ae1 353 Volume controls like the speaker icon, volume slider, etc.
3c4f71cc 354
23324ae1 355 @b wxMEDIACTRLPLAYERCONTROLS_DEFAULT
3c4f71cc 356
23324ae1
FM
357 Default controls for the toolkit. Currently a typedef for
358 wxMEDIACTRLPLAYERCONTROLS_STEP and wxMEDIACTRLPLAYERCONTROLS_VOLUME.
3c4f71cc 359
23324ae1
FM
360 For more see @ref overview_playercontrolswxmediactrl "Player controls".
361 Currently
362 only implemented on the QuickTime and DirectShow backends. The function
363 returns @true on success.
364 */
365 bool ShowPlayerControls(wxMediaCtrlPlayerControls flags = wxMEDIACTRLPLAYERCONTROLS_DEFAULT);
366
367 /**
368 Stops the media.
e54c96f1 369 See Operation() for an overview of how
23324ae1
FM
370 stopping works.
371 */
372 bool Stop();
373
374 /**
375 Obtains the current position in time within the movie in milliseconds.
376 */
377 wxFileOffset Tell();
378
379 /**
380 By default, wxMediaCtrl will scale the size of the video to the
381 requested amount passed to either it's constructor or Create().
382 After calling Load or performing an equivilant operation, you
383 can subsequently obtain the "real" size of the video (if there
384 is any) by calling GetBestSize(). Note that the actual result
385 on the display will be slightly different when ShowPlayerControls
386 is activated and the actual video size will be less then
387 specified due to the extra controls provided by the native toolkit.
388 In addition, the backend may modify GetBestSize() to include the
389 size of the extra controls - so if you want the real size of the
390 video just disable ShowPlayerControls().
23324ae1
FM
391 The idea with setting GetBestSize to the size of the video is
392 that GetBestSize is a wxWindow-derived function that is called
393 when sizers on a window recalculate. What this means is that
394 if you use sizers by default the video will show in it's
395 original size without any extra assistance needed from the user.
396 */
397};
e54c96f1 398