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 enum wxMediaTimeFormat
60 wxMEDIATIMEFORMAT_TIME
63 #define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
64 #define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
65 #define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
67 // ----------------------------------------------------------------------------
71 // ----------------------------------------------------------------------------
73 class WXDLLIMPEXP_MEDIA wxMediaEvent
: public wxNotifyEvent
76 // ------------------------------------------------------------------------
77 // wxMediaEvent Constructor
79 // Normal constructor, much the same as wxNotifyEvent
80 // ------------------------------------------------------------------------
81 wxMediaEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0)
82 : wxNotifyEvent(commandType
, id
)
85 // ------------------------------------------------------------------------
86 // wxMediaEvent Copy Constructor
88 // Normal copy constructor, much the same as wxNotifyEvent
89 // ------------------------------------------------------------------------
90 wxMediaEvent(const wxMediaEvent
&clone
)
91 : wxNotifyEvent(clone
)
94 // ------------------------------------------------------------------------
95 // wxMediaEvent::Clone
97 // Allocates a copy of this object.
98 // Required for wxEvtHandler::AddPendingEvent
99 // ------------------------------------------------------------------------
100 virtual wxEvent
*Clone() const
101 { return new wxMediaEvent(*this); }
104 // Put this class on wxWidget's RTTI table
105 DECLARE_DYNAMIC_CLASS(wxMediaEvent
)
108 // ----------------------------------------------------------------------------
112 // ----------------------------------------------------------------------------
114 class WXDLLIMPEXP_MEDIA wxMediaCtrl
: public wxControl
117 wxMediaCtrl() : m_imp(NULL
), m_bLoaded(false), m_bLoop(false)
120 wxMediaCtrl(wxWindow
* parent
, wxWindowID id
,
121 const wxString
& fileName
= wxT(""),
122 const wxPoint
& pos
= wxDefaultPosition
,
123 const wxSize
& size
= wxDefaultSize
,
125 const wxString
& szBackend
= wxT(""),
126 const wxValidator
& validator
= wxDefaultValidator
,
127 const wxString
& name
= wxT("mediaCtrl"))
128 : m_imp(NULL
), m_bLoaded(false), m_bLoop(false)
129 { Create(parent
, id
, fileName
, pos
, size
, style
,
130 szBackend
, validator
, name
); }
132 wxMediaCtrl(wxWindow
* parent
, wxWindowID id
,
133 const wxURI
& location
,
134 const wxPoint
& pos
= wxDefaultPosition
,
135 const wxSize
& size
= wxDefaultSize
,
137 const wxString
& szBackend
= wxT(""),
138 const wxValidator
& validator
= wxDefaultValidator
,
139 const wxString
& name
= wxT("mediaCtrl"))
140 : m_imp(NULL
), m_bLoop(false)
141 { Create(parent
, id
, location
, pos
, size
, style
,
142 szBackend
, validator
, name
); }
146 bool Create(wxWindow
* parent
, wxWindowID id
,
147 const wxString
& fileName
= wxT(""),
148 const wxPoint
& pos
= wxDefaultPosition
,
149 const wxSize
& size
= wxDefaultSize
,
151 const wxString
& szBackend
= wxT(""),
152 const wxValidator
& validator
= wxDefaultValidator
,
153 const wxString
& name
= wxT("mediaCtrl"));
155 bool Create(wxWindow
* parent
, wxWindowID id
,
156 const wxURI
& location
,
157 const wxPoint
& pos
= wxDefaultPosition
,
158 const wxSize
& size
= wxDefaultSize
,
160 const wxString
& szBackend
= wxT(""),
161 const wxValidator
& validator
= wxDefaultValidator
,
162 const wxString
& name
= wxT("mediaCtrl"));
164 bool DoCreate(wxClassInfo
* instance
,
165 wxWindow
* parent
, wxWindowID id
,
166 const wxPoint
& pos
= wxDefaultPosition
,
167 const wxSize
& size
= wxDefaultSize
,
169 const wxValidator
& validator
= wxDefaultValidator
,
170 const wxString
& name
= wxT("mediaCtrl"));
176 bool Load(const wxString
& fileName
);
177 bool Load(const wxURI
& location
);
179 void Loop(bool bLoop
= true);
182 wxMediaState
GetState();
184 double GetPlaybackRate();
185 bool SetPlaybackRate(double dRate
);
187 bool SetPosition(wxLongLong where
);
188 wxLongLong
GetPosition();
189 wxLongLong
GetDuration();
191 //The following two prevent function hiding
192 void GetPosition(int* x
, int* y
) const
193 { wxControl::GetPosition(x
, y
); }
195 wxPoint
GetPosition() const
196 { return wxControl::GetPosition(); }
199 static wxClassInfo
* NextBackend();
201 void OnMediaFinished(wxMediaEvent
& evt
);
202 virtual void DoMoveWindow(int x
, int y
, int w
, int h
);
203 wxSize
DoGetBestSize() const;
205 class wxMediaBackend
* m_imp
;
209 DECLARE_DYNAMIC_CLASS(wxMediaCtrl
);
212 // ----------------------------------------------------------------------------
216 // Currently an internal class - API stability not gauranteed.
218 // ----------------------------------------------------------------------------
220 class WXDLLIMPEXP_MEDIA wxMediaBackend
: public wxObject
226 virtual ~wxMediaBackend();
228 virtual bool CreateControl(wxControl
* WXUNUSED(ctrl
),
229 wxWindow
* WXUNUSED(parent
),
230 wxWindowID
WXUNUSED(id
),
231 const wxPoint
& WXUNUSED(pos
),
232 const wxSize
& WXUNUSED(size
),
233 long WXUNUSED(style
),
234 const wxValidator
& WXUNUSED(validator
),
235 const wxString
& WXUNUSED(name
))
245 virtual bool Load(const wxString
& WXUNUSED(fileName
))
247 virtual bool Load(const wxURI
& WXUNUSED(location
))
250 virtual bool SetPosition(wxLongLong
WXUNUSED(where
))
252 virtual wxLongLong
GetPosition()
254 virtual wxLongLong
GetDuration()
257 virtual void Move(int WXUNUSED(x
), int WXUNUSED(y
),
258 int WXUNUSED(w
), int WXUNUSED(h
))
260 virtual wxSize
GetVideoSize() const
261 { return wxSize(0,0); }
263 virtual double GetPlaybackRate()
265 virtual bool SetPlaybackRate(double WXUNUSED(dRate
))
268 virtual wxMediaState
GetState()
269 { return wxMEDIASTATE_STOPPED
; }
271 DECLARE_CLASS(wxMediaBackend
)
274 //Event ID to give to our events
275 #define wxMEDIA_FINISHED_ID 13000
276 #define wxMEDIA_STOP_ID 13001
278 //Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
279 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA
, wxEVT_MEDIA_FINISHED
, wxMEDIA_FINISHED_ID
)
280 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA
, wxEVT_MEDIA_STOP
, wxMEDIA_STOP_ID
)
282 //Function type(s) our events need
283 typedef void (wxEvtHandler::*wxMediaEventFunction
)(wxMediaEvent
&);
285 //Macro for usage with message maps
286 #define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
287 #define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
289 // ----------------------------------------------------------------------------
290 // End compilation gaurd
291 // ----------------------------------------------------------------------------
292 #endif // wxUSE_MEDIACTRL
294 // ----------------------------------------------------------------------------
295 // End header guard and header itself
296 // ----------------------------------------------------------------------------
297 #endif // _WX_MEDIACTRL_H_