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"
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
38 #include "wx/control.h"
41 // ============================================================================
43 // ============================================================================
45 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
58 #define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
59 #define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
60 #define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
61 #define wxMEDIABACKEND_GSTREAMER wxT("wxGStreamerMediaBackend")
63 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
69 class WXDLLIMPEXP_MEDIA wxMediaEvent
: public wxNotifyEvent
72 // ------------------------------------------------------------------------
73 // wxMediaEvent Constructor
75 // Normal constructor, much the same as wxNotifyEvent
76 // ------------------------------------------------------------------------
77 wxMediaEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
78 : wxNotifyEvent(commandType
, winid
)
81 // ------------------------------------------------------------------------
82 // wxMediaEvent Copy Constructor
84 // Normal copy constructor, much the same as wxNotifyEvent
85 // ------------------------------------------------------------------------
86 wxMediaEvent(const wxMediaEvent
&clone
)
87 : wxNotifyEvent(clone
)
90 // ------------------------------------------------------------------------
91 // wxMediaEvent::Clone
93 // Allocates a copy of this object.
94 // Required for wxEvtHandler::AddPendingEvent
95 // ------------------------------------------------------------------------
96 virtual wxEvent
*Clone() const
97 { return new wxMediaEvent(*this); }
100 // Put this class on wxWidget's RTTI table
101 DECLARE_DYNAMIC_CLASS(wxMediaEvent
)
104 // ----------------------------------------------------------------------------
108 // ----------------------------------------------------------------------------
110 class WXDLLIMPEXP_MEDIA wxMediaCtrl
: public wxControl
113 wxMediaCtrl() : m_imp(NULL
), m_bLoaded(false), m_bLoop(false)
116 wxMediaCtrl(wxWindow
* parent
, wxWindowID winid
,
117 const wxString
& fileName
= wxEmptyString
,
118 const wxPoint
& pos
= wxDefaultPosition
,
119 const wxSize
& size
= wxDefaultSize
,
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
); }
128 wxMediaCtrl(wxWindow
* parent
, wxWindowID winid
,
129 const wxURI
& location
,
130 const wxPoint
& pos
= wxDefaultPosition
,
131 const wxSize
& size
= wxDefaultSize
,
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
); }
142 bool Create(wxWindow
* parent
, wxWindowID winid
,
143 const wxString
& fileName
= wxEmptyString
,
144 const wxPoint
& pos
= wxDefaultPosition
,
145 const wxSize
& size
= wxDefaultSize
,
147 const wxString
& szBackend
= wxEmptyString
,
148 const wxValidator
& validator
= wxDefaultValidator
,
149 const wxString
& name
= wxT("mediaCtrl"));
151 bool Create(wxWindow
* parent
, wxWindowID winid
,
152 const wxURI
& location
,
153 const wxPoint
& pos
= wxDefaultPosition
,
154 const wxSize
& size
= wxDefaultSize
,
156 const wxString
& szBackend
= wxEmptyString
,
157 const wxValidator
& validator
= wxDefaultValidator
,
158 const wxString
& name
= wxT("mediaCtrl")); //DirectShow only
160 bool DoCreate(wxClassInfo
* instance
,
161 wxWindow
* parent
, wxWindowID winid
,
162 const wxPoint
& pos
= wxDefaultPosition
,
163 const wxSize
& size
= wxDefaultSize
,
165 const wxValidator
& validator
= wxDefaultValidator
,
166 const wxString
& name
= wxT("mediaCtrl"));
172 bool Load(const wxString
& fileName
);
173 bool Load(const wxURI
& location
); //DirectShow only
175 void Loop(bool bLoop
= true);
178 wxMediaState
GetState();
180 double GetPlaybackRate(); //All but MCI
181 bool SetPlaybackRate(double dRate
); //All but MCI
183 wxFileOffset
Seek(wxFileOffset where
, wxSeekMode mode
= wxFromStart
);
184 wxFileOffset
Tell(); //FIXME: This should be const
185 wxFileOffset
Length(); //FIXME: This should be const
188 static wxClassInfo
* NextBackend();
190 void OnMediaFinished(wxMediaEvent
& evt
);
191 virtual void DoMoveWindow(int x
, int y
, int w
, int h
);
192 wxSize
DoGetBestSize() const;
195 friend class wxQTMediaBackend
;
198 friend class wxQTMediaBackend
;
200 class wxMediaBackend
* m_imp
;
204 DECLARE_DYNAMIC_CLASS(wxMediaCtrl
)
207 // ----------------------------------------------------------------------------
211 // Currently an internal class - API stability not guaranteed.
213 // ----------------------------------------------------------------------------
215 class WXDLLIMPEXP_MEDIA wxMediaBackend
: public wxObject
221 virtual ~wxMediaBackend();
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
))
240 virtual bool Load(const wxString
& WXUNUSED(fileName
))
242 virtual bool Load(const wxURI
& WXUNUSED(location
))
245 virtual bool SetPosition(wxLongLong
WXUNUSED(where
))
247 virtual wxLongLong
GetPosition()
249 virtual wxLongLong
GetDuration()
252 virtual void Move(int WXUNUSED(x
), int WXUNUSED(y
),
253 int WXUNUSED(w
), int WXUNUSED(h
))
255 virtual wxSize
GetVideoSize() const
258 virtual double GetPlaybackRate()
260 virtual bool SetPlaybackRate(double WXUNUSED(dRate
))
263 virtual wxMediaState
GetState()
264 { return wxMEDIASTATE_STOPPED
; }
266 DECLARE_DYNAMIC_CLASS(wxMediaBackend
)
269 //Event ID to give to our events
270 #define wxMEDIA_FINISHED_ID 13000
271 #define wxMEDIA_STOP_ID 13001
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
)
277 //Function type(s) our events need
278 typedef void (wxEvtHandler
::*wxMediaEventFunction
)(wxMediaEvent
&);
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 ),
284 // ----------------------------------------------------------------------------
285 // End compilation gaurd
286 // ----------------------------------------------------------------------------
287 #endif // wxUSE_MEDIACTRL
289 // ----------------------------------------------------------------------------
290 // End header guard and header itself
291 // ----------------------------------------------------------------------------
292 #endif // _WX_MEDIACTRL_H_