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")
62 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 class WXDLLIMPEXP_MEDIA wxMediaEvent
: public wxNotifyEvent
71 // ------------------------------------------------------------------------
72 // wxMediaEvent Constructor
74 // Normal constructor, much the same as wxNotifyEvent
75 // ------------------------------------------------------------------------
76 wxMediaEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0)
77 : wxNotifyEvent(commandType
, id
)
80 // ------------------------------------------------------------------------
81 // wxMediaEvent Copy Constructor
83 // Normal copy constructor, much the same as wxNotifyEvent
84 // ------------------------------------------------------------------------
85 wxMediaEvent(const wxMediaEvent
&clone
)
86 : wxNotifyEvent(clone
)
89 // ------------------------------------------------------------------------
90 // wxMediaEvent::Clone
92 // Allocates a copy of this object.
93 // Required for wxEvtHandler::AddPendingEvent
94 // ------------------------------------------------------------------------
95 virtual wxEvent
*Clone() const
96 { return new wxMediaEvent(*this); }
99 // Put this class on wxWidget's RTTI table
100 DECLARE_DYNAMIC_CLASS(wxMediaEvent
)
103 // ----------------------------------------------------------------------------
107 // ----------------------------------------------------------------------------
109 class WXDLLIMPEXP_MEDIA wxMediaCtrl
: public wxControl
112 wxMediaCtrl() : m_imp(NULL
), m_bLoaded(false), m_bLoop(false)
115 wxMediaCtrl(wxWindow
* parent
, wxWindowID id
,
116 const wxString
& fileName
= wxT(""),
117 const wxPoint
& pos
= wxDefaultPosition
,
118 const wxSize
& size
= wxDefaultSize
,
120 const wxString
& szBackend
= wxT(""),
121 const wxValidator
& validator
= wxDefaultValidator
,
122 const wxString
& name
= wxT("mediaCtrl"))
123 : m_imp(NULL
), m_bLoaded(false), m_bLoop(false)
124 { Create(parent
, id
, fileName
, pos
, size
, style
,
125 szBackend
, validator
, name
); }
127 wxMediaCtrl(wxWindow
* parent
, wxWindowID id
,
128 const wxURI
& location
,
129 const wxPoint
& pos
= wxDefaultPosition
,
130 const wxSize
& size
= wxDefaultSize
,
132 const wxString
& szBackend
= wxT(""),
133 const wxValidator
& validator
= wxDefaultValidator
,
134 const wxString
& name
= wxT("mediaCtrl"))
135 : m_imp(NULL
), m_bLoop(false)
136 { Create(parent
, id
, location
, pos
, size
, style
,
137 szBackend
, validator
, name
); }
141 bool Create(wxWindow
* parent
, wxWindowID id
,
142 const wxString
& fileName
= wxT(""),
143 const wxPoint
& pos
= wxDefaultPosition
,
144 const wxSize
& size
= wxDefaultSize
,
146 const wxString
& szBackend
= wxT(""),
147 const wxValidator
& validator
= wxDefaultValidator
,
148 const wxString
& name
= wxT("mediaCtrl"));
150 bool Create(wxWindow
* parent
, wxWindowID id
,
151 const wxURI
& location
,
152 const wxPoint
& pos
= wxDefaultPosition
,
153 const wxSize
& size
= wxDefaultSize
,
155 const wxString
& szBackend
= wxT(""),
156 const wxValidator
& validator
= wxDefaultValidator
,
157 const wxString
& name
= wxT("mediaCtrl")); //DirectShow only
159 bool DoCreate(wxClassInfo
* instance
,
160 wxWindow
* parent
, wxWindowID id
,
161 const wxPoint
& pos
= wxDefaultPosition
,
162 const wxSize
& size
= wxDefaultSize
,
164 const wxValidator
& validator
= wxDefaultValidator
,
165 const wxString
& name
= wxT("mediaCtrl"));
171 bool Load(const wxString
& fileName
);
172 bool Load(const wxURI
& location
); //DirectShow only
174 void Loop(bool bLoop
= true);
177 wxMediaState
GetState();
179 double GetPlaybackRate(); //All but MCI
180 bool SetPlaybackRate(double dRate
); //All but MCI
182 wxFileOffset
Seek(wxFileOffset where
, wxSeekMode mode
= wxFromStart
);
183 wxFileOffset
Tell(); //FIXME: This should be const
184 wxFileOffset
Length(); //FIXME: This should be const
187 static wxClassInfo
* NextBackend();
189 void OnMediaFinished(wxMediaEvent
& evt
);
190 virtual void DoMoveWindow(int x
, int y
, int w
, int h
);
191 wxSize
DoGetBestSize() const;
194 friend class wxMediaBackend
;
196 class wxMediaBackend
* m_imp
;
200 DECLARE_DYNAMIC_CLASS(wxMediaCtrl
);
203 // ----------------------------------------------------------------------------
207 // Currently an internal class - API stability not guaranteed.
209 // ----------------------------------------------------------------------------
211 class WXDLLIMPEXP_MEDIA wxMediaBackend
: public wxObject
217 virtual ~wxMediaBackend();
219 virtual bool CreateControl(wxControl
* WXUNUSED(ctrl
),
220 wxWindow
* WXUNUSED(parent
),
221 wxWindowID
WXUNUSED(id
),
222 const wxPoint
& WXUNUSED(pos
),
223 const wxSize
& WXUNUSED(size
),
224 long WXUNUSED(style
),
225 const wxValidator
& WXUNUSED(validator
),
226 const wxString
& WXUNUSED(name
))
236 virtual bool Load(const wxString
& WXUNUSED(fileName
))
238 virtual bool Load(const wxURI
& WXUNUSED(location
))
241 virtual bool SetPosition(wxLongLong
WXUNUSED(where
))
243 virtual wxLongLong
GetPosition()
245 virtual wxLongLong
GetDuration()
248 virtual void Move(int WXUNUSED(x
), int WXUNUSED(y
),
249 int WXUNUSED(w
), int WXUNUSED(h
))
251 virtual wxSize
GetVideoSize() const
252 { return wxSize(0,0); }
254 virtual double GetPlaybackRate()
256 virtual bool SetPlaybackRate(double WXUNUSED(dRate
))
259 virtual wxMediaState
GetState()
260 { return wxMEDIASTATE_STOPPED
; }
263 wxMacControl
* GetControlPeer(wxControl
* ctrl
)
264 { return ((wxMediaCtrl
*)ctrl
)->m_peer
; }
267 DECLARE_CLASS(wxMediaBackend
)
270 //Event ID to give to our events
271 #define wxMEDIA_FINISHED_ID 13000
272 #define wxMEDIA_STOP_ID 13001
274 //Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
275 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA
, wxEVT_MEDIA_FINISHED
, wxMEDIA_FINISHED_ID
)
276 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA
, wxEVT_MEDIA_STOP
, wxMEDIA_STOP_ID
)
278 //Function type(s) our events need
279 typedef void (wxEvtHandler::*wxMediaEventFunction
)(wxMediaEvent
&);
281 //Macro for usage with message maps
282 #define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
283 #define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
285 // ----------------------------------------------------------------------------
286 // End compilation gaurd
287 // ----------------------------------------------------------------------------
288 #endif // wxUSE_MEDIACTRL
290 // ----------------------------------------------------------------------------
291 // End header guard and header itself
292 // ----------------------------------------------------------------------------
293 #endif // _WX_MEDIACTRL_H_