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
194 static wxClassInfo
* NextBackend();
196 void OnMediaFinished(wxMediaEvent
& evt
);
197 virtual void DoMoveWindow(int x
, int y
, int w
, int h
);
198 wxSize
DoGetBestSize() const;
200 //FIXME: This is nasty... find a better way to work around
203 friend class wxQTMediaBackend
;
206 friend class wxQTMediaBackend
;
208 class wxMediaBackend
* m_imp
;
211 DECLARE_DYNAMIC_CLASS(wxMediaCtrl
)
214 // ----------------------------------------------------------------------------
218 // Currently an internal class - API stability not guaranteed.
220 // ----------------------------------------------------------------------------
222 class WXDLLIMPEXP_MEDIA wxMediaBackend
: public wxObject
228 virtual ~wxMediaBackend();
230 virtual bool CreateControl(wxControl
* WXUNUSED(ctrl
),
231 wxWindow
* WXUNUSED(parent
),
232 wxWindowID
WXUNUSED(winid
),
233 const wxPoint
& WXUNUSED(pos
),
234 const wxSize
& WXUNUSED(size
),
235 long WXUNUSED(style
),
236 const wxValidator
& WXUNUSED(validator
),
237 const wxString
& WXUNUSED(name
))
247 virtual bool Load(const wxString
& WXUNUSED(fileName
))
249 virtual bool Load(const wxURI
& WXUNUSED(location
))
252 virtual bool SetPosition(wxLongLong
WXUNUSED(where
))
254 virtual wxLongLong
GetPosition()
256 virtual wxLongLong
GetDuration()
259 virtual void Move(int WXUNUSED(x
), int WXUNUSED(y
),
260 int WXUNUSED(w
), int WXUNUSED(h
))
262 virtual wxSize
GetVideoSize() const
263 { return wxSize(0,0); }
265 virtual double GetPlaybackRate()
267 virtual bool SetPlaybackRate(double WXUNUSED(dRate
))
270 virtual wxMediaState
GetState()
271 { return wxMEDIASTATE_STOPPED
; }
273 virtual void RESERVED1() {}
274 virtual void RESERVED2() {}
275 virtual void RESERVED3() {}
276 virtual void RESERVED4() {}
277 virtual void RESERVED5() {}
278 virtual void RESERVED6() {}
279 virtual void RESERVED7() {}
280 virtual void RESERVED8() {}
281 virtual void RESERVED9() {}
283 DECLARE_DYNAMIC_CLASS(wxMediaBackend
)
286 //Event ID to give to our events
287 #define wxMEDIA_FINISHED_ID 13000
288 #define wxMEDIA_STOP_ID 13001
290 //Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
291 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA
, wxEVT_MEDIA_FINISHED
, wxMEDIA_FINISHED_ID
)
292 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA
, wxEVT_MEDIA_STOP
, wxMEDIA_STOP_ID
)
294 //Function type(s) our events need
295 typedef void (wxEvtHandler::*wxMediaEventFunction
)(wxMediaEvent
&);
297 #define wxMediaEventHandler(func) \
298 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMediaEventFunction, &func)
300 //Macro for usage with message maps
301 #define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ),
302 #define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ),
304 // ----------------------------------------------------------------------------
305 // End compilation gaurd
306 // ----------------------------------------------------------------------------
307 #endif // wxUSE_MEDIACTRL
309 // ----------------------------------------------------------------------------
310 // End header guard and header itself
311 // ----------------------------------------------------------------------------
312 #endif // _WX_MEDIACTRL_H_