1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mediactrl.h
3 // Purpose: wxMediaCtrl class
4 // Author: Ryan Norton <wxprojects@comcast.net>
8 // Copyright: (c) Ryan Norton
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
19 #ifndef _WX_MEDIACTRL_H_
20 #define _WX_MEDIACTRL_H_
22 // ----------------------------------------------------------------------------
23 // Pre-compiled header stuff
24 // ----------------------------------------------------------------------------
25 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
26 #pragma interface "mediactrl.h"
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 // ----------------------------------------------------------------------------
41 #include "wx/control.h"
44 // ============================================================================
46 // ============================================================================
48 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
61 #define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
62 #define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
63 #define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
64 #define wxMEDIABACKEND_GSTREAMER wxT("wxGStreamerMediaBackend")
66 // ----------------------------------------------------------------------------
70 // ----------------------------------------------------------------------------
72 class WXDLLIMPEXP_MEDIA wxMediaEvent
: public wxNotifyEvent
75 // ------------------------------------------------------------------------
76 // wxMediaEvent Constructor
78 // Normal constructor, much the same as wxNotifyEvent
79 // ------------------------------------------------------------------------
80 wxMediaEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
81 : wxNotifyEvent(commandType
, winid
)
84 // ------------------------------------------------------------------------
85 // wxMediaEvent Copy Constructor
87 // Normal copy constructor, much the same as wxNotifyEvent
88 // ------------------------------------------------------------------------
89 wxMediaEvent(const wxMediaEvent
&clone
)
90 : wxNotifyEvent(clone
)
93 // ------------------------------------------------------------------------
94 // wxMediaEvent::Clone
96 // Allocates a copy of this object.
97 // Required for wxEvtHandler::AddPendingEvent
98 // ------------------------------------------------------------------------
99 virtual wxEvent
*Clone() const
100 { return new wxMediaEvent(*this); }
103 // Put this class on wxWidget's RTTI table
104 DECLARE_DYNAMIC_CLASS(wxMediaEvent
)
107 // ----------------------------------------------------------------------------
111 // ----------------------------------------------------------------------------
113 class WXDLLIMPEXP_MEDIA wxMediaCtrl
: public wxControl
116 wxMediaCtrl() : m_imp(NULL
), m_bLoaded(false)
119 wxMediaCtrl(wxWindow
* parent
, wxWindowID winid
,
120 const wxString
& fileName
= wxEmptyString
,
121 const wxPoint
& pos
= wxDefaultPosition
,
122 const wxSize
& size
= wxDefaultSize
,
124 const wxString
& szBackend
= wxEmptyString
,
125 const wxValidator
& validator
= wxDefaultValidator
,
126 const wxString
& name
= wxT("mediaCtrl"))
127 : m_imp(NULL
), m_bLoaded(false)
128 { Create(parent
, winid
, fileName
, pos
, size
, style
,
129 szBackend
, validator
, name
); }
131 wxMediaCtrl(wxWindow
* parent
, wxWindowID winid
,
132 const wxURI
& location
,
133 const wxPoint
& pos
= wxDefaultPosition
,
134 const wxSize
& size
= wxDefaultSize
,
136 const wxString
& szBackend
= wxEmptyString
,
137 const wxValidator
& validator
= wxDefaultValidator
,
138 const wxString
& name
= wxT("mediaCtrl"))
139 : m_imp(NULL
), m_bLoaded(false)
140 { Create(parent
, winid
, location
, pos
, size
, style
,
141 szBackend
, validator
, name
); }
145 bool Create(wxWindow
* parent
, wxWindowID winid
,
146 const wxString
& fileName
= wxEmptyString
,
147 const wxPoint
& pos
= wxDefaultPosition
,
148 const wxSize
& size
= wxDefaultSize
,
150 const wxString
& szBackend
= wxEmptyString
,
151 const wxValidator
& validator
= wxDefaultValidator
,
152 const wxString
& name
= wxT("mediaCtrl"));
154 bool Create(wxWindow
* parent
, wxWindowID winid
,
155 const wxURI
& location
,
156 const wxPoint
& pos
= wxDefaultPosition
,
157 const wxSize
& size
= wxDefaultSize
,
159 const wxString
& szBackend
= wxEmptyString
,
160 const wxValidator
& validator
= wxDefaultValidator
,
161 const wxString
& name
= wxT("mediaCtrl")); //DirectShow only
163 bool DoCreate(wxClassInfo
* instance
,
164 wxWindow
* parent
, wxWindowID winid
,
165 const wxPoint
& pos
= wxDefaultPosition
,
166 const wxSize
& size
= wxDefaultSize
,
168 const wxValidator
& validator
= wxDefaultValidator
,
169 const wxString
& name
= wxT("mediaCtrl"));
175 bool Load(const wxString
& fileName
);
178 wxMediaState
GetState();
180 wxFileOffset
Seek(wxFileOffset where
, wxSeekMode mode
= wxFromStart
);
181 wxFileOffset
Tell(); //FIXME: This should be const
182 wxFileOffset
Length(); //FIXME: This should be const
185 // Unofficial parts of API
187 //DirectShow/GStreamer only. Quicktime too, but somewhat buggy...
188 bool Load(const wxURI
& location
);
190 double GetPlaybackRate(); //All but MCI & GStreamer
191 bool SetPlaybackRate(double dRate
); //All but MCI & GStreamer
193 double GetVolume(); //DirectShow only
194 bool SetVolume(double dVolume
); //DirectShow only
197 static wxClassInfo
* NextBackend();
199 void OnMediaFinished(wxMediaEvent
& evt
);
200 virtual void DoMoveWindow(int x
, int y
, int w
, int h
);
201 wxSize
DoGetBestSize() const;
203 //FIXME: This is nasty... find a better way to work around
206 friend class wxQTMediaBackend
;
209 friend class wxQTMediaBackend
;
211 class wxMediaBackend
* m_imp
;
214 DECLARE_DYNAMIC_CLASS(wxMediaCtrl
)
217 // ----------------------------------------------------------------------------
221 // Currently an internal class - API stability not guaranteed.
223 // ----------------------------------------------------------------------------
225 class WXDLLIMPEXP_MEDIA wxMediaBackend
: public wxObject
231 virtual ~wxMediaBackend();
233 virtual bool CreateControl(wxControl
* WXUNUSED(ctrl
),
234 wxWindow
* WXUNUSED(parent
),
235 wxWindowID
WXUNUSED(winid
),
236 const wxPoint
& WXUNUSED(pos
),
237 const wxSize
& WXUNUSED(size
),
238 long WXUNUSED(style
),
239 const wxValidator
& WXUNUSED(validator
),
240 const wxString
& WXUNUSED(name
))
250 virtual bool Load(const wxString
& WXUNUSED(fileName
))
252 virtual bool Load(const wxURI
& WXUNUSED(location
))
255 virtual bool SetPosition(wxLongLong
WXUNUSED(where
))
257 virtual wxLongLong
GetPosition()
259 virtual wxLongLong
GetDuration()
262 virtual void Move(int WXUNUSED(x
), int WXUNUSED(y
),
263 int WXUNUSED(w
), int WXUNUSED(h
))
265 virtual wxSize
GetVideoSize() const
266 { return wxSize(0,0); }
268 virtual double GetPlaybackRate()
270 virtual bool SetPlaybackRate(double WXUNUSED(dRate
))
273 virtual wxMediaState
GetState()
274 { return wxMEDIASTATE_STOPPED
; }
276 virtual double GetVolume()
278 virtual bool SetVolume(double WXUNUSED(dVolume
))
281 virtual void RESERVED3() {}
282 virtual void RESERVED4() {}
283 virtual void RESERVED5() {}
284 virtual void RESERVED6() {}
285 virtual void RESERVED7() {}
286 virtual void RESERVED8() {}
287 virtual void RESERVED9() {}
289 DECLARE_DYNAMIC_CLASS(wxMediaBackend
)
292 //Event ID to give to our events
293 #define wxMEDIA_FINISHED_ID 13000
294 #define wxMEDIA_STOP_ID 13001
296 //Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
297 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA
, wxEVT_MEDIA_FINISHED
, wxMEDIA_FINISHED_ID
)
298 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA
, wxEVT_MEDIA_STOP
, wxMEDIA_STOP_ID
)
300 //Function type(s) our events need
301 typedef void (wxEvtHandler::*wxMediaEventFunction
)(wxMediaEvent
&);
303 #define wxMediaEventHandler(func) \
304 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMediaEventFunction, &func)
306 //Macro for usage with message maps
307 #define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ),
308 #define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ),
310 // ----------------------------------------------------------------------------
311 // End compilation gaurd
312 // ----------------------------------------------------------------------------
313 #endif // wxUSE_MEDIACTRL
315 // ----------------------------------------------------------------------------
316 // End header guard and header itself
317 // ----------------------------------------------------------------------------
318 #endif // _WX_MEDIACTRL_H_