]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mediactrl.h
fixed Cygwin compilation (there's no _get_osfhandle)
[wxWidgets.git] / include / wx / mediactrl.h
CommitLineData
ff4aedc5 1///////////////////////////////////////////////////////////////////////////////
1a680109
RN
2// Name: wx/mediactrl.h
3// Purpose: wxMediaCtrl class
4// Author: Ryan Norton <wxprojects@comcast.net>
226ec5a7 5// Modified by:
1a680109
RN
6// Created: 11/07/04
7// RCS-ID: $Id$
8// Copyright: (c) Ryan Norton
9// Licence: wxWindows licence
ff4aedc5 10///////////////////////////////////////////////////////////////////////////////
1a680109 11
ff4aedc5
RN
12// ============================================================================
13// Definitions
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// Header guard
18// ----------------------------------------------------------------------------
19#ifndef _WX_MEDIACTRL_H_
20#define _WX_MEDIACTRL_H_
21
22// ----------------------------------------------------------------------------
23// Pre-compiled header stuff
24// ----------------------------------------------------------------------------
25#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
26#pragma interface "mediactrl.h"
72259e00
RL
27#endif
28
ff4aedc5
RN
29// ----------------------------------------------------------------------------
30// Compilation guard
31// ----------------------------------------------------------------------------
32#if wxUSE_MEDIACTRL
33
34// ----------------------------------------------------------------------------
35// Includes
36// ----------------------------------------------------------------------------
37
38#include "wx/control.h"
39#include "wx/uri.h"
40
41// ============================================================================
42// Declarations
43// ============================================================================
44
45// ----------------------------------------------------------------------------
46//
47// Enumerations
48//
49// ----------------------------------------------------------------------------
50
51enum wxMediaState
52{
53 wxMEDIASTATE_STOPPED,
54 wxMEDIASTATE_PAUSED,
55 wxMEDIASTATE_PLAYING
56};
57
ff4aedc5
RN
58#define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
59#define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
60#define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
ce756cb0 61#define wxMEDIABACKEND_GSTREAMER wxT("wxGStreamerMediaBackend")
ff4aedc5 62
226ec5a7
WS
63// ----------------------------------------------------------------------------
64//
65// wxMediaEvent
66//
67// ----------------------------------------------------------------------------
68
ff2b312f 69class WXDLLIMPEXP_MEDIA wxMediaEvent : public wxNotifyEvent
226ec5a7
WS
70{
71public:
72 // ------------------------------------------------------------------------
73 // wxMediaEvent Constructor
74 //
75 // Normal constructor, much the same as wxNotifyEvent
76 // ------------------------------------------------------------------------
4fc81cbc
RN
77 wxMediaEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
78 : wxNotifyEvent(commandType, winid)
226ec5a7
WS
79 { }
80
81 // ------------------------------------------------------------------------
82 // wxMediaEvent Copy Constructor
83 //
84 // Normal copy constructor, much the same as wxNotifyEvent
85 // ------------------------------------------------------------------------
86 wxMediaEvent(const wxMediaEvent &clone)
87 : wxNotifyEvent(clone)
88 { }
89
90 // ------------------------------------------------------------------------
91 // wxMediaEvent::Clone
92 //
93 // Allocates a copy of this object.
94 // Required for wxEvtHandler::AddPendingEvent
95 // ------------------------------------------------------------------------
96 virtual wxEvent *Clone() const
97 { return new wxMediaEvent(*this); }
98
99
100 // Put this class on wxWidget's RTTI table
101 DECLARE_DYNAMIC_CLASS(wxMediaEvent)
102};
103
ff4aedc5
RN
104// ----------------------------------------------------------------------------
105//
106// wxMediaCtrl
107//
108// ----------------------------------------------------------------------------
109
ff2b312f 110class WXDLLIMPEXP_MEDIA wxMediaCtrl : public wxControl
ff4aedc5
RN
111{
112public:
bc036010 113 wxMediaCtrl() : m_imp(NULL), m_bLoaded(false)
ff4aedc5
RN
114 { }
115
4fc81cbc 116 wxMediaCtrl(wxWindow* parent, wxWindowID winid,
8b5d5223 117 const wxString& fileName = wxEmptyString,
226ec5a7 118 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 119 const wxSize& size = wxDefaultSize,
226ec5a7 120 long style = 0,
8b5d5223 121 const wxString& szBackend = wxEmptyString,
ff4aedc5
RN
122 const wxValidator& validator = wxDefaultValidator,
123 const wxString& name = wxT("mediaCtrl"))
bc036010 124 : m_imp(NULL), m_bLoaded(false)
4fc81cbc 125 { Create(parent, winid, fileName, pos, size, style,
ff4aedc5
RN
126 szBackend, validator, name); }
127
4fc81cbc 128 wxMediaCtrl(wxWindow* parent, wxWindowID winid,
ff4aedc5 129 const wxURI& location,
226ec5a7 130 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 131 const wxSize& size = wxDefaultSize,
226ec5a7 132 long style = 0,
8b5d5223 133 const wxString& szBackend = wxEmptyString,
ff4aedc5
RN
134 const wxValidator& validator = wxDefaultValidator,
135 const wxString& name = wxT("mediaCtrl"))
bc036010 136 : m_imp(NULL), m_bLoaded(false)
4fc81cbc 137 { Create(parent, winid, location, pos, size, style,
ff4aedc5
RN
138 szBackend, validator, name); }
139
140 ~wxMediaCtrl();
141
4fc81cbc 142 bool Create(wxWindow* parent, wxWindowID winid,
8b5d5223 143 const wxString& fileName = wxEmptyString,
226ec5a7 144 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 145 const wxSize& size = wxDefaultSize,
226ec5a7 146 long style = 0,
8b5d5223 147 const wxString& szBackend = wxEmptyString,
ff4aedc5
RN
148 const wxValidator& validator = wxDefaultValidator,
149 const wxString& name = wxT("mediaCtrl"));
150
4fc81cbc 151 bool Create(wxWindow* parent, wxWindowID winid,
ff4aedc5 152 const wxURI& location,
226ec5a7 153 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 154 const wxSize& size = wxDefaultSize,
226ec5a7 155 long style = 0,
8b5d5223 156 const wxString& szBackend = wxEmptyString,
ff4aedc5 157 const wxValidator& validator = wxDefaultValidator,
9180b535 158 const wxString& name = wxT("mediaCtrl")); //DirectShow only
ff4aedc5
RN
159
160 bool DoCreate(wxClassInfo* instance,
4fc81cbc 161 wxWindow* parent, wxWindowID winid,
226ec5a7 162 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 163 const wxSize& size = wxDefaultSize,
226ec5a7 164 long style = 0,
ff4aedc5
RN
165 const wxValidator& validator = wxDefaultValidator,
166 const wxString& name = wxT("mediaCtrl"));
167
ff4aedc5
RN
168 bool Play();
169 bool Pause();
170 bool Stop();
171
172 bool Load(const wxString& fileName);
ff4aedc5 173
ff4aedc5
RN
174
175 wxMediaState GetState();
176
9180b535
RN
177 wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart);
178 wxFileOffset Tell(); //FIXME: This should be const
179 wxFileOffset Length(); //FIXME: This should be const
973dc0a8 180
bc036010
RN
181 //
182 // Unofficial parts of API
183 //
184 //DirectShow/GStreamer only. Quicktime too, but somewhat buggy...
185 bool Load(const wxURI& location);
186
187 double GetPlaybackRate(); //All but MCI & GStreamer
188 bool SetPlaybackRate(double dRate); //All but MCI & GStreamer
189
ff4aedc5 190protected:
973dc0a8
RN
191 static wxClassInfo* NextBackend();
192
226ec5a7 193 void OnMediaFinished(wxMediaEvent& evt);
ff4aedc5
RN
194 virtual void DoMoveWindow(int x, int y, int w, int h);
195 wxSize DoGetBestSize() const;
196
bc036010
RN
197 //FIXME: This is nasty... find a better way to work around
198 //inheritance issues
3b5023b9 199#ifdef __WXMAC__
ecd20d4a 200 friend class wxQTMediaBackend;
4fc81cbc
RN
201#endif
202#ifdef __WXCOCOA__
203 friend class wxQTMediaBackend;
3b5023b9 204#endif
ff4aedc5
RN
205 class wxMediaBackend* m_imp;
206 bool m_bLoaded;
ff4aedc5 207
3839f37e 208 DECLARE_DYNAMIC_CLASS(wxMediaCtrl)
ff4aedc5
RN
209};
210
211// ----------------------------------------------------------------------------
212//
213// wxMediaBackend
214//
9180b535 215// Currently an internal class - API stability not guaranteed.
ff4aedc5
RN
216//
217// ----------------------------------------------------------------------------
218
ff2b312f 219class WXDLLIMPEXP_MEDIA wxMediaBackend : public wxObject
ff4aedc5
RN
220{
221public:
222 wxMediaBackend()
223 { }
224
225 virtual ~wxMediaBackend();
226
226ec5a7
WS
227 virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
228 wxWindow* WXUNUSED(parent),
4fc81cbc 229 wxWindowID WXUNUSED(winid),
226ec5a7 230 const wxPoint& WXUNUSED(pos),
78450975 231 const wxSize& WXUNUSED(size),
226ec5a7 232 long WXUNUSED(style),
78450975
RN
233 const wxValidator& WXUNUSED(validator),
234 const wxString& WXUNUSED(name))
ff4aedc5
RN
235 { return false; }
236
226ec5a7 237 virtual bool Play()
ff4aedc5 238 { return false; }
226ec5a7 239 virtual bool Pause()
ff4aedc5 240 { return false; }
226ec5a7 241 virtual bool Stop()
ff4aedc5
RN
242 { return false; }
243
226ec5a7 244 virtual bool Load(const wxString& WXUNUSED(fileName))
ff4aedc5 245 { return false; }
226ec5a7 246 virtual bool Load(const wxURI& WXUNUSED(location))
ff4aedc5
RN
247 { return false; }
248
226ec5a7 249 virtual bool SetPosition(wxLongLong WXUNUSED(where))
ff4aedc5 250 { return 0; }
226ec5a7 251 virtual wxLongLong GetPosition()
ff4aedc5 252 { return 0; }
226ec5a7 253 virtual wxLongLong GetDuration()
ff4aedc5
RN
254 { return 0; }
255
226ec5a7
WS
256 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
257 int WXUNUSED(w), int WXUNUSED(h))
ff4aedc5 258 { }
226ec5a7 259 virtual wxSize GetVideoSize() const
8b5d5223 260 { return wxSize(); }
ff4aedc5 261
226ec5a7 262 virtual double GetPlaybackRate()
ff4aedc5 263 { return 0.0; }
226ec5a7 264 virtual bool SetPlaybackRate(double WXUNUSED(dRate))
ff4aedc5
RN
265 { return false; }
266
267 virtual wxMediaState GetState()
268 { return wxMEDIASTATE_STOPPED; }
269
3839f37e 270 DECLARE_DYNAMIC_CLASS(wxMediaBackend)
ff4aedc5
RN
271};
272
ff4aedc5
RN
273//Event ID to give to our events
274#define wxMEDIA_FINISHED_ID 13000
275#define wxMEDIA_STOP_ID 13001
276
277//Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
c220a8ec
RD
278DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_FINISHED, wxMEDIA_FINISHED_ID)
279DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_STOP, wxMEDIA_STOP_ID)
ff4aedc5
RN
280
281//Function type(s) our events need
282typedef void (wxEvtHandler::*wxMediaEventFunction)(wxMediaEvent&);
283
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 ),
287
288// ----------------------------------------------------------------------------
289// End compilation gaurd
290// ----------------------------------------------------------------------------
291#endif // wxUSE_MEDIACTRL
292
293// ----------------------------------------------------------------------------
294// End header guard and header itself
295// ----------------------------------------------------------------------------
296#endif // _WX_MEDIACTRL_H_
297
298