properly detect gstreamer and libxml headers and libs, reflect that wxMediaCtrl now...
[wxWidgets.git] / include / wx / mediactrl.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mediactrl.h
3 // Purpose: wxMediaCtrl class
4 // Author: Ryan Norton <wxprojects@comcast.net>
5 // Modified by:
6 // Created: 11/07/04
7 // RCS-ID: $Id$
8 // Copyright: (c) Ryan Norton
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
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"
27 #endif
28
29 // ----------------------------------------------------------------------------
30 // Compilation guard
31 // ----------------------------------------------------------------------------
32 #if wxUSE_MEDIACTRL
33
34 // ----------------------------------------------------------------------------
35 // Includes
36 // ----------------------------------------------------------------------------
37
38 #include "wx/control.h"
39 #include "wx/uri.h"
40
41 // ============================================================================
42 // Declarations
43 // ============================================================================
44
45 // ----------------------------------------------------------------------------
46 //
47 // Enumerations
48 //
49 // ----------------------------------------------------------------------------
50
51 enum wxMediaState
52 {
53 wxMEDIASTATE_STOPPED,
54 wxMEDIASTATE_PAUSED,
55 wxMEDIASTATE_PLAYING
56 };
57
58 #define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
59 #define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
60 #define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
61 #define wxMEDIABACKEND_GSTREAMER wxT("wxGStreamerMediaBackend")
62
63 // ----------------------------------------------------------------------------
64 //
65 // wxMediaEvent
66 //
67 // ----------------------------------------------------------------------------
68
69 class WXDLLIMPEXP_MEDIA wxMediaEvent : public wxNotifyEvent
70 {
71 public:
72 // ------------------------------------------------------------------------
73 // wxMediaEvent Constructor
74 //
75 // Normal constructor, much the same as wxNotifyEvent
76 // ------------------------------------------------------------------------
77 wxMediaEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
78 : wxNotifyEvent(commandType, winid)
79 { }
80
81 // ------------------------------------------------------------------------
82 // wxMediaEvent Copy Constructor
83 //
84 // Normal copy constructor, much the same as wxNotifyEvent
85 // ------------------------------------------------------------------------
86 wxMediaEvent(const wxMediaEvent &clone)
87 : wxNotifyEvent(clone)
88 { }
89
90 // ------------------------------------------------------------------------
91 // wxMediaEvent::Clone
92 //
93 // Allocates a copy of this object.
94 // Required for wxEvtHandler::AddPendingEvent
95 // ------------------------------------------------------------------------
96 virtual wxEvent *Clone() const
97 { return new wxMediaEvent(*this); }
98
99
100 // Put this class on wxWidget's RTTI table
101 DECLARE_DYNAMIC_CLASS(wxMediaEvent)
102 };
103
104 // ----------------------------------------------------------------------------
105 //
106 // wxMediaCtrl
107 //
108 // ----------------------------------------------------------------------------
109
110 class WXDLLIMPEXP_MEDIA wxMediaCtrl : public wxControl
111 {
112 public:
113 wxMediaCtrl() : m_imp(NULL), m_bLoaded(false), m_bLoop(false)
114 { }
115
116 wxMediaCtrl(wxWindow* parent, wxWindowID winid,
117 const wxString& fileName = wxEmptyString,
118 const wxPoint& pos = wxDefaultPosition,
119 const wxSize& size = wxDefaultSize,
120 long style = 0,
121 const wxString& szBackend = wxEmptyString,
122 const wxValidator& validator = wxDefaultValidator,
123 const wxString& name = wxT("mediaCtrl"))
124 : m_imp(NULL), m_bLoaded(false), m_bLoop(false)
125 { Create(parent, winid, fileName, pos, size, style,
126 szBackend, validator, name); }
127
128 wxMediaCtrl(wxWindow* parent, wxWindowID winid,
129 const wxURI& location,
130 const wxPoint& pos = wxDefaultPosition,
131 const wxSize& size = wxDefaultSize,
132 long style = 0,
133 const wxString& szBackend = wxEmptyString,
134 const wxValidator& validator = wxDefaultValidator,
135 const wxString& name = wxT("mediaCtrl"))
136 : m_imp(NULL), m_bLoop(false)
137 { Create(parent, winid, location, pos, size, style,
138 szBackend, validator, name); }
139
140 ~wxMediaCtrl();
141
142 bool Create(wxWindow* parent, wxWindowID winid,
143 const wxString& fileName = wxEmptyString,
144 const wxPoint& pos = wxDefaultPosition,
145 const wxSize& size = wxDefaultSize,
146 long style = 0,
147 const wxString& szBackend = wxEmptyString,
148 const wxValidator& validator = wxDefaultValidator,
149 const wxString& name = wxT("mediaCtrl"));
150
151 bool Create(wxWindow* parent, wxWindowID winid,
152 const wxURI& location,
153 const wxPoint& pos = wxDefaultPosition,
154 const wxSize& size = wxDefaultSize,
155 long style = 0,
156 const wxString& szBackend = wxEmptyString,
157 const wxValidator& validator = wxDefaultValidator,
158 const wxString& name = wxT("mediaCtrl")); //DirectShow only
159
160 bool DoCreate(wxClassInfo* instance,
161 wxWindow* parent, wxWindowID winid,
162 const wxPoint& pos = wxDefaultPosition,
163 const wxSize& size = wxDefaultSize,
164 long style = 0,
165 const wxValidator& validator = wxDefaultValidator,
166 const wxString& name = wxT("mediaCtrl"));
167
168 bool Play();
169 bool Pause();
170 bool Stop();
171
172 bool Load(const wxString& fileName);
173 bool Load(const wxURI& location); //DirectShow only
174
175 void Loop(bool bLoop = true);
176 bool IsLooped();
177
178 wxMediaState GetState();
179
180 double GetPlaybackRate(); //All but MCI
181 bool SetPlaybackRate(double dRate); //All but MCI
182
183 wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart);
184 wxFileOffset Tell(); //FIXME: This should be const
185 wxFileOffset Length(); //FIXME: This should be const
186
187 protected:
188 static wxClassInfo* NextBackend();
189
190 void OnMediaFinished(wxMediaEvent& evt);
191 virtual void DoMoveWindow(int x, int y, int w, int h);
192 wxSize DoGetBestSize() const;
193
194 #ifdef __WXMAC__
195 friend class wxQTMediaBackend;
196 #endif
197 #ifdef __WXCOCOA__
198 friend class wxQTMediaBackend;
199 #endif
200 class wxMediaBackend* m_imp;
201 bool m_bLoaded;
202 bool m_bLoop;
203
204 DECLARE_DYNAMIC_CLASS(wxMediaCtrl)
205 };
206
207 // ----------------------------------------------------------------------------
208 //
209 // wxMediaBackend
210 //
211 // Currently an internal class - API stability not guaranteed.
212 //
213 // ----------------------------------------------------------------------------
214
215 class WXDLLIMPEXP_MEDIA wxMediaBackend : public wxObject
216 {
217 public:
218 wxMediaBackend()
219 { }
220
221 virtual ~wxMediaBackend();
222
223 virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
224 wxWindow* WXUNUSED(parent),
225 wxWindowID WXUNUSED(winid),
226 const wxPoint& WXUNUSED(pos),
227 const wxSize& WXUNUSED(size),
228 long WXUNUSED(style),
229 const wxValidator& WXUNUSED(validator),
230 const wxString& WXUNUSED(name))
231 { return false; }
232
233 virtual bool Play()
234 { return false; }
235 virtual bool Pause()
236 { return false; }
237 virtual bool Stop()
238 { return false; }
239
240 virtual bool Load(const wxString& WXUNUSED(fileName))
241 { return false; }
242 virtual bool Load(const wxURI& WXUNUSED(location))
243 { return false; }
244
245 virtual bool SetPosition(wxLongLong WXUNUSED(where))
246 { return 0; }
247 virtual wxLongLong GetPosition()
248 { return 0; }
249 virtual wxLongLong GetDuration()
250 { return 0; }
251
252 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
253 int WXUNUSED(w), int WXUNUSED(h))
254 { }
255 virtual wxSize GetVideoSize() const
256 { return wxSize(); }
257
258 virtual double GetPlaybackRate()
259 { return 0.0; }
260 virtual bool SetPlaybackRate(double WXUNUSED(dRate))
261 { return false; }
262
263 virtual wxMediaState GetState()
264 { return wxMEDIASTATE_STOPPED; }
265
266 DECLARE_DYNAMIC_CLASS(wxMediaBackend)
267 };
268
269 //Event ID to give to our events
270 #define wxMEDIA_FINISHED_ID 13000
271 #define wxMEDIA_STOP_ID 13001
272
273 //Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
274 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_FINISHED, wxMEDIA_FINISHED_ID)
275 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_STOP, wxMEDIA_STOP_ID)
276
277 //Function type(s) our events need
278 typedef void (wxEvtHandler::*wxMediaEventFunction)(wxMediaEvent&);
279
280 //Macro for usage with message maps
281 #define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
282 #define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
283
284 // ----------------------------------------------------------------------------
285 // End compilation gaurd
286 // ----------------------------------------------------------------------------
287 #endif // wxUSE_MEDIACTRL
288
289 // ----------------------------------------------------------------------------
290 // End header guard and header itself
291 // ----------------------------------------------------------------------------
292 #endif // _WX_MEDIACTRL_H_
293
294