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)
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)
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_bLoaded(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
);
175 wxMediaState
GetState();
177 wxFileOffset
Seek(wxFileOffset where
, wxSeekMode mode
= wxFromStart
);
178 wxFileOffset
Tell(); //FIXME: This should be const
179 wxFileOffset
Length(); //FIXME: This should be const
182 // Unofficial parts of API
184 //DirectShow/GStreamer only. Quicktime too, but somewhat buggy...
185 bool Load(const wxURI
& location
);
187 double GetPlaybackRate(); //All but MCI & GStreamer
188 bool SetPlaybackRate(double dRate
); //All but MCI & GStreamer
191 static wxClassInfo
* NextBackend();
193 void OnMediaFinished(wxMediaEvent
& evt
);
194 virtual void DoMoveWindow(int x
, int y
, int w
, int h
);
195 wxSize
DoGetBestSize() const;
197 //FIXME: This is nasty... find a better way to work around
200 friend class wxQTMediaBackend
;
203 friend class wxQTMediaBackend
;
205 class wxMediaBackend
* m_imp
;
208 DECLARE_DYNAMIC_CLASS(wxMediaCtrl
)
211 // ----------------------------------------------------------------------------
215 // Currently an internal class - API stability not guaranteed.
217 // ----------------------------------------------------------------------------
219 class WXDLLIMPEXP_MEDIA wxMediaBackend
: public wxObject
225 virtual ~wxMediaBackend();
227 virtual bool CreateControl(wxControl
* WXUNUSED(ctrl
),
228 wxWindow
* WXUNUSED(parent
),
229 wxWindowID
WXUNUSED(winid
),
230 const wxPoint
& WXUNUSED(pos
),
231 const wxSize
& WXUNUSED(size
),
232 long WXUNUSED(style
),
233 const wxValidator
& WXUNUSED(validator
),
234 const wxString
& WXUNUSED(name
))
244 virtual bool Load(const wxString
& WXUNUSED(fileName
))
246 virtual bool Load(const wxURI
& WXUNUSED(location
))
249 virtual bool SetPosition(wxLongLong
WXUNUSED(where
))
251 virtual wxLongLong
GetPosition()
253 virtual wxLongLong
GetDuration()
256 virtual void Move(int WXUNUSED(x
), int WXUNUSED(y
),
257 int WXUNUSED(w
), int WXUNUSED(h
))
259 virtual wxSize
GetVideoSize() const
262 virtual double GetPlaybackRate()
264 virtual bool SetPlaybackRate(double WXUNUSED(dRate
))
267 virtual wxMediaState
GetState()
268 { return wxMEDIASTATE_STOPPED
; }
270 DECLARE_DYNAMIC_CLASS(wxMediaBackend
)
273 //Event ID to give to our events
274 #define wxMEDIA_FINISHED_ID 13000
275 #define wxMEDIA_STOP_ID 13001
277 //Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
278 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA
, wxEVT_MEDIA_FINISHED
, wxMEDIA_FINISHED_ID
)
279 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA
, wxEVT_MEDIA_STOP
, wxMEDIA_STOP_ID
)
281 //Function type(s) our events need
282 typedef void (wxEvtHandler::*wxMediaEventFunction
)(wxMediaEvent
&);
284 //Macro for usage with message maps
285 #define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
286 #define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
288 // ----------------------------------------------------------------------------
289 // End compilation gaurd
290 // ----------------------------------------------------------------------------
291 #endif // wxUSE_MEDIACTRL
293 // ----------------------------------------------------------------------------
294 // End header guard and header itself
295 // ----------------------------------------------------------------------------
296 #endif // _WX_MEDIACTRL_H_