]>
Commit | Line | Data |
---|---|---|
ff4aedc5 | 1 | /////////////////////////////////////////////////////////////////////////////// |
1a680109 RN |
2 | // Name: wx/mediactrl.h |
3 | // Purpose: wxMediaCtrl class | |
4 | // Author: Ryan Norton <wxprojects@comcast.net> | |
226ec5a7 | 5 | // Modified by: |
1a680109 RN |
6 | // Created: 11/07/04 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Ryan Norton | |
9 | // Licence: wxWindows licence | |
ff4aedc5 | 10 | /////////////////////////////////////////////////////////////////////////////// |
1a680109 | 11 | |
ff4aedc5 RN |
12 | // ============================================================================ |
13 | // Definitions | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // Header guard | |
18 | // ---------------------------------------------------------------------------- | |
19 | #ifndef _WX_MEDIACTRL_H_ | |
20 | #define _WX_MEDIACTRL_H_ | |
21 | ||
22 | // ---------------------------------------------------------------------------- | |
23 | // Pre-compiled header stuff | |
24 | // ---------------------------------------------------------------------------- | |
25 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
26 | #pragma interface "mediactrl.h" | |
72259e00 RL |
27 | #endif |
28 | ||
2ecf902b WS |
29 | #include "wx/defs.h" |
30 | ||
ff4aedc5 RN |
31 | // ---------------------------------------------------------------------------- |
32 | // Compilation guard | |
33 | // ---------------------------------------------------------------------------- | |
2ecf902b | 34 | |
ff4aedc5 RN |
35 | #if wxUSE_MEDIACTRL |
36 | ||
37 | // ---------------------------------------------------------------------------- | |
38 | // Includes | |
39 | // ---------------------------------------------------------------------------- | |
40 | ||
41 | #include "wx/control.h" | |
42 | #include "wx/uri.h" | |
43 | ||
44 | // ============================================================================ | |
45 | // Declarations | |
46 | // ============================================================================ | |
47 | ||
48 | // ---------------------------------------------------------------------------- | |
49 | // | |
50 | // Enumerations | |
51 | // | |
52 | // ---------------------------------------------------------------------------- | |
53 | ||
54 | enum wxMediaState | |
55 | { | |
56 | wxMEDIASTATE_STOPPED, | |
57 | wxMEDIASTATE_PAUSED, | |
58 | wxMEDIASTATE_PLAYING | |
59 | }; | |
60 | ||
c5191fbd VZ |
61 | enum wxMediaCtrlPlayerControls |
62 | { | |
63 | wxMEDIACTRLPLAYERCONTROLS_NONE = 0, | |
64 | //Step controls like fastfoward, step one frame etc. | |
65 | wxMEDIACTRLPLAYERCONTROLS_STEP = 1 << 0, | |
66 | //Volume controls like the speaker icon, volume slider, etc. | |
67 | wxMEDIACTRLPLAYERCONTROLS_VOLUME = 1 << 1, | |
68 | wxMEDIACTRLPLAYERCONTROLS_DEFAULT = | |
69 | wxMEDIACTRLPLAYERCONTROLS_STEP | | |
70 | wxMEDIACTRLPLAYERCONTROLS_VOLUME | |
71 | }; | |
72 | ||
ff4aedc5 RN |
73 | #define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend") |
74 | #define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend") | |
75 | #define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend") | |
ce756cb0 | 76 | #define wxMEDIABACKEND_GSTREAMER wxT("wxGStreamerMediaBackend") |
ff4aedc5 | 77 | |
c5191fbd | 78 | |
226ec5a7 WS |
79 | // ---------------------------------------------------------------------------- |
80 | // | |
81 | // wxMediaEvent | |
82 | // | |
83 | // ---------------------------------------------------------------------------- | |
84 | ||
ff2b312f | 85 | class WXDLLIMPEXP_MEDIA wxMediaEvent : public wxNotifyEvent |
226ec5a7 WS |
86 | { |
87 | public: | |
88 | // ------------------------------------------------------------------------ | |
89 | // wxMediaEvent Constructor | |
90 | // | |
91 | // Normal constructor, much the same as wxNotifyEvent | |
92 | // ------------------------------------------------------------------------ | |
4fc81cbc RN |
93 | wxMediaEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) |
94 | : wxNotifyEvent(commandType, winid) | |
226ec5a7 WS |
95 | { } |
96 | ||
97 | // ------------------------------------------------------------------------ | |
98 | // wxMediaEvent Copy Constructor | |
99 | // | |
100 | // Normal copy constructor, much the same as wxNotifyEvent | |
101 | // ------------------------------------------------------------------------ | |
102 | wxMediaEvent(const wxMediaEvent &clone) | |
103 | : wxNotifyEvent(clone) | |
104 | { } | |
105 | ||
106 | // ------------------------------------------------------------------------ | |
107 | // wxMediaEvent::Clone | |
108 | // | |
109 | // Allocates a copy of this object. | |
110 | // Required for wxEvtHandler::AddPendingEvent | |
111 | // ------------------------------------------------------------------------ | |
112 | virtual wxEvent *Clone() const | |
113 | { return new wxMediaEvent(*this); } | |
114 | ||
115 | ||
116 | // Put this class on wxWidget's RTTI table | |
117 | DECLARE_DYNAMIC_CLASS(wxMediaEvent) | |
118 | }; | |
119 | ||
ff4aedc5 RN |
120 | // ---------------------------------------------------------------------------- |
121 | // | |
122 | // wxMediaCtrl | |
123 | // | |
124 | // ---------------------------------------------------------------------------- | |
125 | ||
ff2b312f | 126 | class WXDLLIMPEXP_MEDIA wxMediaCtrl : public wxControl |
ff4aedc5 RN |
127 | { |
128 | public: | |
bc036010 | 129 | wxMediaCtrl() : m_imp(NULL), m_bLoaded(false) |
ff4aedc5 RN |
130 | { } |
131 | ||
4fc81cbc | 132 | wxMediaCtrl(wxWindow* parent, wxWindowID winid, |
8b5d5223 | 133 | const wxString& fileName = wxEmptyString, |
226ec5a7 | 134 | const wxPoint& pos = wxDefaultPosition, |
ff4aedc5 | 135 | const wxSize& size = wxDefaultSize, |
226ec5a7 | 136 | long style = 0, |
8b5d5223 | 137 | const wxString& szBackend = wxEmptyString, |
ff4aedc5 RN |
138 | const wxValidator& validator = wxDefaultValidator, |
139 | const wxString& name = wxT("mediaCtrl")) | |
bc036010 | 140 | : m_imp(NULL), m_bLoaded(false) |
4fc81cbc | 141 | { Create(parent, winid, fileName, pos, size, style, |
ff4aedc5 RN |
142 | szBackend, validator, name); } |
143 | ||
4fc81cbc | 144 | wxMediaCtrl(wxWindow* parent, wxWindowID winid, |
ff4aedc5 | 145 | const wxURI& location, |
226ec5a7 | 146 | const wxPoint& pos = wxDefaultPosition, |
ff4aedc5 | 147 | const wxSize& size = wxDefaultSize, |
226ec5a7 | 148 | long style = 0, |
8b5d5223 | 149 | const wxString& szBackend = wxEmptyString, |
ff4aedc5 RN |
150 | const wxValidator& validator = wxDefaultValidator, |
151 | const wxString& name = wxT("mediaCtrl")) | |
bc036010 | 152 | : m_imp(NULL), m_bLoaded(false) |
4fc81cbc | 153 | { Create(parent, winid, location, pos, size, style, |
ff4aedc5 RN |
154 | szBackend, validator, name); } |
155 | ||
156 | ~wxMediaCtrl(); | |
157 | ||
4fc81cbc | 158 | bool Create(wxWindow* parent, wxWindowID winid, |
8b5d5223 | 159 | const wxString& fileName = wxEmptyString, |
226ec5a7 | 160 | const wxPoint& pos = wxDefaultPosition, |
ff4aedc5 | 161 | const wxSize& size = wxDefaultSize, |
226ec5a7 | 162 | long style = 0, |
8b5d5223 | 163 | const wxString& szBackend = wxEmptyString, |
ff4aedc5 RN |
164 | const wxValidator& validator = wxDefaultValidator, |
165 | const wxString& name = wxT("mediaCtrl")); | |
166 | ||
4fc81cbc | 167 | bool Create(wxWindow* parent, wxWindowID winid, |
ff4aedc5 | 168 | const wxURI& location, |
226ec5a7 | 169 | const wxPoint& pos = wxDefaultPosition, |
ff4aedc5 | 170 | const wxSize& size = wxDefaultSize, |
226ec5a7 | 171 | long style = 0, |
8b5d5223 | 172 | const wxString& szBackend = wxEmptyString, |
ff4aedc5 | 173 | const wxValidator& validator = wxDefaultValidator, |
c5191fbd | 174 | const wxString& name = wxT("mediaCtrl")); |
ff4aedc5 RN |
175 | |
176 | bool DoCreate(wxClassInfo* instance, | |
4fc81cbc | 177 | wxWindow* parent, wxWindowID winid, |
226ec5a7 | 178 | const wxPoint& pos = wxDefaultPosition, |
ff4aedc5 | 179 | const wxSize& size = wxDefaultSize, |
226ec5a7 | 180 | long style = 0, |
ff4aedc5 RN |
181 | const wxValidator& validator = wxDefaultValidator, |
182 | const wxString& name = wxT("mediaCtrl")); | |
183 | ||
ff4aedc5 RN |
184 | bool Play(); |
185 | bool Pause(); | |
186 | bool Stop(); | |
187 | ||
188 | bool Load(const wxString& fileName); | |
ff4aedc5 | 189 | |
ff4aedc5 RN |
190 | wxMediaState GetState(); |
191 | ||
9180b535 RN |
192 | wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart); |
193 | wxFileOffset Tell(); //FIXME: This should be const | |
194 | wxFileOffset Length(); //FIXME: This should be const | |
973dc0a8 | 195 | |
c5191fbd | 196 | #if wxABI_VERSION >= 20601 /* 2.6.1+ only */ |
bc036010 RN |
197 | double GetPlaybackRate(); //All but MCI & GStreamer |
198 | bool SetPlaybackRate(double dRate); //All but MCI & GStreamer | |
c5191fbd VZ |
199 | #endif |
200 | ||
201 | #if wxABI_VERSION >= 20602 /* 2.6.2+ only */ | |
202 | bool Load(const wxURI& location); | |
203 | bool Load(const wxURI& location, const wxURI& proxy); | |
204 | ||
205 | wxFileOffset GetDownloadProgress(); | |
206 | wxFileOffset GetDownloadTotal(); | |
bc036010 | 207 | |
c5191fbd VZ |
208 | double GetVolume(); |
209 | bool SetVolume(double dVolume); | |
6f8c67e7 | 210 | |
c5191fbd VZ |
211 | bool ShowPlayerControls( |
212 | wxMediaCtrlPlayerControls flags = wxMEDIACTRLPLAYERCONTROLS_DEFAULT); | |
213 | ||
214 | //helpers for the wxPython people | |
215 | bool LoadURI(const wxString& fileName) | |
216 | { return Load(wxURI(fileName)); } | |
217 | bool LoadURIWithProxy(const wxString& fileName, const wxString& proxy) | |
218 | { return Load(wxURI(fileName), wxURI(proxy)); } | |
219 | #endif | |
ff4aedc5 | 220 | protected: |
973dc0a8 RN |
221 | static wxClassInfo* NextBackend(); |
222 | ||
226ec5a7 | 223 | void OnMediaFinished(wxMediaEvent& evt); |
ff4aedc5 RN |
224 | virtual void DoMoveWindow(int x, int y, int w, int h); |
225 | wxSize DoGetBestSize() const; | |
226 | ||
bc036010 RN |
227 | //FIXME: This is nasty... find a better way to work around |
228 | //inheritance issues | |
c5191fbd | 229 | #if defined(__WXMAC__) || defined(__WXCOCOA__) |
4fc81cbc | 230 | friend class wxQTMediaBackend; |
3b5023b9 | 231 | #endif |
ff4aedc5 RN |
232 | class wxMediaBackend* m_imp; |
233 | bool m_bLoaded; | |
ff4aedc5 | 234 | |
3839f37e | 235 | DECLARE_DYNAMIC_CLASS(wxMediaCtrl) |
ff4aedc5 RN |
236 | }; |
237 | ||
238 | // ---------------------------------------------------------------------------- | |
239 | // | |
240 | // wxMediaBackend | |
241 | // | |
c5191fbd VZ |
242 | // Derive from this and use standard wxWidgets RTTI |
243 | // (DECLARE_DYNAMIC_CLASS and IMPLEMENT_CLASS) to make a backend | |
244 | // for wxMediaCtrl. Backends are searched alphabetically - | |
245 | // the one with the earliest letter is tried first. | |
246 | // | |
247 | // Note that this is currently not API or ABI compatable - | |
248 | // so statically link or make the client compile on-site. | |
ff4aedc5 RN |
249 | // |
250 | // ---------------------------------------------------------------------------- | |
251 | ||
ff2b312f | 252 | class WXDLLIMPEXP_MEDIA wxMediaBackend : public wxObject |
ff4aedc5 RN |
253 | { |
254 | public: | |
255 | wxMediaBackend() | |
256 | { } | |
257 | ||
258 | virtual ~wxMediaBackend(); | |
259 | ||
226ec5a7 WS |
260 | virtual bool CreateControl(wxControl* WXUNUSED(ctrl), |
261 | wxWindow* WXUNUSED(parent), | |
4fc81cbc | 262 | wxWindowID WXUNUSED(winid), |
226ec5a7 | 263 | const wxPoint& WXUNUSED(pos), |
78450975 | 264 | const wxSize& WXUNUSED(size), |
226ec5a7 | 265 | long WXUNUSED(style), |
78450975 RN |
266 | const wxValidator& WXUNUSED(validator), |
267 | const wxString& WXUNUSED(name)) | |
ff4aedc5 RN |
268 | { return false; } |
269 | ||
226ec5a7 | 270 | virtual bool Play() |
ff4aedc5 | 271 | { return false; } |
226ec5a7 | 272 | virtual bool Pause() |
ff4aedc5 | 273 | { return false; } |
226ec5a7 | 274 | virtual bool Stop() |
ff4aedc5 RN |
275 | { return false; } |
276 | ||
226ec5a7 | 277 | virtual bool Load(const wxString& WXUNUSED(fileName)) |
ff4aedc5 | 278 | { return false; } |
226ec5a7 | 279 | virtual bool Load(const wxURI& WXUNUSED(location)) |
ff4aedc5 RN |
280 | { return false; } |
281 | ||
226ec5a7 | 282 | virtual bool SetPosition(wxLongLong WXUNUSED(where)) |
ff4aedc5 | 283 | { return 0; } |
226ec5a7 | 284 | virtual wxLongLong GetPosition() |
ff4aedc5 | 285 | { return 0; } |
226ec5a7 | 286 | virtual wxLongLong GetDuration() |
ff4aedc5 RN |
287 | { return 0; } |
288 | ||
226ec5a7 WS |
289 | virtual void Move(int WXUNUSED(x), int WXUNUSED(y), |
290 | int WXUNUSED(w), int WXUNUSED(h)) | |
ff4aedc5 | 291 | { } |
226ec5a7 | 292 | virtual wxSize GetVideoSize() const |
c47addef | 293 | { return wxSize(0,0); } |
ff4aedc5 | 294 | |
226ec5a7 | 295 | virtual double GetPlaybackRate() |
ff4aedc5 | 296 | { return 0.0; } |
226ec5a7 | 297 | virtual bool SetPlaybackRate(double WXUNUSED(dRate)) |
ff4aedc5 RN |
298 | { return false; } |
299 | ||
300 | virtual wxMediaState GetState() | |
301 | { return wxMEDIASTATE_STOPPED; } | |
302 | ||
6f8c67e7 JS |
303 | virtual double GetVolume() |
304 | { return 0.0; } | |
305 | virtual bool SetVolume(double WXUNUSED(dVolume)) | |
306 | { return false; } | |
307 | ||
c5191fbd VZ |
308 | virtual bool Load(const wxURI& WXUNUSED(location), |
309 | const wxURI& WXUNUSED(proxy)) | |
310 | { return false; } | |
311 | ||
312 | virtual bool ShowPlayerControls( | |
313 | wxMediaCtrlPlayerControls WXUNUSED(flags)) | |
314 | { return false; } | |
315 | virtual bool IsInterfaceShown() | |
316 | { return false; } | |
317 | ||
318 | virtual wxLongLong GetDownloadProgress() | |
319 | { return 0; } | |
320 | virtual wxLongLong GetDownloadTotal() | |
321 | { return 0; } | |
322 | ||
07323ed6 RN |
323 | virtual void RESERVED8() {} |
324 | virtual void RESERVED9() {} | |
325 | ||
3839f37e | 326 | DECLARE_DYNAMIC_CLASS(wxMediaBackend) |
ff4aedc5 RN |
327 | }; |
328 | ||
ff4aedc5 RN |
329 | //Event ID to give to our events |
330 | #define wxMEDIA_FINISHED_ID 13000 | |
331 | #define wxMEDIA_STOP_ID 13001 | |
332 | ||
333 | //Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later | |
c220a8ec RD |
334 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_FINISHED, wxMEDIA_FINISHED_ID) |
335 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_STOP, wxMEDIA_STOP_ID) | |
ff4aedc5 RN |
336 | |
337 | //Function type(s) our events need | |
338 | typedef void (wxEvtHandler::*wxMediaEventFunction)(wxMediaEvent&); | |
339 | ||
4153a503 RN |
340 | #define wxMediaEventHandler(func) \ |
341 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMediaEventFunction, &func) | |
342 | ||
ff4aedc5 | 343 | //Macro for usage with message maps |
4153a503 RN |
344 | #define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ), |
345 | #define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ), | |
ff4aedc5 | 346 | |
c5191fbd VZ |
347 | #if wxABI_VERSION >= 20602 /* 2.6.2+ only */ |
348 | # define wxMEDIA_LOADED_ID 13002 | |
349 | DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_LOADED, wxMEDIA_LOADED_ID) | |
350 | # define EVT_MEDIA_LOADED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_LOADED, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ), | |
351 | #endif | |
352 | ||
ff4aedc5 RN |
353 | // ---------------------------------------------------------------------------- |
354 | // End compilation gaurd | |
355 | // ---------------------------------------------------------------------------- | |
356 | #endif // wxUSE_MEDIACTRL | |
357 | ||
358 | // ---------------------------------------------------------------------------- | |
359 | // End header guard and header itself | |
360 | // ---------------------------------------------------------------------------- | |
361 | #endif // _WX_MEDIACTRL_H_ | |
362 | ||
363 |