1 /////////////////////////////////////////////////////////////////////////////
2 // Name: msw/mediactrl.cpp
3 // Purpose: Built-in Media Backends for Windows
4 // Author: Ryan Norton <wxprojects@comcast.net>
8 // Copyright: (c) Ryan Norton
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 //===========================================================================
14 //===========================================================================
16 //---------------------------------------------------------------------------
17 // Pre-compiled header stuff
18 //---------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "mediactrl.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
31 //---------------------------------------------------------------------------
33 //---------------------------------------------------------------------------
34 #include "wx/mediactrl.h"
36 //---------------------------------------------------------------------------
38 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
43 //---------------------------------------------------------------------------
44 #include "wx/log.h" //wxLogDebug
45 #include "wx/math.h" //log10 & pow
46 #include "wx/msw/private.h" //user info and wndproc setting/getting
47 #include "wx/dcclient.h"
50 //---------------------------------------------------------------------------
51 // Externals (somewhere in src/msw/app.cpp and src/msw/window.cpp)
52 //---------------------------------------------------------------------------
53 extern "C" WXDLLIMPEXP_BASE HINSTANCE
wxGetInstance(void);
55 extern WXDLLIMPEXP_CORE wxChar
*wxCanvasClassName
;
57 extern WXDLLIMPEXP_CORE
const wxChar
*wxCanvasClassName
;
60 LRESULT WXDLLIMPEXP_CORE APIENTRY _EXPORT
wxWndProc(HWND hWnd
, UINT message
,
61 WPARAM wParam
, LPARAM lParam
);
63 //===========================================================================
64 // BACKEND DECLARATIONS
65 //===========================================================================
67 //---------------------------------------------------------------------------
71 //---------------------------------------------------------------------------
73 //---------------------------------------------------------------------------
75 //---------------------------------------------------------------------------
76 #include "wx/msw/ole/oleutils.h" //wxBasicString, IID etc.
77 #include "wx/msw/ole/uuid.h" //IID etc..
84 // These defines are from another ole header - but its not in the
85 // latest sdk. Also the ifndef DISPID_READYSTATE is here because at
86 // least on my machine with the latest sdk olectl.h defines these 3
88 #ifndef DISPID_READYSTATE
89 #define DISPID_READYSTATE -525
90 #define DISPID_READYSTATECHANGE -609
91 #define DISPID_AMBIENT_TRANSFERPRIORITY -728
94 #define DISPID_AMBIENT_OFFLINEIFNOTCONNECTED -5501
95 #define DISPID_AMBIENT_SILENT -5502
97 #ifndef DISPID_AMBIENT_CODEPAGE
98 # define DISPID_AMBIENT_CODEPAGE -725
99 # define DISPID_AMBIENT_CHARSET -727
102 //---------------------------------------------------------------------------
103 // COM compatability definitions
104 //---------------------------------------------------------------------------
105 #ifndef STDMETHODCALLTYPE
106 #define STDMETHODCALLTYPE __stdcall
109 #define STDMETHOD(funcname) virtual HRESULT STDMETHODCALLTYPE funcname
115 #define __RPC_FAR FAR
118 //---------------------------------------------------------------------------
119 // IIDS - used by CoCreateInstance and IUnknown::QueryInterface
121 // [idl name] [idl decription]
122 // amcompat.idl Microsoft Active Movie Control (Ver 2.0)
123 // nscompat.idl Microsoft NetShow Player (Ver 1.0)
124 // msdxm.idl Windows Media Player (Ver 1.0)
127 // First, when I say I "from XXX.idl", I mean I go into the COM Browser
128 // ($Microsoft Visual Studio$/Common/Tools/OLEVIEW.EXE), open
129 // "type libraries", open a specific type library (for quartz for example its
130 // "ActiveMovie control type library (V1.0)"), save it as an .idl, compile the
131 // idl using the midl compiler that comes with visual studio
132 // ($Microsoft Visual Studio$/VC98/bin/midl.exe on VC6) with the /h argument
133 // to make it generate stubs (a .h & .c file), then clean up the generated
134 // interfaces I want with the STDMETHOD wrappers and then put them into
137 // According to the MSDN docs, IMediaPlayer requires Windows 98 SE
138 // or greater. NetShow is available on Windows 3.1 and I'm guessing
139 // IActiveMovie is too. IMediaPlayer is essentially the Windows Media
142 // Some of these are not used but are kept here for future reference anyway
143 //---------------------------------------------------------------------------
144 const IID IID_IActiveMovie
= {0x05589FA2,0xC356,0x11CE,{0xBF,0x01,0x00,0xAA,0x00,0x55,0x59,0x5A}};
145 const IID IID_IActiveMovie2
= {0xB6CD6554,0xE9CB,0x11D0,{0x82,0x1F,0x00,0xA0,0xC9,0x1F,0x9C,0xA0}};
146 const IID IID_IActiveMovie3
= {0x265EC140,0xAE62,0x11D1,{0x85,0x00,0x00,0xA0,0xC9,0x1F,0x9C,0xA0}};
148 const IID IID_INSOPlay
= {0x2179C5D1,0xEBFF,0x11CF,{0xB6,0xFD,0x00,0xAA,0x00,0xB4,0xE2,0x20}};
149 const IID IID_INSPlay
= {0xE7C4BE80,0x7960,0x11D0,{0xB7,0x27,0x00,0xAA,0x00,0xB4,0xE2,0x20}};
150 const IID IID_INSPlay1
= {0x265EC141,0xAE62,0x11D1,{0x85,0x00,0x00,0xA0,0xC9,0x1F,0x9C,0xA0}};
152 const IID IID_IMediaPlayer
= {0x22D6F311,0xB0F6,0x11D0,{0x94,0xAB,0x00,0x80,0xC7,0x4C,0x7E,0x95}};
153 const IID IID_IMediaPlayer2
= {0x20D4F5E0,0x5475,0x11D2,{0x97,0x74,0x00,0x00,0xF8,0x08,0x55,0xE6}};
155 const CLSID CLSID_ActiveMovie
= {0x05589FA1,0xC356,0x11CE,{0xBF,0x01,0x00,0xAA,0x00,0x55,0x59,0x5A}};
156 const CLSID CLSID_MediaPlayer
= {0x22D6F312,0xB0F6,0x11D0,{0x94,0xAB,0x00,0x80,0xC7,0x4C,0x7E,0x95}};
157 const CLSID CLSID_NSPlay
= {0x2179C5D3,0xEBFF,0x11CF,{0xB6,0xFD,0x00,0xAA,0x00,0xB4,0xE2,0x20}};
159 const IID IID_IAMOpenProgress
= {0x8E1C39A1, 0xDE53, 0x11CF,{0xAA, 0x63, 0x00, 0x80, 0xC7, 0x44, 0x52, 0x8D}};
162 const CLSID CLSID_FilgraphManager
= {0xE436EBB3,0x524F,0x11CE,{0x9F,0x53,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
163 const IID IID_IMediaEvent
= {0x56A868B6,0x0AD4,0x11CE,{0xB0,0x3A,0x00,0x20,0xAF,0x0B,0xA7,0x70}};
166 const CLSID CLSID_VideoMixingRenderer9
={0x51B4ABF3, 0x748F, 0x4E3B,{0xA2, 0x76, 0xC8, 0x28, 0x33, 0x0E, 0x92, 0x6A}};
167 const IID IID_IVMRWindowlessControl9
= {0x8F537D09, 0xF85E, 0x4414,{0xB2, 0x3B, 0x50, 0x2E, 0x54, 0xC7, 0x99, 0x27}};
168 const IID IID_IFilterGraph
= {0x56A8689F, 0x0AD4, 0x11CE,{0xB0, 0x3A, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70}};
169 const IID IID_IGraphBuilder
= {0x56A868A9, 0x0AD4, 0x11CE,{0xB0, 0x3A, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70}};
170 const IID IID_IVMRFilterConfig9
= {0x5A804648, 0x4F66, 0x4867,{0x9C, 0x43, 0x4F, 0x5C, 0x82, 0x2C, 0xF1, 0xB8}};
171 const IID IID_IBaseFilter
= {0x56A86895, 0x0AD4, 0x11CE,{0xB0, 0x3A, 0x00, 0x20, 0xAF, 0x0B, 0xA7, 0x70}};
173 //---------------------------------------------------------------------------
174 // QUARTZ COM INTERFACES (dumped from quartz.idl from MSVC COM Browser)
175 //---------------------------------------------------------------------------
177 struct IAMOpenProgress
: public IUnknown
179 STDMETHOD(QueryProgress
)(LONGLONG
*pllTotal
, LONGLONG
*pllCurrent
) PURE
;
180 STDMETHOD(AbortOperation
)(void) PURE
;
183 struct IMediaEvent
: public IDispatch
185 STDMETHOD(GetEventHandle
)(LONG_PTR
*) PURE
;
186 STDMETHOD(GetEvent
)(long *, LONG_PTR
*, LONG_PTR
*, long) PURE
;
187 STDMETHOD(WaitForCompletion
)(long, long *) PURE
;
188 STDMETHOD(CancelDefaultHandling
)(long) PURE
;
189 STDMETHOD(RestoreDefaultHandling
)(long) PURE
;
190 STDMETHOD(FreeEventParams
)(long, LONG_PTR
, LONG_PTR
) PURE
;
193 //---------------------------------------------------------------------------
194 // ACTIVEMOVIE COM INTERFACES (dumped from amcompat.idl from MSVC COM Browser)
195 //---------------------------------------------------------------------------
197 enum ReadyStateConstants
199 amvUninitialized
= 0,
213 enum DisplayModeConstants
219 enum WindowSizeConstants
222 amvDoubleOriginalSize
= 1,
223 amvOneSixteenthScreen
= 2,
224 amvOneFourthScreen
= 3,
228 enum AppearanceConstants
234 enum BorderStyleConstants
240 struct IActiveMovie
: public IDispatch
242 STDMETHOD(AboutBox
)( void) PURE
;
243 STDMETHOD(Run
)( void) PURE
;
244 STDMETHOD(Pause
)( void) PURE
;
245 STDMETHOD(Stop
)( void) PURE
;
246 STDMETHOD(get_ImageSourceWidth
)(long __RPC_FAR
*pWidth
) PURE
;
247 STDMETHOD(get_ImageSourceHeight
)(long __RPC_FAR
*pHeight
) PURE
;
248 STDMETHOD(get_Author
)(BSTR __RPC_FAR
*pbstrAuthor
) PURE
;
249 STDMETHOD(get_Title
)(BSTR __RPC_FAR
*pbstrTitle
) PURE
;
250 STDMETHOD(get_Copyright
)(BSTR __RPC_FAR
*pbstrCopyright
) PURE
;
251 STDMETHOD(get_Description
)(BSTR __RPC_FAR
*pbstrDescription
) PURE
;
252 STDMETHOD(get_Rating
)(BSTR __RPC_FAR
*pbstrRating
) PURE
;
253 STDMETHOD(get_FileName
)(BSTR __RPC_FAR
*pbstrFileName
) PURE
;
254 STDMETHOD(put_FileName
)(BSTR pbstrFileName
) PURE
;
255 STDMETHOD(get_Duration
)(double __RPC_FAR
*pValue
) PURE
;
256 STDMETHOD(get_CurrentPosition
)(double __RPC_FAR
*pValue
) PURE
;
257 STDMETHOD(put_CurrentPosition
)(double pValue
) PURE
;
258 STDMETHOD(get_PlayCount
)(long __RPC_FAR
*pPlayCount
) PURE
;
259 STDMETHOD(put_PlayCount
)(long pPlayCount
) PURE
;
260 STDMETHOD(get_SelectionStart
)(double __RPC_FAR
*pValue
) PURE
;
261 STDMETHOD(put_SelectionStart
)(double pValue
) PURE
;
262 STDMETHOD(get_SelectionEnd
)(double __RPC_FAR
*pValue
) PURE
;
263 STDMETHOD(put_SelectionEnd
)(double pValue
) PURE
;
264 STDMETHOD(get_CurrentState
)(StateConstants __RPC_FAR
*pState
) PURE
;
265 STDMETHOD(get_Rate
)(double __RPC_FAR
*pValue
) PURE
;
266 STDMETHOD(put_Rate
)(double pValue
) PURE
;
267 STDMETHOD(get_Volume
)(long __RPC_FAR
*pValue
) PURE
;
268 STDMETHOD(put_Volume
)(long pValue
) PURE
;
269 STDMETHOD(get_Balance
)(long __RPC_FAR
*pValue
) PURE
;
270 STDMETHOD(put_Balance
)(long pValue
) PURE
;
271 STDMETHOD(get_EnableContextMenu
)(VARIANT_BOOL __RPC_FAR
*pEnable
) PURE
;
272 STDMETHOD(put_EnableContextMenu
)(VARIANT_BOOL pEnable
) PURE
;
273 STDMETHOD(get_ShowDisplay
)(VARIANT_BOOL __RPC_FAR
*Show
) PURE
;
274 STDMETHOD(put_ShowDisplay
)(VARIANT_BOOL Show
) PURE
;
275 STDMETHOD(get_ShowControls
)(VARIANT_BOOL __RPC_FAR
*Show
) PURE
;
276 STDMETHOD(put_ShowControls
)(VARIANT_BOOL Show
) PURE
;
277 STDMETHOD(get_ShowPositionControls
)(VARIANT_BOOL __RPC_FAR
*Show
) PURE
;
278 STDMETHOD(put_ShowPositionControls
)(VARIANT_BOOL Show
) PURE
;
279 STDMETHOD(get_ShowSelectionControls
)(VARIANT_BOOL __RPC_FAR
*Show
) PURE
;
280 STDMETHOD(put_ShowSelectionControls
)(VARIANT_BOOL Show
) PURE
;
281 STDMETHOD(get_ShowTracker
)(VARIANT_BOOL __RPC_FAR
*Show
) PURE
;
282 STDMETHOD(put_ShowTracker
)(VARIANT_BOOL Show
) PURE
;
283 STDMETHOD(get_EnablePositionControls
)(VARIANT_BOOL __RPC_FAR
*Enable
) PURE
;
284 STDMETHOD(put_EnablePositionControls
)(VARIANT_BOOL Enable
) PURE
;
285 STDMETHOD(get_EnableSelectionControls
)(VARIANT_BOOL __RPC_FAR
*Enable
) PURE
;
286 STDMETHOD(put_EnableSelectionControls
)(VARIANT_BOOL Enable
) PURE
;
287 STDMETHOD(get_EnableTracker
)(VARIANT_BOOL __RPC_FAR
*Enable
) PURE
;
288 STDMETHOD(put_EnableTracker
)(VARIANT_BOOL Enable
) PURE
;
289 STDMETHOD(get_AllowHideDisplay
)(VARIANT_BOOL __RPC_FAR
*Show
) PURE
;
290 STDMETHOD(put_AllowHideDisplay
)(VARIANT_BOOL Show
) PURE
;
291 STDMETHOD(get_AllowHideControls
)(VARIANT_BOOL __RPC_FAR
*Show
) PURE
;
292 STDMETHOD(put_AllowHideControls
)(VARIANT_BOOL Show
) PURE
;
293 STDMETHOD(get_DisplayMode
)(DisplayModeConstants __RPC_FAR
*pValue
) PURE
;
294 STDMETHOD(put_DisplayMode
)(DisplayModeConstants pValue
) PURE
;
295 STDMETHOD(get_AllowChangeDisplayMode
)(VARIANT_BOOL __RPC_FAR
*fAllow
) PURE
;
296 STDMETHOD(put_AllowChangeDisplayMode
)(VARIANT_BOOL fAllow
) PURE
;
297 STDMETHOD(get_FilterGraph
)(IUnknown __RPC_FAR
*__RPC_FAR
*ppFilterGraph
) PURE
;
298 STDMETHOD(put_FilterGraph
)(IUnknown __RPC_FAR
*ppFilterGraph
) PURE
;
299 STDMETHOD(get_FilterGraphDispatch
)(IDispatch __RPC_FAR
*__RPC_FAR
*pDispatch
) PURE
;
300 STDMETHOD(get_DisplayForeColor
)(unsigned long __RPC_FAR
*ForeColor
) PURE
;
301 STDMETHOD(put_DisplayForeColor
)(unsigned long ForeColor
) PURE
;
302 STDMETHOD(get_DisplayBackColor
)(unsigned long __RPC_FAR
*BackColor
) PURE
;
303 STDMETHOD(put_DisplayBackColor
)(unsigned long BackColor
) PURE
;
304 STDMETHOD(get_MovieWindowSize
)(WindowSizeConstants __RPC_FAR
*WindowSize
) PURE
;
305 STDMETHOD(put_MovieWindowSize
)(WindowSizeConstants WindowSize
) PURE
;
306 STDMETHOD(get_FullScreenMode
)(VARIANT_BOOL __RPC_FAR
*pEnable
) PURE
;
307 STDMETHOD(put_FullScreenMode
)(VARIANT_BOOL pEnable
) PURE
;
308 STDMETHOD(get_AutoStart
)(VARIANT_BOOL __RPC_FAR
*pEnable
) PURE
;
309 STDMETHOD(put_AutoStart
)(VARIANT_BOOL pEnable
) PURE
;
310 STDMETHOD(get_AutoRewind
)(VARIANT_BOOL __RPC_FAR
*pEnable
) PURE
;
311 STDMETHOD(put_AutoRewind
)(VARIANT_BOOL pEnable
) PURE
;
312 STDMETHOD(get_hWnd
)(long __RPC_FAR
*hWnd
) PURE
;
313 STDMETHOD(get_Appearance
)(AppearanceConstants __RPC_FAR
*pAppearance
) PURE
;
314 STDMETHOD(put_Appearance
)(AppearanceConstants pAppearance
) PURE
;
315 STDMETHOD(get_BorderStyle
)(BorderStyleConstants __RPC_FAR
*pBorderStyle
) PURE
;
316 STDMETHOD(put_BorderStyle
)(BorderStyleConstants pBorderStyle
) PURE
;
317 STDMETHOD(get_Enabled
)(VARIANT_BOOL __RPC_FAR
*pEnabled
) PURE
;
318 STDMETHOD(put_Enabled
)(VARIANT_BOOL pEnabled
) PURE
;
319 STDMETHOD(get_Info
)(long __RPC_FAR
*ppInfo
) PURE
;
324 struct IActiveMovie2
: public IActiveMovie
326 STDMETHOD(IsSoundCardEnabled
)(VARIANT_BOOL __RPC_FAR
*pbSoundCard
) PURE
;
327 STDMETHOD(get_ReadyState
)(ReadyStateConstants __RPC_FAR
*pValue
) PURE
;
330 struct IActiveMovie3
: public IActiveMovie2
332 STDMETHOD(get_MediaPlayer
)(IDispatch __RPC_FAR
*__RPC_FAR
*ppDispatch
) PURE
;
336 //---------------------------------------------------------------------------
337 // MEDIAPLAYER COM INTERFACES (dumped from msdxm.idl from MSVC COM Browser)
338 //---------------------------------------------------------------------------
340 enum MPPlayStateConstants
351 enum MPDisplaySizeConstants
358 mpOneSixteenthScreen
= 5,
359 mpOneFourthScreen
= 6,
363 enum MPReadyStateConstants
365 mpReadyStateUninitialized
= 0,
366 mpReadyStateLoading
= 1,
367 mpReadyStateInteractive
= 3,
368 mpReadyStateComplete
= 4
371 typedef unsigned long VB_OLE_COLOR
;
373 enum MPDisplayModeConstants
393 mpShowDescription
= 5,
398 mpClipCopyright
= 10,
400 mpClipDescription
= 12,
403 mpBannerMoreInfo
= 15,
407 enum DVDMenuIDConstants
411 dvdMenu_Subpicture
= 4,
417 enum MPShowDialogConstants
419 mpShowDialogHelp
= 0,
420 mpShowDialogStatistics
= 1,
421 mpShowDialogOptions
= 2,
422 mpShowDialogContextMenu
= 3
426 struct IMediaPlayer
: public IDispatch
428 STDMETHOD(get_CurrentPosition
)(double __RPC_FAR
*pCurrentPosition
) PURE
;
429 STDMETHOD(put_CurrentPosition
)(double pCurrentPosition
) PURE
;
430 STDMETHOD(get_Duration
)(double __RPC_FAR
*pDuration
) PURE
;
431 STDMETHOD(get_ImageSourceWidth
)(long __RPC_FAR
*pWidth
) PURE
;
432 STDMETHOD(get_ImageSourceHeight
)(long __RPC_FAR
*pHeight
) PURE
;
433 STDMETHOD(get_MarkerCount
)(long __RPC_FAR
*pMarkerCount
) PURE
;
434 STDMETHOD(get_CanScan
)(VARIANT_BOOL __RPC_FAR
*pCanScan
) PURE
;
435 STDMETHOD(get_CanSeek
)(VARIANT_BOOL __RPC_FAR
*pCanSeek
) PURE
;
436 STDMETHOD(get_CanSeekToMarkers
)(VARIANT_BOOL __RPC_FAR
*pCanSeekToMarkers
) PURE
;
437 STDMETHOD(get_CurrentMarker
)(long __RPC_FAR
*pCurrentMarker
) PURE
;
438 STDMETHOD(put_CurrentMarker
)(long pCurrentMarker
) PURE
;
439 STDMETHOD(get_FileName
)(BSTR __RPC_FAR
*pbstrFileName
) PURE
;
440 STDMETHOD(put_FileName
)(BSTR pbstrFileName
) PURE
;
441 STDMETHOD(get_SourceLink
)(BSTR __RPC_FAR
*pbstrSourceLink
) PURE
;
442 STDMETHOD(get_CreationDate
)(DATE __RPC_FAR
*pCreationDate
) PURE
;
443 STDMETHOD(get_ErrorCorrection
)(BSTR __RPC_FAR
*pbstrErrorCorrection
) PURE
;
444 STDMETHOD(get_Bandwidth
)(long __RPC_FAR
*pBandwidth
) PURE
;
445 STDMETHOD(get_SourceProtocol
)(long __RPC_FAR
*pSourceProtocol
) PURE
;
446 STDMETHOD(get_ReceivedPackets
)(long __RPC_FAR
*pReceivedPackets
) PURE
;
447 STDMETHOD(get_RecoveredPackets
)(long __RPC_FAR
*pRecoveredPackets
) PURE
;
448 STDMETHOD(get_LostPackets
)(long __RPC_FAR
*pLostPackets
) PURE
;
449 STDMETHOD(get_ReceptionQuality
)(long __RPC_FAR
*pReceptionQuality
) PURE
;
450 STDMETHOD(get_BufferingCount
)(long __RPC_FAR
*pBufferingCount
) PURE
;
451 STDMETHOD(get_IsBroadcast
)(VARIANT_BOOL __RPC_FAR
*pIsBroadcast
) PURE
;
452 STDMETHOD(get_BufferingProgress
)(long __RPC_FAR
*pBufferingProgress
) PURE
;
453 STDMETHOD(get_ChannelName
)(BSTR __RPC_FAR
*pbstrChannelName
) PURE
;
454 STDMETHOD(get_ChannelDescription
)(BSTR __RPC_FAR
*pbstrChannelDescription
) PURE
;
455 STDMETHOD(get_ChannelURL
)(BSTR __RPC_FAR
*pbstrChannelURL
) PURE
;
456 STDMETHOD(get_ContactAddress
)(BSTR __RPC_FAR
*pbstrContactAddress
) PURE
;
457 STDMETHOD(get_ContactPhone
)(BSTR __RPC_FAR
*pbstrContactPhone
) PURE
;
458 STDMETHOD(get_ContactEmail
)(BSTR __RPC_FAR
*pbstrContactEmail
) PURE
;
459 STDMETHOD(get_BufferingTime
)(double __RPC_FAR
*pBufferingTime
) PURE
;
460 STDMETHOD(put_BufferingTime
)(double pBufferingTime
) PURE
;
461 STDMETHOD(get_AutoStart
)(VARIANT_BOOL __RPC_FAR
*pAutoStart
) PURE
;
462 STDMETHOD(put_AutoStart
)(VARIANT_BOOL pAutoStart
) PURE
;
463 STDMETHOD(get_AutoRewind
)(VARIANT_BOOL __RPC_FAR
*pAutoRewind
) PURE
;
464 STDMETHOD(put_AutoRewind
)(VARIANT_BOOL pAutoRewind
) PURE
;
465 STDMETHOD(get_Rate
)(double __RPC_FAR
*pRate
) PURE
;
466 STDMETHOD(put_Rate
)(double pRate
) PURE
;
467 STDMETHOD(get_SendKeyboardEvents
)(VARIANT_BOOL __RPC_FAR
*pSendKeyboardEvents
) PURE
;
468 STDMETHOD(put_SendKeyboardEvents
)(VARIANT_BOOL pSendKeyboardEvents
) PURE
;
469 STDMETHOD(get_SendMouseClickEvents
)(VARIANT_BOOL __RPC_FAR
*pSendMouseClickEvents
) PURE
;
470 STDMETHOD(put_SendMouseClickEvents
)(VARIANT_BOOL pSendMouseClickEvents
) PURE
;
471 STDMETHOD(get_SendMouseMoveEvents
)(VARIANT_BOOL __RPC_FAR
*pSendMouseMoveEvents
) PURE
;
472 STDMETHOD(put_SendMouseMoveEvents
)(VARIANT_BOOL pSendMouseMoveEvents
) PURE
;
473 STDMETHOD(get_PlayCount
)(long __RPC_FAR
*pPlayCount
) PURE
;
474 STDMETHOD(put_PlayCount
)(long pPlayCount
) PURE
;
475 STDMETHOD(get_ClickToPlay
)(VARIANT_BOOL __RPC_FAR
*pClickToPlay
) PURE
;
476 STDMETHOD(put_ClickToPlay
)(VARIANT_BOOL pClickToPlay
) PURE
;
477 STDMETHOD(get_AllowScan
)(VARIANT_BOOL __RPC_FAR
*pAllowScan
) PURE
;
478 STDMETHOD(put_AllowScan
)(VARIANT_BOOL pAllowScan
) PURE
;
479 STDMETHOD(get_EnableContextMenu
)(VARIANT_BOOL __RPC_FAR
*pEnableContextMenu
) PURE
;
480 STDMETHOD(put_EnableContextMenu
)(VARIANT_BOOL pEnableContextMenu
) PURE
;
481 STDMETHOD(get_CursorType
)(long __RPC_FAR
*pCursorType
) PURE
;
482 STDMETHOD(put_CursorType
)(long pCursorType
) PURE
;
483 STDMETHOD(get_CodecCount
)(long __RPC_FAR
*pCodecCount
) PURE
;
484 STDMETHOD(get_AllowChangeDisplaySize
)(VARIANT_BOOL __RPC_FAR
*pAllowChangeDisplaySize
) PURE
;
485 STDMETHOD(put_AllowChangeDisplaySize
)( VARIANT_BOOL pAllowChangeDisplaySize
) PURE
;
486 STDMETHOD(get_IsDurationValid
)(VARIANT_BOOL __RPC_FAR
*pIsDurationValid
) PURE
;
487 STDMETHOD(get_OpenState
)(long __RPC_FAR
*pOpenState
) PURE
;
488 STDMETHOD(get_SendOpenStateChangeEvents
)(VARIANT_BOOL __RPC_FAR
*pSendOpenStateChangeEvents
) PURE
;
489 STDMETHOD(put_SendOpenStateChangeEvents
)(VARIANT_BOOL pSendOpenStateChangeEvents
) PURE
;
490 STDMETHOD(get_SendWarningEvents
)( VARIANT_BOOL __RPC_FAR
*pSendWarningEvents
) PURE
;
491 STDMETHOD(put_SendWarningEvents
)(VARIANT_BOOL pSendWarningEvents
) PURE
;
492 STDMETHOD(get_SendErrorEvents
)(VARIANT_BOOL __RPC_FAR
*pSendErrorEvents
) PURE
;
493 STDMETHOD(put_SendErrorEvents
)(VARIANT_BOOL pSendErrorEvents
) PURE
;
494 STDMETHOD(get_PlayState
)(MPPlayStateConstants __RPC_FAR
*pPlayState
) PURE
;
495 STDMETHOD(get_SendPlayStateChangeEvents
)(VARIANT_BOOL __RPC_FAR
*pSendPlayStateChangeEvents
) PURE
;
496 STDMETHOD(put_SendPlayStateChangeEvents
)(VARIANT_BOOL pSendPlayStateChangeEvents
) PURE
;
497 STDMETHOD(get_DisplaySize
)(MPDisplaySizeConstants __RPC_FAR
*pDisplaySize
) PURE
;
498 STDMETHOD(put_DisplaySize
)(MPDisplaySizeConstants pDisplaySize
) PURE
;
499 STDMETHOD(get_InvokeURLs
)(VARIANT_BOOL __RPC_FAR
*pInvokeURLs
) PURE
;
500 STDMETHOD(put_InvokeURLs
)(VARIANT_BOOL pInvokeURLs
) PURE
;
501 STDMETHOD(get_BaseURL
)(BSTR __RPC_FAR
*pbstrBaseURL
) PURE
;
502 STDMETHOD(put_BaseURL
)(BSTR pbstrBaseURL
) PURE
;
503 STDMETHOD(get_DefaultFrame
)(BSTR __RPC_FAR
*pbstrDefaultFrame
) PURE
;
504 STDMETHOD(put_DefaultFrame
)(BSTR pbstrDefaultFrame
) PURE
;
505 STDMETHOD(get_HasError
)(VARIANT_BOOL __RPC_FAR
*pHasError
) PURE
;
506 STDMETHOD(get_ErrorDescription
)(BSTR __RPC_FAR
*pbstrErrorDescription
) PURE
;
507 STDMETHOD(get_ErrorCode
)(long __RPC_FAR
*pErrorCode
) PURE
;
508 STDMETHOD(get_AnimationAtStart
)(VARIANT_BOOL __RPC_FAR
*pAnimationAtStart
) PURE
;
509 STDMETHOD(put_AnimationAtStart
)(VARIANT_BOOL pAnimationAtStart
) PURE
;
510 STDMETHOD(get_TransparentAtStart
)( VARIANT_BOOL __RPC_FAR
*pTransparentAtStart
) PURE
;
511 STDMETHOD(put_TransparentAtStart
)(VARIANT_BOOL pTransparentAtStart
) PURE
;
512 STDMETHOD(get_Volume
)(long __RPC_FAR
*pVolume
) PURE
;
513 STDMETHOD(put_Volume
)(long pVolume
) PURE
;
514 STDMETHOD(get_Balance
)(long __RPC_FAR
*pBalance
) PURE
;
515 STDMETHOD(put_Balance
)(long pBalance
) PURE
;
516 STDMETHOD(get_ReadyState
)(MPReadyStateConstants __RPC_FAR
*pValue
) PURE
;
517 STDMETHOD(get_SelectionStart
)(double __RPC_FAR
*pValue
) PURE
;
518 STDMETHOD(put_SelectionStart
)(double pValue
) PURE
;
519 STDMETHOD(get_SelectionEnd
)(double __RPC_FAR
*pValue
) PURE
;
520 STDMETHOD(put_SelectionEnd
)(double pValue
) PURE
;
521 STDMETHOD(get_ShowDisplay
)(VARIANT_BOOL __RPC_FAR
*Show
) PURE
;
522 STDMETHOD(put_ShowDisplay
)(VARIANT_BOOL Show
) PURE
;
523 STDMETHOD(get_ShowControls
)(VARIANT_BOOL __RPC_FAR
*Show
) PURE
;
524 STDMETHOD(put_ShowControls
)(VARIANT_BOOL Show
) PURE
;
525 STDMETHOD(get_ShowPositionControls
)(VARIANT_BOOL __RPC_FAR
*Show
) PURE
;
526 STDMETHOD(put_ShowPositionControls
)(VARIANT_BOOL Show
) PURE
;
527 STDMETHOD(get_ShowTracker
)(VARIANT_BOOL __RPC_FAR
*Show
) PURE
;
528 STDMETHOD(put_ShowTracker
)(VARIANT_BOOL Show
) PURE
;
529 STDMETHOD(get_EnablePositionControls
)(VARIANT_BOOL __RPC_FAR
*Enable
) PURE
;
530 STDMETHOD(put_EnablePositionControls
)(VARIANT_BOOL Enable
) PURE
;
531 STDMETHOD(get_EnableTracker
)(VARIANT_BOOL __RPC_FAR
*Enable
) PURE
;
532 STDMETHOD(put_EnableTracker
)(VARIANT_BOOL Enable
) PURE
;
533 STDMETHOD(get_Enabled
)(VARIANT_BOOL __RPC_FAR
*pEnabled
) PURE
;
534 STDMETHOD(put_Enabled
)(VARIANT_BOOL pEnabled
) PURE
;
535 STDMETHOD(get_DisplayForeColor
)(VB_OLE_COLOR __RPC_FAR
*ForeColor
) PURE
;
536 STDMETHOD(put_DisplayForeColor
)(VB_OLE_COLOR ForeColor
) PURE
;
537 STDMETHOD(get_DisplayBackColor
)(VB_OLE_COLOR __RPC_FAR
*BackColor
) PURE
;
538 STDMETHOD(put_DisplayBackColor
)(VB_OLE_COLOR BackColor
) PURE
;
539 STDMETHOD(get_DisplayMode
)(MPDisplayModeConstants __RPC_FAR
*pValue
) PURE
;
540 STDMETHOD(put_DisplayMode
)(MPDisplayModeConstants pValue
) PURE
;
541 STDMETHOD(get_VideoBorder3D
)(VARIANT_BOOL __RPC_FAR
*pVideoBorderWidth
) PURE
;
542 STDMETHOD(put_VideoBorder3D
)(VARIANT_BOOL pVideoBorderWidth
) PURE
;
543 STDMETHOD(get_VideoBorderWidth
)(long __RPC_FAR
*pVideoBorderWidth
) PURE
;
544 STDMETHOD(put_VideoBorderWidth
)(long pVideoBorderWidth
) PURE
;
545 STDMETHOD(get_VideoBorderColor
)(VB_OLE_COLOR __RPC_FAR
*pVideoBorderWidth
) PURE
;
546 STDMETHOD(put_VideoBorderColor
)(VB_OLE_COLOR pVideoBorderWidth
) PURE
;
547 STDMETHOD(get_ShowGotoBar
)(VARIANT_BOOL __RPC_FAR
*pbool
) PURE
;
548 STDMETHOD(put_ShowGotoBar
)(VARIANT_BOOL pbool
) PURE
;
549 STDMETHOD(get_ShowStatusBar
)(VARIANT_BOOL __RPC_FAR
*pbool
) PURE
;
550 STDMETHOD(put_ShowStatusBar
)(VARIANT_BOOL pbool
) PURE
;
551 STDMETHOD(get_ShowCaptioning
)(VARIANT_BOOL __RPC_FAR
*pbool
) PURE
;
552 STDMETHOD(put_ShowCaptioning
)(VARIANT_BOOL pbool
) PURE
;
553 STDMETHOD(get_ShowAudioControls
)(VARIANT_BOOL __RPC_FAR
*pbool
) PURE
;
554 STDMETHOD(put_ShowAudioControls
)(VARIANT_BOOL pbool
) PURE
;
555 STDMETHOD(get_CaptioningID
)( BSTR __RPC_FAR
*pstrText
) PURE
;
556 STDMETHOD(put_CaptioningID
)(BSTR pstrText
) PURE
;
557 STDMETHOD(get_Mute
)(VARIANT_BOOL __RPC_FAR
*vbool
) PURE
;
558 STDMETHOD(put_Mute
)(VARIANT_BOOL vbool
) PURE
;
559 STDMETHOD(get_CanPreview
)(VARIANT_BOOL __RPC_FAR
*pCanPreview
) PURE
;
560 STDMETHOD(get_PreviewMode
)(VARIANT_BOOL __RPC_FAR
*pPreviewMode
) PURE
;
561 STDMETHOD(put_PreviewMode
)(VARIANT_BOOL pPreviewMode
) PURE
;
562 STDMETHOD(get_HasMultipleItems
)(VARIANT_BOOL __RPC_FAR
*pHasMuliItems
) PURE
;
563 STDMETHOD(get_Language
)(long __RPC_FAR
*pLanguage
) PURE
;
564 STDMETHOD(put_Language
)(long pLanguage
) PURE
;
565 STDMETHOD(get_AudioStream
)(long __RPC_FAR
*pStream
) PURE
;
566 STDMETHOD(put_AudioStream
)(long pStream
) PURE
;
567 STDMETHOD(get_SAMIStyle
)(BSTR __RPC_FAR
*pbstrStyle
) PURE
;
568 STDMETHOD(put_SAMIStyle
)(BSTR pbstrStyle
) PURE
;
569 STDMETHOD(get_SAMILang
)(BSTR __RPC_FAR
*pbstrLang
) PURE
;
570 STDMETHOD(put_SAMILang
)(BSTR pbstrLang
) PURE
;
571 STDMETHOD(get_SAMIFileName
)(BSTR __RPC_FAR
*pbstrFileName
) PURE
;
572 STDMETHOD(put_SAMIFileName
)(BSTR pbstrFileName
) PURE
;
573 STDMETHOD(get_StreamCount
)( long __RPC_FAR
*pStreamCount
) PURE
;
574 STDMETHOD(get_ClientId
)(BSTR __RPC_FAR
*pbstrClientId
) PURE
;
575 STDMETHOD(get_ConnectionSpeed
)(long __RPC_FAR
*plConnectionSpeed
) PURE
;
576 STDMETHOD(get_AutoSize
)(VARIANT_BOOL __RPC_FAR
*pbool
) PURE
;
577 STDMETHOD(put_AutoSize
)(VARIANT_BOOL pbool
) PURE
;
578 STDMETHOD(get_EnableFullScreenControls
)(VARIANT_BOOL __RPC_FAR
*pbVal
) PURE
;
579 STDMETHOD(put_EnableFullScreenControls
)(VARIANT_BOOL pbVal
) PURE
;
580 STDMETHOD(get_ActiveMovie
)(IDispatch __RPC_FAR
*__RPC_FAR
*ppdispatch
) PURE
;
581 STDMETHOD(get_NSPlay
)(IDispatch __RPC_FAR
*__RPC_FAR
*ppdispatch
) PURE
;
582 STDMETHOD(get_WindowlessVideo
)(VARIANT_BOOL __RPC_FAR
*pbool
) PURE
;
583 STDMETHOD(put_WindowlessVideo
)(VARIANT_BOOL pbool
) PURE
;
584 STDMETHOD(Play
)(void) PURE
;
585 STDMETHOD(Stop
)(void) PURE
;
586 STDMETHOD(Pause
)(void) PURE
;
587 STDMETHOD(GetMarkerTime
)(long MarkerNum
,
588 double __RPC_FAR
*pMarkerTime
) PURE
;
589 STDMETHOD(GetMarkerName
)(long MarkerNum
,
590 BSTR __RPC_FAR
*pbstrMarkerName
) PURE
;
591 STDMETHOD(AboutBox
)(void) PURE
;
592 STDMETHOD(GetCodecInstalled
)(long CodecNum
,
593 VARIANT_BOOL __RPC_FAR
*pCodecInstalled
) PURE
;
594 STDMETHOD(GetCodecDescription
)(long CodecNum
,
595 BSTR __RPC_FAR
*pbstrCodecDescription
) PURE
;
596 STDMETHOD(GetCodecURL
)(long CodecNum
,
597 BSTR __RPC_FAR
*pbstrCodecURL
) PURE
;
598 STDMETHOD(GetMoreInfoURL
)(MPMoreInfoType MoreInfoType
,
599 BSTR __RPC_FAR
*pbstrMoreInfoURL
) PURE
;
600 STDMETHOD(GetMediaInfoString
)(MPMediaInfoType MediaInfoType
,
601 BSTR __RPC_FAR
*pbstrMediaInfo
) PURE
;
602 STDMETHOD(Cancel
)(void) PURE
;
603 STDMETHOD(Open
)(BSTR bstrFileName
) PURE
;
604 STDMETHOD(IsSoundCardEnabled
)(VARIANT_BOOL __RPC_FAR
*pbSoundCard
) PURE
;
605 STDMETHOD(Next
)(void) PURE
;
606 STDMETHOD(Previous
)(void) PURE
;
607 STDMETHOD(StreamSelect
)(long StreamNum
) PURE
;
608 STDMETHOD(FastForward
)(void) PURE
;
609 STDMETHOD(FastReverse
)(void) PURE
;
610 STDMETHOD(GetStreamName
)(long StreamNum
,
611 BSTR __RPC_FAR
*pbstrStreamName
) PURE
;
612 STDMETHOD(GetStreamGroup
)(long StreamNum
,
613 long __RPC_FAR
*pStreamGroup
) PURE
;
614 STDMETHOD(GetStreamSelected
)(long StreamNum
, VARIANT_BOOL __RPC_FAR
*pStreamSelected
) PURE
;
617 struct IMediaPlayer2
: public IMediaPlayer
619 STDMETHOD(get_DVD
)(struct IMediaPlayerDvd __RPC_FAR
*__RPC_FAR
*ppdispatch
) PURE
;
620 STDMETHOD(GetMediaParameter
)(long EntryNum
, BSTR bstrParameterName
, BSTR __RPC_FAR
*pbstrParameterValue
) PURE
;
621 STDMETHOD(GetMediaParameterName(long EntryNum
, long Index
, BSTR __RPC_FAR
*pbstrParameterName
) PURE
;
622 STDMETHOD(get_EntryCount
)(long __RPC_FAR
*pNumberEntries
) PURE
;
623 STDMETHOD(GetCurrentEntry
)(long __RPC_FAR
*pEntryNumber
) PURE
;
624 STDMETHOD(SetCurrentEntry
)(long EntryNumber
) PURE
;
625 STDMETHOD(ShowDialog
)(MPShowDialogConstants mpDialogIndex
) PURE
;
628 //---------------------------------------------------------------------------
629 // NETSHOW COM INTERFACES (dumped from nscompat.idl from MSVC COM Browser)
630 //---------------------------------------------------------------------------
632 struct INSOPlay
: public IDispatch
634 STDMETHOD(get_ImageSourceWidth
)(long __RPC_FAR
*pWidth
) PURE
;
635 STDMETHOD(get_ImageSourceHeight
)(long __RPC_FAR
*pHeight
) PURE
;
636 STDMETHOD(get_Duration
)(double __RPC_FAR
*pDuration
) PURE
;
637 STDMETHOD(get_Author
)(BSTR __RPC_FAR
*pbstrAuthor
) PURE
;
638 STDMETHOD(get_Copyright
)(BSTR __RPC_FAR
*pbstrCopyright
) PURE
;
639 STDMETHOD(get_Description
)(BSTR __RPC_FAR
*pbstrDescription
) PURE
;
640 STDMETHOD(get_Rating
)(BSTR __RPC_FAR
*pbstrRating
) PURE
;
641 STDMETHOD(get_Title
)(BSTR __RPC_FAR
*pbstrTitle
) PURE
;
642 STDMETHOD(get_SourceLink
)(BSTR __RPC_FAR
*pbstrSourceLink
) PURE
;
643 STDMETHOD(get_MarkerCount
)(long __RPC_FAR
*pMarkerCount
) PURE
;
644 STDMETHOD(get_CanScan
)(VARIANT_BOOL __RPC_FAR
*pCanScan
) PURE
;
645 STDMETHOD(get_CanSeek
)(VARIANT_BOOL __RPC_FAR
*pCanSeek
) PURE
;
646 STDMETHOD(get_CanSeekToMarkers
)(VARIANT_BOOL __RPC_FAR
*pCanSeekToMarkers
) PURE
;
647 STDMETHOD(get_CreationDate
)(DATE __RPC_FAR
*pCreationDate
) PURE
;
648 STDMETHOD(get_Bandwidth
)(long __RPC_FAR
*pBandwidth
) PURE
;
649 STDMETHOD(get_ErrorCorrection
)(BSTR __RPC_FAR
*pbstrErrorCorrection
) PURE
;
650 STDMETHOD(get_AutoStart
)(VARIANT_BOOL __RPC_FAR
*pAutoStart
) PURE
;
651 STDMETHOD(put_AutoStart
)(VARIANT_BOOL pAutoStart
) PURE
;
652 STDMETHOD(get_AutoRewind
)(VARIANT_BOOL __RPC_FAR
*pAutoRewind
) PURE
;
653 STDMETHOD(put_AutoRewind
)(VARIANT_BOOL pAutoRewind
) PURE
;
654 STDMETHOD(get_AllowChangeControlType
)(VARIANT_BOOL __RPC_FAR
*pAllowChangeControlType
) PURE
;
655 STDMETHOD(put_AllowChangeControlType
)(VARIANT_BOOL pAllowChangeControlType
) PURE
;
656 STDMETHOD(get_InvokeURLs
)(VARIANT_BOOL __RPC_FAR
*pInvokeURLs
) PURE
;
657 STDMETHOD(put_InvokeURLs
)(VARIANT_BOOL pInvokeURLs
) PURE
;
658 STDMETHOD(get_EnableContextMenu
)(VARIANT_BOOL __RPC_FAR
*pEnableContextMenu
) PURE
;
659 STDMETHOD(put_EnableContextMenu
)(VARIANT_BOOL pEnableContextMenu
) PURE
;
660 STDMETHOD(get_TransparentAtStart
)(VARIANT_BOOL __RPC_FAR
*pTransparentAtStart
) PURE
;
661 STDMETHOD(put_TransparentAtStart
)(VARIANT_BOOL pTransparentAtStart
) PURE
;
662 STDMETHOD(get_TransparentOnStop
)(VARIANT_BOOL __RPC_FAR
*pTransparentOnStop
) PURE
;
663 STDMETHOD(put_TransparentOnStop
)(VARIANT_BOOL pTransparentOnStop
) PURE
;
664 STDMETHOD(get_ClickToPlay
)(VARIANT_BOOL __RPC_FAR
*pClickToPlay
) PURE
;
665 STDMETHOD(put_ClickToPlay
)(VARIANT_BOOL pClickToPlay
) PURE
;
666 STDMETHOD(get_FileName
)(BSTR __RPC_FAR
*pbstrFileName
) PURE
;
667 STDMETHOD(put_FileName
)(BSTR pbstrFileName
) PURE
;
668 STDMETHOD(get_CurrentPosition
)(double __RPC_FAR
*pCurrentPosition
) PURE
;
669 STDMETHOD(put_CurrentPosition
)(double pCurrentPosition
) PURE
;
670 STDMETHOD(get_Rate
)(double __RPC_FAR
*pRate
) PURE
;
671 STDMETHOD(put_Rate
)(double pRate
) PURE
;
672 STDMETHOD(get_CurrentMarker
)(long __RPC_FAR
*pCurrentMarker
) PURE
;
673 STDMETHOD(put_CurrentMarker
)(long pCurrentMarker
) PURE
;
674 STDMETHOD(get_PlayCount
)(long __RPC_FAR
*pPlayCount
) PURE
;
675 STDMETHOD(put_PlayCount
)(long pPlayCount
) PURE
;
676 STDMETHOD(get_CurrentState
)(long __RPC_FAR
*pCurrentState
) PURE
;
677 STDMETHOD(get_DisplaySize
)(long __RPC_FAR
*pDisplaySize
) PURE
;
678 STDMETHOD(put_DisplaySize
)(long pDisplaySize
) PURE
;
679 STDMETHOD(get_MainWindow
)(long __RPC_FAR
*pMainWindow
) PURE
;
680 STDMETHOD(get_ControlType
)(long __RPC_FAR
*pControlType
) PURE
;
681 STDMETHOD(put_ControlType
)(long pControlType
) PURE
;
682 STDMETHOD(get_AllowScan
)(VARIANT_BOOL __RPC_FAR
*pAllowScan
) PURE
;
683 STDMETHOD(put_AllowScan
)(VARIANT_BOOL pAllowScan
) PURE
;
684 STDMETHOD(get_SendKeyboardEvents
)(VARIANT_BOOL __RPC_FAR
*pSendKeyboardEvents
) PURE
;
685 STDMETHOD(put_SendKeyboardEvents
)(VARIANT_BOOL pSendKeyboardEvents
) PURE
;
686 STDMETHOD(get_SendMouseClickEvents
)(VARIANT_BOOL __RPC_FAR
*pSendMouseClickEvents
) PURE
;
687 STDMETHOD(put_SendMouseClickEvents
)(VARIANT_BOOL pSendMouseClickEvents
) PURE
;
688 STDMETHOD(get_SendMouseMoveEvents
)(VARIANT_BOOL __RPC_FAR
*pSendMouseMoveEvents
) PURE
;
689 STDMETHOD(put_SendMouseMoveEvents
)(VARIANT_BOOL pSendMouseMoveEvents
) PURE
;
690 STDMETHOD(get_SendStateChangeEvents
)(VARIANT_BOOL __RPC_FAR
*pSendStateChangeEvents
) PURE
;
691 STDMETHOD(put_SendStateChangeEvents
)(VARIANT_BOOL pSendStateChangeEvents
) PURE
;
692 STDMETHOD(get_ReceivedPackets
)(long __RPC_FAR
*pReceivedPackets
) PURE
;
693 STDMETHOD(get_RecoveredPackets
)(long __RPC_FAR
*pRecoveredPackets
) PURE
;
694 STDMETHOD(get_LostPackets
)(long __RPC_FAR
*pLostPackets
) PURE
;
695 STDMETHOD(get_ReceptionQuality
)(long __RPC_FAR
*pReceptionQuality
) PURE
;
696 STDMETHOD(get_BufferingCount
)(long __RPC_FAR
*pBufferingCount
) PURE
;
697 STDMETHOD(get_CursorType
)(long __RPC_FAR
*pCursorType
) PURE
;
698 STDMETHOD(put_CursorType
)(long pCursorType
) PURE
;
699 STDMETHOD(get_AnimationAtStart
)(VARIANT_BOOL __RPC_FAR
*pAnimationAtStart
) PURE
;
700 STDMETHOD(put_AnimationAtStart
)(VARIANT_BOOL pAnimationAtStart
) PURE
;
701 STDMETHOD(get_AnimationOnStop
)(VARIANT_BOOL __RPC_FAR
*pAnimationOnStop
) PURE
;
702 STDMETHOD(put_AnimationOnStop
)(VARIANT_BOOL pAnimationOnStop
) PURE
;
703 STDMETHOD(Play
)(void) PURE
;
704 STDMETHOD(Pause
)(void) PURE
;
705 STDMETHOD(Stop
)(void) PURE
;
706 STDMETHOD(GetMarkerTime
)(long MarkerNum
, double __RPC_FAR
*pMarkerTime
) PURE
;
707 STDMETHOD(GetMarkerName
)(long MarkerNum
, BSTR __RPC_FAR
*pbstrMarkerName
) PURE
;
710 struct INSPlay
: public INSOPlay
712 STDMETHOD(get_ChannelName
)(BSTR __RPC_FAR
*pbstrChannelName
) PURE
;
713 STDMETHOD(get_ChannelDescription
)(BSTR __RPC_FAR
*pbstrChannelDescription
) PURE
;
714 STDMETHOD(get_ChannelURL
)(BSTR __RPC_FAR
*pbstrChannelURL
) PURE
;
715 STDMETHOD(get_ContactAddress
)(BSTR __RPC_FAR
*pbstrContactAddress
) PURE
;
716 STDMETHOD(get_ContactPhone
)(BSTR __RPC_FAR
*pbstrContactPhone
) PURE
;
717 STDMETHOD(get_ContactEmail
)(BSTR __RPC_FAR
*pbstrContactEmail
) PURE
;
718 STDMETHOD(get_AllowChangeDisplaySize
)(VARIANT_BOOL __RPC_FAR
*pAllowChangeDisplaySize
) PURE
;
719 STDMETHOD(put_AllowChangeDisplaySize
)(VARIANT_BOOL pAllowChangeDisplaySize
) PURE
;
720 STDMETHOD(get_CodecCount
)(long __RPC_FAR
*pCodecCount
) PURE
;
721 STDMETHOD(get_IsBroadcast
)(VARIANT_BOOL __RPC_FAR
*pIsBroadcast
) PURE
;
722 STDMETHOD(get_IsDurationValid
)(VARIANT_BOOL __RPC_FAR
*pIsDurationValid
) PURE
;
723 STDMETHOD(get_SourceProtocol
)(long __RPC_FAR
*pSourceProtocol
) PURE
;
724 STDMETHOD(get_OpenState
)(long __RPC_FAR
*pOpenState
) PURE
;
725 STDMETHOD(get_SendOpenStateChangeEvents
)(VARIANT_BOOL __RPC_FAR
*pSendOpenStateChangeEvents
) PURE
;
726 STDMETHOD(put_SendOpenStateChangeEvents
)(VARIANT_BOOL pSendOpenStateChangeEvents
) PURE
;
727 STDMETHOD(get_SendWarningEvents
)(VARIANT_BOOL __RPC_FAR
*pSendWarningEvents
) PURE
;
728 STDMETHOD(put_SendWarningEvents
)(VARIANT_BOOL pSendWarningEvents
) PURE
;
729 STDMETHOD(get_SendErrorEvents
)(VARIANT_BOOL __RPC_FAR
*pSendErrorEvents
) PURE
;
730 STDMETHOD(put_SendErrorEvents
)(VARIANT_BOOL pSendErrorEvents
) PURE
;
731 STDMETHOD(get_HasError
)(VARIANT_BOOL __RPC_FAR
*pHasError
) PURE
;
732 STDMETHOD(get_ErrorDescription
)(BSTR __RPC_FAR
*pbstrErrorDescription
) PURE
;
733 STDMETHOD(get_ErrorCode
)(long __RPC_FAR
*pErrorCode
) PURE
;
734 STDMETHOD(get_PlayState
)(long __RPC_FAR
*pPlayState
) PURE
;
735 STDMETHOD(get_SendPlayStateChangeEvents
)(VARIANT_BOOL __RPC_FAR
*pSendPlayStateChangeEvents
) PURE
;
736 STDMETHOD(put_SendPlayStateChangeEvents
)(VARIANT_BOOL pSendPlayStateChangeEvents
) PURE
;
737 STDMETHOD(get_BufferingTime
)(double __RPC_FAR
*pBufferingTime
) PURE
;
738 STDMETHOD(put_BufferingTime
)(double pBufferingTime
) PURE
;
739 STDMETHOD(get_UseFixedUDPPort
)(VARIANT_BOOL __RPC_FAR
*pUseFixedUDPPort
) PURE
;
740 STDMETHOD(put_UseFixedUDPPort
)(VARIANT_BOOL pUseFixedUDPPort
) PURE
;
741 STDMETHOD(get_FixedUDPPort
)(long __RPC_FAR
*pFixedUDPPort
) PURE
;
742 STDMETHOD(put_FixedUDPPort
)(long pFixedUDPPort
) PURE
;
743 STDMETHOD(get_UseHTTPProxy
)(VARIANT_BOOL __RPC_FAR
*pUseHTTPProxy
) PURE
;
744 STDMETHOD(put_UseHTTPProxy
)(VARIANT_BOOL pUseHTTPProxy
) PURE
;
745 STDMETHOD(get_EnableAutoProxy
)(VARIANT_BOOL __RPC_FAR
*pEnableAutoProxy
) PURE
;
746 STDMETHOD(put_EnableAutoProxy
)(VARIANT_BOOL pEnableAutoProxy
) PURE
;
747 STDMETHOD(get_HTTPProxyHost
)(BSTR __RPC_FAR
*pbstrHTTPProxyHost
) PURE
;
748 STDMETHOD(put_HTTPProxyHost
)(BSTR pbstrHTTPProxyHost
) PURE
;
749 STDMETHOD(get_HTTPProxyPort
)(long __RPC_FAR
*pHTTPProxyPort
) PURE
;
750 STDMETHOD(put_HTTPProxyPort
)(long pHTTPProxyPort
) PURE
;
751 STDMETHOD(get_EnableMulticast
)(VARIANT_BOOL __RPC_FAR
*pEnableMulticast
) PURE
;
752 STDMETHOD(put_EnableMulticast
)(VARIANT_BOOL pEnableMulticast
) PURE
;
753 STDMETHOD(get_EnableUDP
)(VARIANT_BOOL __RPC_FAR
*pEnableUDP
) PURE
;
754 STDMETHOD(put_EnableUDP
)(VARIANT_BOOL pEnableUDP
) PURE
;
755 STDMETHOD(get_EnableTCP
)(VARIANT_BOOL __RPC_FAR
*pEnableTCP
) PURE
;
756 STDMETHOD(put_EnableTCP
)(VARIANT_BOOL pEnableTCP
) PURE
;
757 STDMETHOD(get_EnableHTTP
)(VARIANT_BOOL __RPC_FAR
*pEnableHTTP
) PURE
;
758 STDMETHOD(put_EnableHTTP
)(VARIANT_BOOL pEnableHTTP
) PURE
;
759 STDMETHOD(get_BufferingProgress
)(long __RPC_FAR
*pBufferingProgress
) PURE
;
760 STDMETHOD(get_BaseURL
)(BSTR __RPC_FAR
*pbstrBaseURL
) PURE
;
761 STDMETHOD(put_BaseURL
)(BSTR pbstrBaseURL
) PURE
;
762 STDMETHOD(get_DefaultFrame
)(BSTR __RPC_FAR
*pbstrDefaultFrame
) PURE
;
763 STDMETHOD(put_DefaultFrame
)(BSTR pbstrDefaultFrame
) PURE
;
764 STDMETHOD(AboutBox
))(void) PURE
;
765 STDMETHOD(Cancel
)(void) PURE
;
766 STDMETHOD(GetCodecInstalled
)(long CodecNum
, VARIANT_BOOL __RPC_FAR
*pCodecInstalled
) PURE
;
767 STDMETHOD(GetCodecDescription
)(long CodecNum
, BSTR __RPC_FAR
*pbstrCodecDescription
) PURE
;
768 STDMETHOD(GetCodecURL
)(long CodecNum
, BSTR __RPC_FAR
*pbstrCodecURL
) PURE
;
769 STDMETHOD(Open
)(BSTR bstrFileName
) PURE
;
773 struct INSPlay1
: public INSPlay
775 STDMETHOD(get_MediaPlayer
)(IDispatch __RPC_FAR
*__RPC_FAR
*ppdispatch
) PURE
;
778 //---------------------------------------------------------------------------
779 // MISC COM INTERFACES
780 //---------------------------------------------------------------------------
781 typedef enum _FilterState
787 typedef enum _PinDirection
{
792 typedef struct _FilterInfo
{
794 struct IFilterGraph
*pGraph
;
797 typedef struct _PinInfo
{
798 struct IBaseFilter
*pFilter
;
806 typedef struct _MediaType
{
809 BOOL bFixedSizeSamples
;
810 BOOL bTemporalCompression
;
818 struct IFilterGraph
: public IUnknown
820 STDMETHOD(AddFilter
)(IBaseFilter
*, LPCWSTR
) PURE
;
821 STDMETHOD(RemoveFilter
)(IBaseFilter
*) PURE
;
822 STDMETHOD(EnumFilters
)(IEnumFilters
**) PURE
;
823 STDMETHOD(FindFilterByName
)(LPCWSTR
, IBaseFilter
**) PURE
;
824 STDMETHOD(ConnectDirect
)(IPin
*, IPin
*, const AM_MEDIA_TYPE
*) PURE
;
825 STDMETHOD(Reconnect
)(IPin
*) PURE
;
826 STDMETHOD(Disconnect
)(IPin
*) PURE
;
827 STDMETHOD(SetDefaultSyncSource
)() PURE
;
830 struct IGraphBuilder
: public IFilterGraph
832 STDMETHOD(Connect
)(IPin
*, IPin
*) PURE
;
833 STDMETHOD(Render
)(IPin
*) PURE
;
834 STDMETHOD(RenderFile
)(LPCWSTR
, LPCWSTR
) PURE
;
835 STDMETHOD(AddSourceFilter
)(LPCWSTR
, LPCWSTR
, IBaseFilter
**) PURE
;
836 STDMETHOD(SetLogFile
)(DWORD_PTR
) PURE
;
837 STDMETHOD(Abort
)() PURE
;
838 STDMETHOD(ShouldOperationContinue
)() PURE
;
841 struct IReferenceClock
;
843 #define REFERENCE_TIME LONGLONG
844 struct IMediaFilter
: public IPersist
846 STDMETHOD(Stop
)( void) PURE
;
847 STDMETHOD(Pause
)( void) PURE
;
848 STDMETHOD(Run
)(REFERENCE_TIME tStart
) PURE
;
849 STDMETHOD(GetState
)(DWORD dwMilliSecsTimeout
,
850 FILTER_STATE
*State
) PURE
;
851 STDMETHOD(SetSyncSource
)(IReferenceClock
*pClock
) PURE
;
852 STDMETHOD(GetSyncSource
)(IReferenceClock
**pClock
) PURE
;
855 struct IBaseFilter
: public IMediaFilter
857 STDMETHOD(EnumPins
)(IEnumPins
**ppEnum
) PURE
;
858 STDMETHOD(FindPin
)(LPCWSTR Id
, IPin
**ppPin
) PURE
;
859 STDMETHOD(QueryFilterInfo
)(FILTER_INFO
*pInfo
) PURE
;
860 STDMETHOD(JoinFilterGraph
)(IFilterGraph
*pGraph
, LPCWSTR pName
) PURE
;
861 STDMETHOD(QueryVendorInfo
)(LPWSTR
*pVendorInfo
) PURE
;
864 //---------------------------------------------------------------------------
866 // wxActiveX (Ryan Norton's version :))
867 // wxActiveX is (C) 2003 Lindsay Mathieson
869 //---------------------------------------------------------------------------
870 #define WX_DECLARE_AUTOOLE(wxAutoOleInterface, I) \
871 class wxAutoOleInterface \
877 explicit wxAutoOleInterface(I *pInterface = NULL) : m_interface(pInterface) {} \
878 wxAutoOleInterface(REFIID riid, IUnknown *pUnk) : m_interface(NULL) \
879 { QueryInterface(riid, pUnk); } \
880 wxAutoOleInterface(REFIID riid, IDispatch *pDispatch) : m_interface(NULL) \
881 { QueryInterface(riid, pDispatch); } \
882 wxAutoOleInterface(REFCLSID clsid, REFIID riid) : m_interface(NULL)\
883 { CreateInstance(clsid, riid); }\
884 wxAutoOleInterface(const wxAutoOleInterface& ti) : m_interface(NULL)\
885 { operator = (ti); }\
887 wxAutoOleInterface& operator = (const wxAutoOleInterface& ti)\
890 ti.m_interface->AddRef();\
892 m_interface = ti.m_interface;\
896 wxAutoOleInterface& operator = (I *&ti)\
903 ~wxAutoOleInterface() { Free(); }\
908 m_interface->Release();\
912 HRESULT QueryInterface(REFIID riid, IUnknown *pUnk)\
915 wxASSERT(pUnk != NULL);\
916 return pUnk->QueryInterface(riid, (void **) &m_interface);\
919 HRESULT CreateInstance(REFCLSID clsid, REFIID riid)\
922 return CoCreateInstance(clsid, NULL, CLSCTX_ALL, riid, (void **) &m_interface);\
925 inline operator I *() const {return m_interface;}\
926 inline I* operator ->() {return m_interface;}\
927 inline I** GetRef() {return &m_interface;}\
928 inline bool Ok() const {return m_interface != NULL;}\
931 WX_DECLARE_AUTOOLE(wxAutoIDispatch
, IDispatch
)
932 WX_DECLARE_AUTOOLE(wxAutoIOleClientSite
, IOleClientSite
)
933 WX_DECLARE_AUTOOLE(wxAutoIUnknown
, IUnknown
)
934 WX_DECLARE_AUTOOLE(wxAutoIOleObject
, IOleObject
)
935 WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceObject
, IOleInPlaceObject
)
936 WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceActiveObject
, IOleInPlaceActiveObject
)
937 WX_DECLARE_AUTOOLE(wxAutoIOleDocumentView
, IOleDocumentView
)
938 WX_DECLARE_AUTOOLE(wxAutoIViewObject
, IViewObject
)
939 WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceSite
, IOleInPlaceSite
)
940 WX_DECLARE_AUTOOLE(wxAutoIOleDocument
, IOleDocument
)
941 WX_DECLARE_AUTOOLE(wxAutoIPersistStreamInit
, IPersistStreamInit
)
942 WX_DECLARE_AUTOOLE(wxAutoIAdviseSink
, IAdviseSink
)
944 class wxActiveX
: public wxWindow
947 wxActiveX(wxWindow
* parent
, REFIID iid
, IUnknown
* pUnk
);
948 virtual ~wxActiveX();
950 void OnSize(wxSizeEvent
&);
951 void OnPaint(wxPaintEvent
&);
952 void OnSetFocus(wxFocusEvent
&);
953 void OnKillFocus(wxFocusEvent
&);
956 friend class FrameSite
;
958 wxAutoIDispatch m_Dispatch
;
959 wxAutoIOleClientSite m_clientSite
;
960 wxAutoIUnknown m_ActiveX
;
961 wxAutoIOleObject m_oleObject
;
962 wxAutoIOleInPlaceObject m_oleInPlaceObject
;
963 wxAutoIOleInPlaceActiveObject m_oleInPlaceActiveObject
;
964 wxAutoIOleDocumentView m_docView
;
965 wxAutoIViewObject m_viewObject
;
966 HWND m_oleObjectHWND
;
967 bool m_bAmbientUserMode
;
968 DWORD m_docAdviseCookie
;
969 wxWindow
* m_realparent
;
971 void CreateActiveX(REFIID
, IUnknown
*);
974 #define DECLARE_OLE_UNKNOWN(cls)\
980 TAutoInitInt() : l(0) {}\
982 TAutoInitInt refCount, lockCount;\
983 static void _GetInterface(cls *self, REFIID iid, void **_interface, const char *&desc);\
986 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject);\
987 ULONG STDMETHODCALLTYPE AddRef();\
988 ULONG STDMETHODCALLTYPE Release();\
989 ULONG STDMETHODCALLTYPE AddLock();\
990 ULONG STDMETHODCALLTYPE ReleaseLock()
992 #define DEFINE_OLE_TABLE(cls)\
993 LONG cls::GetRefCount() {return refCount.l;}\
994 HRESULT STDMETHODCALLTYPE cls::QueryInterface(REFIID iid, void ** ppvObject)\
1000 const char *desc = NULL;\
1001 cls::_GetInterface(this, iid, ppvObject, desc);\
1004 return E_NOINTERFACE;\
1006 ((IUnknown * )(*ppvObject))->AddRef();\
1009 ULONG STDMETHODCALLTYPE cls::AddRef()\
1011 InterlockedIncrement(&refCount.l);\
1014 ULONG STDMETHODCALLTYPE cls::Release()\
1016 if (refCount.l > 0)\
1018 InterlockedDecrement(&refCount.l);\
1019 if (refCount.l == 0)\
1029 ULONG STDMETHODCALLTYPE cls::AddLock()\
1031 InterlockedIncrement(&lockCount.l);\
1032 return lockCount.l;\
1034 ULONG STDMETHODCALLTYPE cls::ReleaseLock()\
1036 if (lockCount.l > 0)\
1038 InterlockedDecrement(&lockCount.l);\
1039 return lockCount.l;\
1044 DEFINE_OLE_BASE(cls)
1046 #define DEFINE_OLE_BASE(cls)\
1047 void cls::_GetInterface(cls *self, REFIID iid, void **_interface, const char *&desc)\
1049 *_interface = NULL;\
1052 #define OLE_INTERFACE(_iid, _type)\
1053 if (IsEqualIID(iid, _iid))\
1055 *_interface = (IUnknown *) (_type *) self;\
1060 #define OLE_IINTERFACE(_face) OLE_INTERFACE(IID_##_face, _face)
1062 #define OLE_INTERFACE_CUSTOM(func)\
1063 if (func(self, iid, _interface, desc))\
1068 #define END_OLE_TABLE\
1073 public IOleClientSite
,
1074 public IOleInPlaceSiteEx
,
1075 public IOleInPlaceFrame
,
1076 public IOleItemContainer
,
1078 public IOleCommandTarget
,
1079 public IOleDocumentSite
,
1081 public IOleControlSite
1084 DECLARE_OLE_UNKNOWN(FrameSite
);
1087 FrameSite(wxWindow
* win
, wxActiveX
* win2
)
1090 m_bSupportsWindowlessActivation
= true;
1091 m_bInPlaceLocked
= false;
1092 m_bUIActive
= false;
1093 m_bInPlaceActive
= false;
1094 m_bWindowless
= false;
1096 m_nAmbientLocale
= 0;
1097 m_clrAmbientForeColor
= ::GetSysColor(COLOR_WINDOWTEXT
);
1098 m_clrAmbientBackColor
= ::GetSysColor(COLOR_WINDOW
);
1099 m_bAmbientShowHatching
= true;
1100 m_bAmbientShowGrabHandles
= true;
1101 m_bAmbientAppearance
= true;
1104 m_hWndParent
= (HWND
)win
->GetHWND();
1106 virtual ~FrameSite(){}
1107 //***************************IDispatch*****************************
1108 HRESULT STDMETHODCALLTYPE
GetIDsOfNames(REFIID
, OLECHAR
** ,
1109 unsigned int , LCID
,
1111 { return E_NOTIMPL
; }
1112 STDMETHOD(GetTypeInfo
)(unsigned int, LCID
, ITypeInfo
**)
1113 { return E_NOTIMPL
; }
1114 HRESULT STDMETHODCALLTYPE
GetTypeInfoCount(unsigned int *)
1115 { return E_NOTIMPL
; }
1116 HRESULT STDMETHODCALLTYPE
Invoke(DISPID dispIdMember
, REFIID
, LCID
,
1117 WORD wFlags
, DISPPARAMS
*,
1118 VARIANT
* pVarResult
, EXCEPINFO
*,
1121 if (!(wFlags
& DISPATCH_PROPERTYGET
))
1124 if (pVarResult
== NULL
)
1125 return E_INVALIDARG
;
1127 //The most common case is boolean, use as an initial type
1128 V_VT(pVarResult
) = VT_BOOL
;
1130 switch (dispIdMember
)
1132 case DISPID_AMBIENT_MESSAGEREFLECT
:
1133 V_BOOL(pVarResult
)= FALSE
;
1136 case DISPID_AMBIENT_DISPLAYASDEFAULT
:
1137 V_BOOL(pVarResult
)= TRUE
;
1140 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
1141 V_BOOL(pVarResult
) = TRUE
;
1144 case DISPID_AMBIENT_SILENT
:
1145 V_BOOL(pVarResult
)= TRUE
;
1148 case DISPID_AMBIENT_APPEARANCE
:
1149 pVarResult
->vt
= VT_BOOL
;
1150 pVarResult
->boolVal
= m_bAmbientAppearance
;
1153 case DISPID_AMBIENT_FORECOLOR
:
1154 pVarResult
->vt
= VT_I4
;
1155 pVarResult
->lVal
= (long) m_clrAmbientForeColor
;
1158 case DISPID_AMBIENT_BACKCOLOR
:
1159 pVarResult
->vt
= VT_I4
;
1160 pVarResult
->lVal
= (long) m_clrAmbientBackColor
;
1163 case DISPID_AMBIENT_LOCALEID
:
1164 pVarResult
->vt
= VT_I4
;
1165 pVarResult
->lVal
= (long) m_nAmbientLocale
;
1168 case DISPID_AMBIENT_USERMODE
:
1169 pVarResult
->vt
= VT_BOOL
;
1170 pVarResult
->boolVal
= m_window
->m_bAmbientUserMode
;
1173 case DISPID_AMBIENT_SHOWGRABHANDLES
:
1174 pVarResult
->vt
= VT_BOOL
;
1175 pVarResult
->boolVal
= m_bAmbientShowGrabHandles
;
1178 case DISPID_AMBIENT_SHOWHATCHING
:
1179 pVarResult
->vt
= VT_BOOL
;
1180 pVarResult
->boolVal
= m_bAmbientShowHatching
;
1184 return DISP_E_MEMBERNOTFOUND
;
1190 //**************************IOleWindow***************************
1191 HRESULT STDMETHODCALLTYPE
GetWindow(HWND
* phwnd
)
1194 return E_INVALIDARG
;
1195 (*phwnd
) = m_hWndParent
;
1198 HRESULT STDMETHODCALLTYPE
ContextSensitiveHelp(BOOL
)
1200 //**************************IOleInPlaceUIWindow*****************
1201 HRESULT STDMETHODCALLTYPE
GetBorder(LPRECT lprectBorder
)
1203 if (lprectBorder
== NULL
)
1204 return E_INVALIDARG
;
1205 return INPLACE_E_NOTOOLSPACE
;
1207 HRESULT STDMETHODCALLTYPE
RequestBorderSpace(LPCBORDERWIDTHS pborderwidths
)
1209 if (pborderwidths
== NULL
)
1210 return E_INVALIDARG
;
1211 return INPLACE_E_NOTOOLSPACE
;
1213 HRESULT STDMETHODCALLTYPE
SetBorderSpace(LPCBORDERWIDTHS
)
1215 HRESULT STDMETHODCALLTYPE
SetActiveObject(
1216 IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR
)
1219 pActiveObject
->AddRef();
1221 m_window
->m_oleInPlaceActiveObject
= pActiveObject
;
1225 //********************IOleInPlaceFrame************************
1227 STDMETHOD(InsertMenus
)(HMENU
, LPOLEMENUGROUPWIDTHS
){return S_OK
;}
1228 STDMETHOD(SetMenu
)(HMENU
, HOLEMENU
, HWND
){ return S_OK
;}
1229 STDMETHOD(RemoveMenus
)(HMENU
){return S_OK
;}
1230 STDMETHOD(SetStatusText
)(LPCOLESTR
){ return S_OK
;}
1231 HRESULT STDMETHODCALLTYPE
EnableModeless(BOOL
){return S_OK
;}
1232 HRESULT STDMETHODCALLTYPE
TranslateAccelerator(LPMSG lpmsg
, WORD
)
1234 // TODO: send an event with this id
1235 if (m_window
->m_oleInPlaceActiveObject
.Ok())
1236 m_window
->m_oleInPlaceActiveObject
->TranslateAccelerator(lpmsg
);
1240 //*******************IOleInPlaceSite**************************
1241 HRESULT STDMETHODCALLTYPE
CanInPlaceActivate(){return S_OK
;}
1242 HRESULT STDMETHODCALLTYPE
OnInPlaceActivate()
1243 { m_bInPlaceActive
= true; return S_OK
; }
1244 HRESULT STDMETHODCALLTYPE
OnUIActivate()
1245 { m_bUIActive
= true; return S_OK
; }
1246 HRESULT STDMETHODCALLTYPE
GetWindowContext(IOleInPlaceFrame
**ppFrame
,
1247 IOleInPlaceUIWindow
**ppDoc
,
1249 LPRECT lprcClipRect
,
1250 LPOLEINPLACEFRAMEINFO lpFrameInfo
)
1252 if (ppFrame
== NULL
|| ppDoc
== NULL
|| lprcPosRect
== NULL
||
1253 lprcClipRect
== NULL
|| lpFrameInfo
== NULL
)
1255 if (ppFrame
!= NULL
)
1259 return E_INVALIDARG
;
1262 HRESULT hr
= QueryInterface(IID_IOleInPlaceFrame
, (void **) ppFrame
);
1263 if (! SUCCEEDED(hr
))
1265 return E_UNEXPECTED
;
1268 hr
= QueryInterface(IID_IOleInPlaceUIWindow
, (void **) ppDoc
);
1269 if (! SUCCEEDED(hr
))
1271 (*ppFrame
)->Release();
1273 return E_UNEXPECTED
;
1277 ::GetClientRect(m_hWndParent
, &rect
);
1280 lprcPosRect
->left
= lprcPosRect
->top
= 0;
1281 lprcPosRect
->right
= rect
.right
;
1282 lprcPosRect
->bottom
= rect
.bottom
;
1286 lprcClipRect
->left
= lprcClipRect
->top
= 0;
1287 lprcClipRect
->right
= rect
.right
;
1288 lprcClipRect
->bottom
= rect
.bottom
;
1291 memset(lpFrameInfo
, 0, sizeof(OLEINPLACEFRAMEINFO
));
1292 lpFrameInfo
->cb
= sizeof(OLEINPLACEFRAMEINFO
);
1293 lpFrameInfo
->hwndFrame
= m_hWndParent
;
1297 HRESULT STDMETHODCALLTYPE
Scroll(SIZE
){return S_OK
;}
1298 HRESULT STDMETHODCALLTYPE
OnUIDeactivate(BOOL
)
1299 { m_bUIActive
= false; return S_OK
; }
1300 HRESULT STDMETHODCALLTYPE
OnInPlaceDeactivate()
1301 { m_bInPlaceActive
= false; return S_OK
; }
1302 HRESULT STDMETHODCALLTYPE
DiscardUndoState(){return S_OK
;}
1303 HRESULT STDMETHODCALLTYPE
DeactivateAndUndo(){return S_OK
; }
1304 HRESULT STDMETHODCALLTYPE
OnPosRectChange(LPCRECT lprcPosRect
)
1306 if (m_window
->m_oleInPlaceObject
.Ok() && lprcPosRect
)
1308 m_window
->m_oleInPlaceObject
->SetObjectRects(
1309 lprcPosRect
, lprcPosRect
);
1313 //*************************IOleInPlaceSiteEx***********************
1314 HRESULT STDMETHODCALLTYPE
OnInPlaceActivateEx(BOOL
* pfNoRedraw
, DWORD
)
1316 OleLockRunning(m_window
->m_ActiveX
, TRUE
, FALSE
);
1318 (*pfNoRedraw
) = FALSE
;
1322 HRESULT STDMETHODCALLTYPE
OnInPlaceDeactivateEx(BOOL
)
1324 OleLockRunning(m_window
->m_ActiveX
, FALSE
, FALSE
);
1327 STDMETHOD(RequestUIActivate
)(){ return S_OK
;}
1328 //*************************IOleClientSite**************************
1329 HRESULT STDMETHODCALLTYPE
SaveObject(){return S_OK
;}
1330 const char *OleGetMonikerToStr(DWORD dwAssign
)
1334 case OLEGETMONIKER_ONLYIFTHERE
: return "OLEGETMONIKER_ONLYIFTHERE";
1335 case OLEGETMONIKER_FORCEASSIGN
: return "OLEGETMONIKER_FORCEASSIGN";
1336 case OLEGETMONIKER_UNASSIGN
: return "OLEGETMONIKER_UNASSIGN";
1337 case OLEGETMONIKER_TEMPFORUSER
: return "OLEGETMONIKER_TEMPFORUSER";
1338 default : return "Bad Enum";
1342 const char *OleGetWhicMonikerStr(DWORD dwWhichMoniker
)
1344 switch(dwWhichMoniker
)
1346 case OLEWHICHMK_CONTAINER
: return "OLEWHICHMK_CONTAINER";
1347 case OLEWHICHMK_OBJREL
: return "OLEWHICHMK_OBJREL";
1348 case OLEWHICHMK_OBJFULL
: return "OLEWHICHMK_OBJFULL";
1349 default : return "Bad Enum";
1352 STDMETHOD(GetMoniker
)(DWORD
, DWORD
, IMoniker
**){return E_FAIL
;}
1353 HRESULT STDMETHODCALLTYPE
GetContainer(LPOLECONTAINER
* ppContainer
)
1355 if (ppContainer
== NULL
)
1356 return E_INVALIDARG
;
1357 HRESULT hr
= QueryInterface(
1358 IID_IOleContainer
, (void**)(ppContainer
));
1359 wxASSERT(SUCCEEDED(hr
));
1362 HRESULT STDMETHODCALLTYPE
ShowObject()
1364 if (m_window
->m_oleObjectHWND
)
1365 ::ShowWindow(m_window
->m_oleObjectHWND
, SW_SHOW
);
1368 STDMETHOD(OnShowWindow
)(BOOL
){return S_OK
;}
1369 STDMETHOD(RequestNewObjectLayout
)(){return E_NOTIMPL
;}
1370 //********************IParseDisplayName***************************
1371 HRESULT STDMETHODCALLTYPE
ParseDisplayName(
1372 IBindCtx
*, LPOLESTR
, ULONG
*, IMoniker
**){return E_NOTIMPL
;}
1373 //********************IOleContainer*******************************
1374 STDMETHOD(EnumObjects
)(DWORD
, IEnumUnknown
**){return E_NOTIMPL
;}
1375 HRESULT STDMETHODCALLTYPE
LockContainer(BOOL
){return S_OK
;}
1376 //********************IOleItemContainer***************************
1377 HRESULT STDMETHODCALLTYPE
1383 (LPOLESTR pszItem
, DWORD
, IBindCtx
*, REFIID
, void ** ppvObject
)
1385 if (pszItem
== NULL
|| ppvObject
== NULL
)
1386 return E_INVALIDARG
;
1388 return MK_E_NOOBJECT
;
1390 HRESULT STDMETHODCALLTYPE
GetObjectStorage(
1391 LPOLESTR pszItem
, IBindCtx
* , REFIID
, void ** ppvStorage
)
1393 if (pszItem
== NULL
|| ppvStorage
== NULL
)
1394 return E_INVALIDARG
;
1396 return MK_E_NOOBJECT
;
1398 HRESULT STDMETHODCALLTYPE
IsRunning(LPOLESTR pszItem
)
1400 if (pszItem
== NULL
)
1401 return E_INVALIDARG
;
1402 return MK_E_NOOBJECT
;
1404 //***********************IOleControlSite*****************************
1405 HRESULT STDMETHODCALLTYPE
OnControlInfoChanged()
1407 HRESULT STDMETHODCALLTYPE
LockInPlaceActive(BOOL fLock
)
1409 m_bInPlaceLocked
= (fLock
) ? true : false;
1412 HRESULT STDMETHODCALLTYPE
GetExtendedControl(IDispatch
**)
1414 HRESULT STDMETHODCALLTYPE
TransformCoords(
1415 POINTL
* pPtlHimetric
, POINTF
* pPtfContainer
, DWORD
)
1417 if (pPtlHimetric
== NULL
|| pPtfContainer
== NULL
)
1418 return E_INVALIDARG
;
1421 HRESULT STDMETHODCALLTYPE
TranslateAccelerator(LPMSG
, DWORD
)
1423 HRESULT STDMETHODCALLTYPE
OnFocus(BOOL
){return S_OK
;}
1424 HRESULT STDMETHODCALLTYPE
ShowPropertyFrame(){return E_NOTIMPL
;}
1425 //**************************IOleCommandTarget***********************
1426 HRESULT STDMETHODCALLTYPE
QueryStatus(const GUID
*, ULONG cCmds
,
1427 OLECMD prgCmds
[], OLECMDTEXT
*)
1429 if (prgCmds
== NULL
) return E_INVALIDARG
;
1430 for (ULONG nCmd
= 0; nCmd
< cCmds
; nCmd
++)
1432 // unsupported by default
1433 prgCmds
[nCmd
].cmdf
= 0;
1435 return OLECMDERR_E_UNKNOWNGROUP
;
1438 HRESULT STDMETHODCALLTYPE
Exec(const GUID
*, DWORD
,
1439 DWORD
, VARIANTARG
*, VARIANTARG
*)
1440 {return OLECMDERR_E_NOTSUPPORTED
;}
1442 //**********************IAdviseSink************************************
1443 void STDMETHODCALLTYPE
OnDataChange(FORMATETC
*, STGMEDIUM
*) {}
1444 void STDMETHODCALLTYPE
OnViewChange(DWORD
, LONG
) {}
1445 void STDMETHODCALLTYPE
OnRename(IMoniker
*){}
1446 void STDMETHODCALLTYPE
OnSave(){}
1447 void STDMETHODCALLTYPE
OnClose(){}
1449 //**********************IOleDocumentSite***************************
1450 HRESULT STDMETHODCALLTYPE
ActivateMe(
1451 IOleDocumentView __RPC_FAR
*pViewToActivate
)
1453 wxAutoIOleInPlaceSite
inPlaceSite(
1454 IID_IOleInPlaceSite
, (IDispatch
*) this);
1455 if (!inPlaceSite
.Ok())
1458 if (pViewToActivate
)
1460 m_window
->m_docView
= pViewToActivate
;
1461 m_window
->m_docView
->SetInPlaceSite(inPlaceSite
);
1465 wxAutoIOleDocument
oleDoc(
1466 IID_IOleDocument
, m_window
->m_oleObject
);
1470 HRESULT hr
= oleDoc
->CreateView(inPlaceSite
, NULL
,
1471 0, m_window
->m_docView
.GetRef());
1475 m_window
->m_docView
->SetInPlaceSite(inPlaceSite
);
1478 m_window
->m_docView
->UIActivate(TRUE
);
1484 wxActiveX
* m_window
;
1489 bool m_bSupportsWindowlessActivation
;
1490 bool m_bInPlaceLocked
;
1491 bool m_bInPlaceActive
;
1495 LCID m_nAmbientLocale
;
1496 COLORREF m_clrAmbientForeColor
;
1497 COLORREF m_clrAmbientBackColor
;
1498 bool m_bAmbientShowHatching
;
1499 bool m_bAmbientShowGrabHandles
;
1500 bool m_bAmbientAppearance
;
1503 DEFINE_OLE_TABLE(FrameSite
)
1504 OLE_INTERFACE(IID_IUnknown
, IOleClientSite
)
1505 OLE_IINTERFACE(IOleClientSite
)
1506 OLE_INTERFACE(IID_IOleWindow
, IOleInPlaceSite
)
1507 OLE_IINTERFACE(IOleInPlaceSite
)
1508 OLE_IINTERFACE(IOleInPlaceSiteEx
)
1509 OLE_IINTERFACE(IOleInPlaceUIWindow
)
1510 OLE_IINTERFACE(IOleInPlaceFrame
)
1511 OLE_IINTERFACE(IParseDisplayName
)
1512 OLE_IINTERFACE(IOleContainer
)
1513 OLE_IINTERFACE(IOleItemContainer
)
1514 OLE_IINTERFACE(IDispatch
)
1515 OLE_IINTERFACE(IOleCommandTarget
)
1516 OLE_IINTERFACE(IOleDocumentSite
)
1517 OLE_IINTERFACE(IAdviseSink
)
1518 OLE_IINTERFACE(IOleControlSite
)
1522 wxActiveX::wxActiveX(wxWindow
* parent
, REFIID iid
, IUnknown
* pUnk
)
1523 : m_realparent(parent
)
1525 m_bAmbientUserMode
= true;
1526 m_docAdviseCookie
= 0;
1527 CreateActiveX(iid
, pUnk
);
1530 wxActiveX::~wxActiveX()
1532 // disconnect connection points
1533 if (m_oleInPlaceObject
.Ok())
1535 m_oleInPlaceObject
->InPlaceDeactivate();
1536 m_oleInPlaceObject
->UIDeactivate();
1539 if (m_oleObject
.Ok())
1541 if (m_docAdviseCookie
!= 0)
1542 m_oleObject
->Unadvise(m_docAdviseCookie
);
1544 m_oleObject
->DoVerb(
1545 OLEIVERB_HIDE
, NULL
, m_clientSite
, 0, (HWND
) GetHWND(), NULL
);
1546 m_oleObject
->Close(OLECLOSE_NOSAVE
);
1547 m_oleObject
->SetClientSite(NULL
);
1551 void wxActiveX::CreateActiveX(REFIID iid
, IUnknown
* pUnk
)
1554 hret
= m_ActiveX
.QueryInterface(iid
, pUnk
);
1555 wxASSERT(SUCCEEDED(hret
));
1558 FrameSite
*frame
= new FrameSite(m_realparent
, this);
1560 hret
= m_clientSite
.QueryInterface(
1561 IID_IOleClientSite
, (IDispatch
*) frame
);
1562 wxASSERT(SUCCEEDED(hret
));
1564 wxAutoIAdviseSink
adviseSink(IID_IAdviseSink
, (IDispatch
*) frame
);
1565 wxASSERT(adviseSink
.Ok());
1567 // Get Dispatch interface
1568 hret
= m_Dispatch
.QueryInterface(IID_IDispatch
, m_ActiveX
);
1570 // Get IOleObject interface
1571 hret
= m_oleObject
.QueryInterface(IID_IOleObject
, m_ActiveX
);
1572 wxASSERT(SUCCEEDED(hret
));
1574 // get IViewObject Interface
1575 hret
= m_viewObject
.QueryInterface(IID_IViewObject
, m_ActiveX
);
1576 wxASSERT(SUCCEEDED(hret
));
1579 m_docAdviseCookie
= 0;
1580 hret
= m_oleObject
->Advise(adviseSink
, &m_docAdviseCookie
);
1581 m_oleObject
->SetHostNames(L
"wxActiveXContainer", NULL
);
1582 OleSetContainedObject(m_oleObject
, TRUE
);
1583 OleRun(m_oleObject
);
1586 // Get IOleInPlaceObject interface
1587 hret
= m_oleInPlaceObject
.QueryInterface(
1588 IID_IOleInPlaceObject
, m_ActiveX
);
1589 wxASSERT(SUCCEEDED(hret
));
1593 m_oleObject
->GetMiscStatus(DVASPECT_CONTENT
, &dwMiscStatus
);
1594 wxASSERT(SUCCEEDED(hret
));
1596 // set client site first ?
1597 if (dwMiscStatus
& OLEMISC_SETCLIENTSITEFIRST
)
1598 m_oleObject
->SetClientSite(m_clientSite
);
1602 wxAutoIPersistStreamInit
1603 pPersistStreamInit(IID_IPersistStreamInit
, m_oleObject
);
1605 if (pPersistStreamInit
.Ok())
1607 hret
= pPersistStreamInit
->InitNew();
1610 if (! (dwMiscStatus
& OLEMISC_SETCLIENTSITEFIRST
))
1611 m_oleObject
->SetClientSite(m_clientSite
);
1615 ::GetClientRect((HWND
)m_realparent
->GetHWND(), &posRect
);
1617 m_oleObjectHWND
= 0;
1619 if (m_oleInPlaceObject
.Ok())
1621 hret
= m_oleInPlaceObject
->GetWindow(&m_oleObjectHWND
);
1622 if (SUCCEEDED(hret
))
1623 ::SetActiveWindow(m_oleObjectHWND
);
1627 if (! (dwMiscStatus
& OLEMISC_INVISIBLEATRUNTIME
))
1629 if (posRect
.right
> 0 && posRect
.bottom
> 0 &&
1630 m_oleInPlaceObject
.Ok())
1631 m_oleInPlaceObject
->SetObjectRects(&posRect
, &posRect
);
1633 hret
= m_oleObject
->DoVerb(OLEIVERB_INPLACEACTIVATE
, NULL
,
1634 m_clientSite
, 0, (HWND
)m_realparent
->GetHWND(), &posRect
);
1635 hret
= m_oleObject
->DoVerb(OLEIVERB_SHOW
, 0, m_clientSite
, 0,
1636 (HWND
)m_realparent
->GetHWND(), &posRect
);
1639 if (! m_oleObjectHWND
&& m_oleInPlaceObject
.Ok())
1641 hret
= m_oleInPlaceObject
->GetWindow(&m_oleObjectHWND
);
1644 if (m_oleObjectHWND
)
1646 ::SetActiveWindow(m_oleObjectHWND
);
1647 ::ShowWindow(m_oleObjectHWND
, SW_SHOW
);
1649 this->AssociateHandle(m_oleObjectHWND
);
1650 this->Reparent(m_realparent
);
1652 wxWindow
* pWnd
= m_realparent
;
1653 int id
= m_realparent
->GetId();
1655 pWnd
->Connect(id
, wxEVT_SIZE
,
1656 wxSizeEventHandler(wxActiveX::OnSize
), 0, this);
1657 pWnd
->Connect(id
, wxEVT_SET_FOCUS
,
1658 wxFocusEventHandler(wxActiveX::OnSetFocus
), 0, this);
1659 pWnd
->Connect(id
, wxEVT_KILL_FOCUS
,
1660 wxFocusEventHandler(wxActiveX::OnKillFocus
), 0, this);
1664 #define HIMETRIC_PER_INCH 2540
1665 #define MAP_PIX_TO_LOGHIM(x,ppli) MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
1667 static void PixelsToHimetric(SIZEL
&sz
)
1669 static int logX
= 0;
1670 static int logY
= 0;
1675 HDC dc
= GetDC(NULL
);
1676 logX
= GetDeviceCaps(dc
, LOGPIXELSX
);
1677 logY
= GetDeviceCaps(dc
, LOGPIXELSY
);
1678 ReleaseDC(NULL
, dc
);
1681 #define HIMETRIC_INCH 2540
1682 #define CONVERT(x, logpixels) MulDiv(HIMETRIC_INCH, (x), (logpixels))
1684 sz
.cx
= CONVERT(sz
.cx
, logX
);
1685 sz
.cy
= CONVERT(sz
.cy
, logY
);
1688 #undef HIMETRIC_INCH
1692 void wxActiveX::OnSize(wxSizeEvent
& event
)
1695 GetParent()->GetClientSize(&w
, &h
);
1703 if (w
<= 0 && h
<= 0)
1706 // extents are in HIMETRIC units
1707 if (m_oleObject
.Ok())
1710 PixelsToHimetric(sz
);
1714 m_oleObject
->GetExtent(DVASPECT_CONTENT
, &sz2
);
1715 if (sz2
.cx
!= sz
.cx
|| sz
.cy
!= sz2
.cy
)
1716 m_oleObject
->SetExtent(DVASPECT_CONTENT
, &sz
);
1719 if (m_oleInPlaceObject
.Ok())
1720 m_oleInPlaceObject
->SetObjectRects(&posRect
, &posRect
);
1725 void wxActiveX::OnPaint(wxPaintEvent
& WXUNUSED(event
))
1728 // Draw only when control is windowless or deactivated
1733 GetParent()->GetSize(&w
, &h
);
1740 ::RedrawWindow(m_oleObjectHWND
, NULL
, NULL
, RDW_INTERNALPAINT
);
1741 RECTL
*prcBounds
= (RECTL
*) &posRect
;
1742 m_viewObject
->Draw(DVASPECT_CONTENT
, -1, NULL
, NULL
, NULL
,
1743 (HDC
)dc
.GetHDC(), prcBounds
, NULL
, NULL
, 0);
1748 // We've got this one I think
1752 void wxActiveX::OnSetFocus(wxFocusEvent
& event
)
1754 if (m_oleInPlaceActiveObject
.Ok())
1755 m_oleInPlaceActiveObject
->OnFrameWindowActivate(TRUE
);
1760 void wxActiveX::OnKillFocus(wxFocusEvent
& event
)
1762 if (m_oleInPlaceActiveObject
.Ok())
1763 m_oleInPlaceActiveObject
->OnFrameWindowActivate(FALSE
);
1768 //###########################################################################
1774 //###########################################################################
1776 typedef BOOL (WINAPI
* LPAMGETERRORTEXT
)(HRESULT
, wxChar
*, DWORD
);
1778 //cludgy workaround for wx events. slots would be nice :)
1779 class WXDLLIMPEXP_MEDIA wxAMMediaEvtHandler
: public wxEvtHandler
1782 void OnPaint(wxPaintEvent
&);
1783 void OnEraseBackground(wxEraseEvent
&);
1786 class WXDLLIMPEXP_MEDIA wxAMMediaBackend
: public wxMediaBackend
1790 virtual ~wxAMMediaBackend();
1793 virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
1798 const wxValidator
& validator
,
1799 const wxString
& name
);
1801 virtual bool Play();
1802 virtual bool Pause();
1803 virtual bool Stop();
1805 virtual bool Load(const wxString
& fileName
);
1806 virtual bool Load(const wxURI
& location
);
1807 virtual bool Load(const wxURI
& location
, const wxURI
& proxy
);
1809 bool DoLoad(const wxString
& location
);
1812 virtual wxMediaState
GetState();
1814 virtual bool SetPosition(wxLongLong where
);
1815 virtual wxLongLong
GetPosition();
1816 virtual wxLongLong
GetDuration();
1818 virtual void Move(int x
, int y
, int w
, int h
);
1819 wxSize
GetVideoSize() const;
1821 virtual double GetPlaybackRate();
1822 virtual bool SetPlaybackRate(double);
1824 virtual double GetVolume();
1825 virtual bool SetVolume(double);
1827 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags
);
1830 void DoGetDownloadProgress(wxLongLong
*, wxLongLong
*);
1831 virtual wxLongLong
GetDownloadProgress()
1833 wxLongLong progress
, total
;
1834 DoGetDownloadProgress(&progress
, &total
);
1837 virtual wxLongLong
GetDownloadTotal()
1839 wxLongLong progress
, total
;
1840 DoGetDownloadProgress(&progress
, &total
);
1846 IActiveMovie
* m_pAM
;
1847 IMediaPlayer
* m_pMP
;
1851 HMODULE m_hQuartzDll
;
1852 LPAMGETERRORTEXT m_lpAMGetErrorText
;
1853 wxString
GetErrorString(HRESULT hrdsv
);
1856 DECLARE_DYNAMIC_CLASS(wxAMMediaBackend
)
1859 //---------------------------------------------------------------------------
1861 // wxMCIMediaBackend
1863 //---------------------------------------------------------------------------
1865 //---------------------------------------------------------------------------
1867 //---------------------------------------------------------------------------
1868 #include <mmsystem.h>
1870 class WXDLLIMPEXP_MEDIA wxMCIMediaBackend
: public wxMediaBackend
1874 wxMCIMediaBackend();
1875 ~wxMCIMediaBackend();
1877 virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
1882 const wxValidator
& validator
,
1883 const wxString
& name
);
1885 virtual bool Play();
1886 virtual bool Pause();
1887 virtual bool Stop();
1889 virtual bool Load(const wxURI
& location
,
1891 { return wxMediaBackend::Load(location
, proxy
); }
1893 virtual bool Load(const wxString
& fileName
);
1894 virtual bool Load(const wxURI
& location
);
1896 virtual wxMediaState
GetState();
1898 virtual bool SetPosition(wxLongLong where
);
1899 virtual wxLongLong
GetPosition();
1900 virtual wxLongLong
GetDuration();
1902 virtual void Move(int x
, int y
, int w
, int h
);
1903 wxSize
GetVideoSize() const;
1905 virtual double GetPlaybackRate();
1906 virtual bool SetPlaybackRate(double dRate
);
1908 virtual double GetVolume();
1909 virtual bool SetVolume(double);
1911 static LRESULT CALLBACK
NotifyWndProc(HWND hWnd
, UINT nMsg
,
1912 WPARAM wParam
, LPARAM lParam
);
1914 LRESULT CALLBACK
OnNotifyWndProc(HWND hWnd
, UINT nMsg
,
1915 WPARAM wParam
, LPARAM lParam
);
1917 MCIDEVICEID m_hDev
; //Our MCI Device ID/Handler
1918 wxControl
* m_ctrl
; //Parent control
1919 HWND m_hNotifyWnd
; //Window to use for MCI events
1920 bool m_bVideo
; //Whether or not we have video
1922 DECLARE_DYNAMIC_CLASS(wxMCIMediaBackend
)
1925 //---------------------------------------------------------------------------
1929 // We don't include Quicktime headers here and define all the types
1930 // ourselves because looking for the quicktime libaries etc. would
1931 // be tricky to do and making this a dependency for the MSVC projects
1932 // would be unrealistic.
1934 // Thanks to Robert Roebling for the wxDL macro/library idea
1935 //---------------------------------------------------------------------------
1937 //---------------------------------------------------------------------------
1939 //---------------------------------------------------------------------------
1940 //#include <qtml.h> //Windoze QT include
1941 //#include <QuickTimeComponents.h> //Standard QT stuff
1942 #include "wx/dynlib.h"
1944 //---------------------------------------------------------------------------
1946 //---------------------------------------------------------------------------
1947 typedef struct MovieRecord
* Movie
;
1948 typedef wxInt16 OSErr
;
1949 typedef wxInt32 OSStatus
;
1952 typedef unsigned char Str255
[256];
1953 #define StringPtr unsigned char*
1954 #define newMovieActive 1
1955 #define newMovieAsyncOK (1 << 8)
1959 #define OSType unsigned long
1960 #define CGrafPtr struct GrafPort *
1961 #define TimeScale long
1962 #define TimeBase struct TimeBaseRecord *
1963 typedef struct ComponentInstanceRecord
* ComponentInstance
;
1964 #define kMovieLoadStatePlayable 10000
1966 #define MovieController ComponentInstance
1968 #ifndef URLDataHandlerSubType
1969 #if defined(__WATCOMC__) || defined(__MINGW32__)
1970 // use magic numbers for compilers which complain about multicharacter integers
1971 const OSType URLDataHandlerSubType
= 1970433056;
1972 const OSType VisualMediaCharacteristic
= 1702454643;
1974 const OSType URLDataHandlerSubType
= 'url ';
1975 const OSType VisualMediaCharacteristic
= 'eyes';
1982 Str255 name
; /*Str63 on mac, Str255 on msw */
1998 wide value
; /* units */
1999 TimeScale scale
; /* units per second */
2008 struct EventRecord
{
2018 mcScaleMovieToFit
= 2,
2024 //---------------------------------------------------------------------------
2026 //---------------------------------------------------------------------------
2027 #define wxDL_METHOD_DEFINE( rettype, name, args, shortargs, defret ) \
2028 typedef rettype (* name ## Type) args ; \
2029 name ## Type pfn_ ## name; \
2031 { if (m_ok) return pfn_ ## name shortargs ; return defret; }
2033 #define wxDL_VOIDMETHOD_DEFINE( name, args, shortargs ) \
2034 typedef void (* name ## Type) args ; \
2035 name ## Type pfn_ ## name; \
2037 { if (m_ok) pfn_ ## name shortargs ; }
2039 #define wxDL_METHOD_LOAD( lib, name, success ) \
2040 pfn_ ## name = (name ## Type) lib.GetSymbol( wxT(#name), &success ); \
2041 if (!success) { wxLog::EnableLogging(bWasLoggingEnabled); return false; }
2044 class WXDLLIMPEXP_MEDIA wxQuickTimeLibrary
2047 ~wxQuickTimeLibrary()
2049 if(m_dll
.IsLoaded())
2054 bool IsOk() const {return m_ok
;}
2057 wxDynamicLibrary m_dll
;
2061 wxDL_VOIDMETHOD_DEFINE( StartMovie
, (Movie m
), (m
) );
2062 wxDL_VOIDMETHOD_DEFINE( StopMovie
, (Movie m
), (m
) );
2063 wxDL_METHOD_DEFINE( bool, IsMovieDone
, (Movie m
), (m
), false);
2064 wxDL_VOIDMETHOD_DEFINE( GoToBeginningOfMovie
, (Movie m
), (m
) );
2065 wxDL_METHOD_DEFINE( OSErr
, GetMoviesError
, (), (), -1);
2066 wxDL_METHOD_DEFINE( OSErr
, EnterMovies
, (), (), -1);
2067 wxDL_VOIDMETHOD_DEFINE( ExitMovies
, (), () );
2068 wxDL_METHOD_DEFINE( OSErr
, InitializeQTML
, (long flags
), (flags
), -1);
2069 wxDL_VOIDMETHOD_DEFINE( TerminateQTML
, (), () );
2071 wxDL_METHOD_DEFINE( OSErr
, NativePathNameToFSSpec
,
2072 (char* inName
, FSSpec
* outFile
, long flags
),
2073 (inName
, outFile
, flags
), -1);
2075 wxDL_METHOD_DEFINE( OSErr
, OpenMovieFile
,
2076 (const FSSpec
* fileSpec
, short * resRefNum
, wxInt8 permission
),
2077 (fileSpec
, resRefNum
, permission
), -1 );
2079 wxDL_METHOD_DEFINE( OSErr
, CloseMovieFile
,
2080 (short resRefNum
), (resRefNum
), -1);
2082 wxDL_METHOD_DEFINE( OSErr
, NewMovieFromFile
,
2083 (Movie
* theMovie
, short resRefNum
, short * resId
,
2084 StringPtr resName
, short newMovieFlags
,
2085 bool * dataRefWasChanged
),
2086 (theMovie
, resRefNum
, resId
, resName
, newMovieFlags
,
2087 dataRefWasChanged
), -1);
2089 wxDL_VOIDMETHOD_DEFINE( SetMovieRate
, (Movie m
, Fixed rate
), (m
, rate
) );
2090 wxDL_METHOD_DEFINE( Fixed
, GetMovieRate
, (Movie m
), (m
), 0);
2091 wxDL_VOIDMETHOD_DEFINE( MoviesTask
, (Movie m
, long maxms
), (m
, maxms
) );
2092 wxDL_VOIDMETHOD_DEFINE( BlockMove
,
2093 (const char* p1
, const char* p2
, long s
), (p1
,p2
,s
) );
2094 wxDL_METHOD_DEFINE( Handle
, NewHandleClear
, (long s
), (s
), NULL
);
2096 wxDL_METHOD_DEFINE( OSErr
, NewMovieFromDataRef
,
2097 (Movie
* m
, short flags
, short * id
,
2098 Handle dataRef
, OSType dataRefType
),
2099 (m
,flags
,id
,dataRef
,dataRefType
), -1 );
2101 wxDL_VOIDMETHOD_DEFINE( DisposeHandle
, (Handle h
), (h
) );
2102 wxDL_VOIDMETHOD_DEFINE( GetMovieNaturalBoundsRect
, (Movie m
, Rect
* r
), (m
,r
) );
2103 wxDL_METHOD_DEFINE( void*, GetMovieIndTrackType
,
2104 (Movie m
, long index
, OSType type
, long flags
),
2105 (m
,index
,type
,flags
), NULL
);
2106 wxDL_VOIDMETHOD_DEFINE( CreatePortAssociation
,
2107 (void* hWnd
, void* junk
, long morejunk
), (hWnd
, junk
, morejunk
) );
2108 wxDL_METHOD_DEFINE(void*, GetNativeWindowPort
, (void* hWnd
), (hWnd
), NULL
);
2109 wxDL_VOIDMETHOD_DEFINE(SetMovieGWorld
, (Movie m
, CGrafPtr port
, void* whatever
),
2110 (m
, port
, whatever
) );
2111 wxDL_VOIDMETHOD_DEFINE(DisposeMovie
, (Movie m
), (m
) );
2112 wxDL_VOIDMETHOD_DEFINE(SetMovieBox
, (Movie m
, Rect
* r
), (m
,r
));
2113 wxDL_VOIDMETHOD_DEFINE(SetMovieTimeScale
, (Movie m
, long s
), (m
,s
));
2114 wxDL_METHOD_DEFINE(long, GetMovieDuration
, (Movie m
), (m
), 0);
2115 wxDL_METHOD_DEFINE(TimeBase
, GetMovieTimeBase
, (Movie m
), (m
), 0);
2116 wxDL_METHOD_DEFINE(TimeScale
, GetMovieTimeScale
, (Movie m
), (m
), 0);
2117 wxDL_METHOD_DEFINE(long, GetMovieTime
, (Movie m
, void* cruft
), (m
,cruft
), 0);
2118 wxDL_VOIDMETHOD_DEFINE(SetMovieTime
, (Movie m
, TimeRecord
* tr
), (m
,tr
) );
2119 wxDL_METHOD_DEFINE(short, GetMovieVolume
, (Movie m
), (m
), 0);
2120 wxDL_VOIDMETHOD_DEFINE(SetMovieVolume
, (Movie m
, short sVolume
), (m
,sVolume
) );
2121 wxDL_VOIDMETHOD_DEFINE(SetMovieTimeValue
, (Movie m
, long s
), (m
,s
));
2122 wxDL_METHOD_DEFINE(ComponentInstance
, NewMovieController
, (Movie m
, const Rect
* mr
, long fl
), (m
,mr
,fl
), 0);
2123 wxDL_VOIDMETHOD_DEFINE(DisposeMovieController
, (ComponentInstance ci
), (ci
));
2124 wxDL_METHOD_DEFINE(int, MCSetVisible
, (ComponentInstance m
, int b
), (m
, b
), 0);
2127 wxDL_VOIDMETHOD_DEFINE(PrePrerollMovie
, (Movie m
, long t
, Fixed r
, WXFARPROC p1
, void* p2
), (m
,t
,r
,p1
,p2
) );
2128 wxDL_VOIDMETHOD_DEFINE(PrerollMovie
, (Movie m
, long t
, Fixed r
), (m
,t
,r
) );
2129 wxDL_METHOD_DEFINE(Fixed
, GetMoviePreferredRate
, (Movie m
), (m
), 0);
2130 wxDL_METHOD_DEFINE(long, GetMovieLoadState
, (Movie m
), (m
), 0);
2131 wxDL_METHOD_DEFINE(void*, NewRoutineDescriptor
, (WXFARPROC f
, int l
, void* junk
), (f
, l
, junk
), 0);
2132 wxDL_VOIDMETHOD_DEFINE(DisposeRoutineDescriptor
, (void* f
), (f
));
2133 wxDL_METHOD_DEFINE(void*, GetCurrentArchitecture
, (), (), 0);
2134 wxDL_METHOD_DEFINE(int, MCDoAction
, (ComponentInstance ci
, long f
, void* p
), (ci
,f
,p
), 0);
2135 wxDL_VOIDMETHOD_DEFINE(MCSetControllerBoundsRect
, (ComponentInstance ci
, Rect
* r
), (ci
,r
));
2136 wxDL_VOIDMETHOD_DEFINE(DestroyPortAssociation
, (CGrafPtr g
), (g
));
2137 wxDL_VOIDMETHOD_DEFINE(NativeEventToMacEvent
, (MSG
* p1
, EventRecord
* p2
), (p1
,p2
));
2138 wxDL_VOIDMETHOD_DEFINE(MCIsPlayerEvent
, (ComponentInstance ci
, EventRecord
* p2
), (ci
, p2
));
2139 wxDL_METHOD_DEFINE(int, MCSetMovie
, (ComponentInstance ci
, Movie m
, void* p1
, Point w
),
2141 wxDL_VOIDMETHOD_DEFINE(MCPositionController
,
2142 (ComponentInstance ci
, Rect
* r
, void* junk
, void* morejunk
), (ci
,r
,junk
,morejunk
));
2143 wxDL_VOIDMETHOD_DEFINE(MCSetActionFilterWithRefCon
,
2144 (ComponentInstance ci
, WXFARPROC cb
, void* ref
), (ci
,cb
,ref
));
2145 wxDL_VOIDMETHOD_DEFINE(MCGetControllerInfo
, (MovieController mc
, long* flags
), (mc
,flags
));
2146 wxDL_VOIDMETHOD_DEFINE(BeginUpdate
, (CGrafPtr port
), (port
));
2147 wxDL_VOIDMETHOD_DEFINE(UpdateMovie
, (Movie m
), (m
));
2148 wxDL_VOIDMETHOD_DEFINE(EndUpdate
, (CGrafPtr port
), (port
));
2149 wxDL_METHOD_DEFINE( OSErr
, GetMoviesStickyError
, (), (), -1);
2152 bool wxQuickTimeLibrary::Initialize()
2156 bool bWasLoggingEnabled
= wxLog::EnableLogging(false); //Turn off the wxDynamicLibrary logging
2158 if(!m_dll
.Load(wxT("qtmlClient.dll")))
2160 wxLog::EnableLogging(bWasLoggingEnabled
);
2164 wxDL_METHOD_LOAD( m_dll
, StartMovie
, m_ok
);
2165 wxDL_METHOD_LOAD( m_dll
, StopMovie
, m_ok
);
2166 wxDL_METHOD_LOAD( m_dll
, IsMovieDone
, m_ok
);
2167 wxDL_METHOD_LOAD( m_dll
, GoToBeginningOfMovie
, m_ok
);
2168 wxDL_METHOD_LOAD( m_dll
, GetMoviesError
, m_ok
);
2169 wxDL_METHOD_LOAD( m_dll
, EnterMovies
, m_ok
);
2170 wxDL_METHOD_LOAD( m_dll
, ExitMovies
, m_ok
);
2171 wxDL_METHOD_LOAD( m_dll
, InitializeQTML
, m_ok
);
2172 wxDL_METHOD_LOAD( m_dll
, TerminateQTML
, m_ok
);
2173 wxDL_METHOD_LOAD( m_dll
, NativePathNameToFSSpec
, m_ok
);
2174 wxDL_METHOD_LOAD( m_dll
, OpenMovieFile
, m_ok
);
2175 wxDL_METHOD_LOAD( m_dll
, CloseMovieFile
, m_ok
);
2176 wxDL_METHOD_LOAD( m_dll
, NewMovieFromFile
, m_ok
);
2177 wxDL_METHOD_LOAD( m_dll
, GetMovieRate
, m_ok
);
2178 wxDL_METHOD_LOAD( m_dll
, SetMovieRate
, m_ok
);
2179 wxDL_METHOD_LOAD( m_dll
, MoviesTask
, m_ok
);
2180 wxDL_METHOD_LOAD( m_dll
, BlockMove
, m_ok
);
2181 wxDL_METHOD_LOAD( m_dll
, NewHandleClear
, m_ok
);
2182 wxDL_METHOD_LOAD( m_dll
, NewMovieFromDataRef
, m_ok
);
2183 wxDL_METHOD_LOAD( m_dll
, DisposeHandle
, m_ok
);
2184 wxDL_METHOD_LOAD( m_dll
, GetMovieNaturalBoundsRect
, m_ok
);
2185 wxDL_METHOD_LOAD( m_dll
, GetMovieIndTrackType
, m_ok
);
2186 wxDL_METHOD_LOAD( m_dll
, CreatePortAssociation
, m_ok
);
2187 wxDL_METHOD_LOAD( m_dll
, DestroyPortAssociation
, m_ok
);
2188 wxDL_METHOD_LOAD( m_dll
, GetNativeWindowPort
, m_ok
);
2189 wxDL_METHOD_LOAD( m_dll
, SetMovieGWorld
, m_ok
);
2190 wxDL_METHOD_LOAD( m_dll
, DisposeMovie
, m_ok
);
2191 wxDL_METHOD_LOAD( m_dll
, SetMovieBox
, m_ok
);
2192 wxDL_METHOD_LOAD( m_dll
, SetMovieTimeScale
, m_ok
);
2193 wxDL_METHOD_LOAD( m_dll
, GetMovieDuration
, m_ok
);
2194 wxDL_METHOD_LOAD( m_dll
, GetMovieTimeBase
, m_ok
);
2195 wxDL_METHOD_LOAD( m_dll
, GetMovieTimeScale
, m_ok
);
2196 wxDL_METHOD_LOAD( m_dll
, GetMovieTime
, m_ok
);
2197 wxDL_METHOD_LOAD( m_dll
, SetMovieTime
, m_ok
);
2198 wxDL_METHOD_LOAD( m_dll
, GetMovieVolume
, m_ok
);
2199 wxDL_METHOD_LOAD( m_dll
, SetMovieVolume
, m_ok
);
2200 wxDL_METHOD_LOAD( m_dll
, SetMovieTimeValue
, m_ok
);
2201 wxDL_METHOD_LOAD( m_dll
, NewMovieController
, m_ok
);
2202 wxDL_METHOD_LOAD( m_dll
, DisposeMovieController
, m_ok
);
2203 wxDL_METHOD_LOAD( m_dll
, MCSetVisible
, m_ok
);
2204 wxDL_METHOD_LOAD( m_dll
, PrePrerollMovie
, m_ok
);
2205 wxDL_METHOD_LOAD( m_dll
, PrerollMovie
, m_ok
);
2206 wxDL_METHOD_LOAD( m_dll
, GetMoviePreferredRate
, m_ok
);
2207 wxDL_METHOD_LOAD( m_dll
, GetMovieLoadState
, m_ok
);
2208 wxDL_METHOD_LOAD( m_dll
, MCDoAction
, m_ok
);
2209 wxDL_METHOD_LOAD( m_dll
, MCSetControllerBoundsRect
, m_ok
);
2210 wxDL_METHOD_LOAD( m_dll
, NativeEventToMacEvent
, m_ok
);
2211 wxDL_METHOD_LOAD( m_dll
, MCIsPlayerEvent
, m_ok
);
2212 wxDL_METHOD_LOAD( m_dll
, MCSetMovie
, m_ok
);
2213 wxDL_METHOD_LOAD( m_dll
, MCSetActionFilterWithRefCon
, m_ok
);
2214 wxDL_METHOD_LOAD( m_dll
, MCGetControllerInfo
, m_ok
);
2215 wxDL_METHOD_LOAD( m_dll
, BeginUpdate
, m_ok
);
2216 wxDL_METHOD_LOAD( m_dll
, UpdateMovie
, m_ok
);
2217 wxDL_METHOD_LOAD( m_dll
, EndUpdate
, m_ok
);
2218 wxDL_METHOD_LOAD( m_dll
, GetMoviesStickyError
, m_ok
);
2220 wxLog::EnableLogging(bWasLoggingEnabled
);
2226 //cludgy workaround for wx events. slots would be nice :)
2227 class WXDLLIMPEXP_MEDIA wxQTMediaEvtHandler
: public wxEvtHandler
2230 void OnPaint(wxPaintEvent
&);
2231 void OnEraseBackground(wxEraseEvent
&);
2234 class WXDLLIMPEXP_MEDIA wxQTMediaBackend
: public wxMediaBackend
2238 ~wxQTMediaBackend();
2240 virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
2245 const wxValidator
& validator
,
2246 const wxString
& name
);
2248 virtual bool Play();
2249 virtual bool Pause();
2250 virtual bool Stop();
2252 virtual bool Load(const wxURI
& location
,
2254 { return wxMediaBackend::Load(location
, proxy
); }
2256 virtual bool Load(const wxString
& fileName
);
2257 virtual bool Load(const wxURI
& location
);
2259 virtual wxMediaState
GetState();
2261 virtual bool SetPosition(wxLongLong where
);
2262 virtual wxLongLong
GetPosition();
2263 virtual wxLongLong
GetDuration();
2265 virtual void Move(int x
, int y
, int w
, int h
);
2266 wxSize
GetVideoSize() const;
2268 virtual double GetPlaybackRate();
2269 virtual bool SetPlaybackRate(double dRate
);
2271 virtual double GetVolume();
2272 virtual bool SetVolume(double);
2277 static void PPRMProc (Movie theMovie
, OSErr theErr
, void* theRefCon
);
2278 //TODO: Last param actually long - does this work on 64bit machines?
2279 static Boolean
MCFilterProc (MovieController theController
,
2280 short action
, void *params
, LONG_PTR refCon
);
2282 static LRESULT CALLBACK
QTWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
2284 virtual bool ShowPlayerControls(wxMediaCtrlPlayerControls flags
);
2286 wxSize m_bestSize
; //Original movie size
2287 Movie m_movie
; //QT Movie handle/instance
2288 wxControl
* m_ctrl
; //Parent control
2289 bool m_bVideo
; //Whether or not we have video
2290 bool m_bPlaying
; //Whether or not movie is playing
2291 wxTimer
* m_timer
; //Load or Play timer
2292 wxQuickTimeLibrary m_lib
; //DLL to load functions from
2293 ComponentInstance m_pMC
; //Movie Controller
2295 DECLARE_DYNAMIC_CLASS(wxQTMediaBackend
)
2299 //===========================================================================
2301 //===========================================================================
2303 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2307 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2309 IMPLEMENT_DYNAMIC_CLASS(wxAMMediaBackend
, wxMediaBackend
);
2311 //---------------------------------------------------------------------------
2312 // Usual debugging macros
2313 //---------------------------------------------------------------------------
2315 #define MAX_ERROR_TEXT_LEN 160
2317 //Get the error string for Active Movie
2318 wxString
wxAMMediaBackend::GetErrorString(HRESULT hrdsv
)
2320 wxChar szError
[MAX_ERROR_TEXT_LEN
];
2321 if( m_lpAMGetErrorText
!= NULL
&&
2322 (*m_lpAMGetErrorText
)(hrdsv
, szError
, MAX_ERROR_TEXT_LEN
) == 0)
2324 return wxString::Format(wxT("DirectShow error \"%s\" \n")
2325 wxT("(numeric %X)\n")
2327 szError
, (int)hrdsv
);
2331 return wxString::Format(wxT("Unknown error \n")
2332 wxT("(numeric %X)\n")
2338 #define wxAMFAIL(x) wxFAIL_MSG(GetErrorString(x));
2339 #define wxVERIFY(x) wxASSERT((x))
2340 #define wxAMLOG(x) wxLogDebug(GetErrorString(x))
2342 #define wxAMVERIFY(x) (x)
2343 #define wxVERIFY(x) (x)
2348 //---------------------------------------------------------------------------
2349 // Standard macros for ease of use
2350 //---------------------------------------------------------------------------
2351 #define SAFE_RELEASE(x) { if (x) x->Release(); x = NULL; }
2353 //---------------------------------------------------------------------------
2356 // Queries the control periodically to see if it has reached the point
2357 // in its loading cycle where we can begin playing the media - if so
2358 // then we finish up some things like getting the original size of the video
2359 // and then sending the loaded event to our handler
2360 //---------------------------------------------------------------------------
2361 class wxAMLoadTimer
: public wxTimer
2364 wxAMLoadTimer(wxAMMediaBackend
* parent
) :
2371 MPReadyStateConstants nState
;
2372 m_parent
->m_pMP
->get_ReadyState(&nState
);
2373 if(nState
!= mpReadyStateLoading
)
2376 m_parent
->FinishLoad();
2382 IActiveMovie2
* pAM2
= NULL
;
2383 ReadyStateConstants nState
;
2384 if(m_parent
->m_pAM
->QueryInterface(IID_IActiveMovie2
,
2385 (void**)&pAM2
) == 0 &&
2386 pAM2
->get_ReadyState(&nState
) == 0)
2389 if(nState
!= amvLoading
)
2392 m_parent
->FinishLoad();
2402 m_parent
->FinishLoad();
2410 wxAMMediaBackend
* m_parent
; //Backend pointer
2413 //---------------------------------------------------------------------------
2416 // Sets m_hNotifyWnd to NULL to signify that we haven't loaded anything yet
2417 // Queries the control periodically to see if it has stopped -
2418 // if it has it sends the stop event
2419 //---------------------------------------------------------------------------
2420 class wxAMPlayTimer
: public wxTimer
2423 wxAMPlayTimer(wxAMMediaBackend
* parent
) :
2428 if(m_parent
->GetState() == wxMEDIASTATE_STOPPED
&&
2429 //NB: Stop events could get triggered by the interface
2430 //if ShowPlayerControls is enabled,
2431 //so we need this hack here to make an attempt
2432 //at it not getting sent - but its far from ideal -
2433 //they can still get sent in some cases
2434 m_parent
->GetPosition() == m_parent
->GetDuration())
2436 wxMediaEvent
theEvent(wxEVT_MEDIA_STOP
,
2437 m_parent
->m_ctrl
->GetId());
2438 m_parent
->m_ctrl
->ProcessEvent(theEvent
);
2440 if(theEvent
.IsAllowed())
2442 //Seek to beginning of movie
2443 m_parent
->wxAMMediaBackend::SetPosition(0);
2446 //send the event to our child
2447 wxMediaEvent
theEvent(wxEVT_MEDIA_FINISHED
,
2448 m_parent
->m_ctrl
->GetId());
2449 m_parent
->m_ctrl
->AddPendingEvent(theEvent
);
2455 wxAMMediaBackend
* m_parent
; //Backend pointer
2460 // The following is an alternative way - but it doesn't seem
2461 // to work with the IActiveMovie control - it probably processes
2463 //---------------------------------------------------------------------------
2466 // Query the IMediaEvent interface from the embedded WMP's
2467 // filtergraph, then process the events from it - sending
2468 // EC_COMPLETE events as stop events to the media control.
2469 //---------------------------------------------------------------------------
2470 class wxAMPlayTimer : public wxTimer
2473 wxAMPlayTimer(wxAMMediaBackend* pBE) : m_pBE(pBE), m_pME(NULL)
2477 hr = m_pBE->m_pAM->get_FilterGraph(&pGB);
2478 wxASSERT(SUCCEEDED(hr));
2479 hr = pGB->QueryInterface(IID_IMediaEvent, (void**)&m_pME);
2480 wxASSERT(SUCCEEDED(hr));
2486 SAFE_RELEASE(m_pME);
2496 // DirectShow keeps a list of queued events, and we need
2497 // to go through them one by one, stopping at (Hopefully only one)
2498 // EC_COMPLETE message
2500 while( m_pME->GetEvent(&evCode, &evParam1, &evParam2, 0) == 0 )
2502 // Cleanup memory that GetEvent allocated
2503 HRESULT hr = m_pME->FreeEventParams(evCode,
2504 evParam1, evParam2);
2507 //Even though this makes a messagebox this
2508 //is windows where we can do gui stuff in seperate
2510 wxFAIL_MSG(m_pBE->GetErrorString(hr));
2512 // If this is the end of the clip, notify handler
2513 else if(1 == evCode) //EC_COMPLETE
2515 wxMediaEvent theEvent(wxEVT_MEDIA_STOP,
2516 m_pBE->m_ctrl->GetId());
2517 m_pBE->m_ctrl->ProcessEvent(theEvent);
2519 if(theEvent.IsAllowed())
2523 //send the event to our child
2524 wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
2525 m_pBE->m_ctrl->GetId());
2526 m_pBE->m_ctrl->AddPendingEvent(theEvent);
2533 wxAMMediaBackend* m_pBE; //Backend pointer
2534 IMediaEvent* m_pME; //To determine when to send stop event
2538 //---------------------------------------------------------------------------
2539 // wxAMMediaBackend Constructor
2540 //---------------------------------------------------------------------------
2541 wxAMMediaBackend::wxAMMediaBackend()
2552 //---------------------------------------------------------------------------
2553 // wxAMMediaBackend Destructor
2554 //---------------------------------------------------------------------------
2555 wxAMMediaBackend::~wxAMMediaBackend()
2557 Clear(); //Free memory from Load()
2561 m_pAX
->DissociateHandle();
2570 ::FreeLibrary(m_hQuartzDll
);
2574 //---------------------------------------------------------------------------
2575 // wxAMMediaBackend::Clear
2577 // Free up interfaces and memory allocated by LoadXXX
2578 //---------------------------------------------------------------------------
2579 void wxAMMediaBackend::Clear()
2585 //---------------------------------------------------------------------------
2586 // wxAMMediaBackend::CreateControl
2587 //---------------------------------------------------------------------------
2588 bool wxAMMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
2593 const wxValidator
& validator
,
2594 const wxString
& name
)
2596 // First get the AMGetErrorText procedure in debug
2597 // mode for more meaningful messages
2599 m_hQuartzDll
= ::LoadLibrary(wxT("quartz.dll"));
2602 m_lpAMGetErrorText
= (LPAMGETERRORTEXT
) ::GetProcAddress(
2604 wxString::Format(wxT("AMGetErrorText%s"),
2614 ).mb_str(wxConvLocal
)
2619 // Now determine which (if any) media player interface is
2620 // available - IMediaPlayer or IActiveMovie
2621 if( ::CoCreateInstance(CLSID_MediaPlayer
, NULL
,
2622 CLSCTX_INPROC_SERVER
,
2623 IID_IMediaPlayer
, (void**)&m_pMP
) != 0 )
2625 if( ::CoCreateInstance(CLSID_ActiveMovie
, NULL
,
2626 CLSCTX_INPROC_SERVER
,
2627 IID_IActiveMovie
, (void**)&m_pAM
) != 0 )
2629 m_pAM
->QueryInterface(IID_IMediaPlayer
, (void**)&m_pMP
);
2633 m_pMP
->QueryInterface(IID_IActiveMovie
, (void**)&m_pAM
);
2637 // By default wxWindow(s) is created with a border -
2638 // so we need to get rid of those
2640 // Since we don't have a child window like most other
2641 // backends, we don't need wxCLIP_CHILDREN
2643 if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
,
2644 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
,
2649 // Now create the ActiveX container along with the media player
2650 // interface and query them
2653 m_pAX
= new wxActiveX(ctrl
,
2654 m_pMP
? IID_IMediaPlayer
: IID_IActiveMovie
,
2659 // Here we set up wx-specific stuff for the default
2660 // settings wxMediaCtrl says it will stay to
2664 m_pMP
->put_DisplaySize(mpFitToSize
);
2665 // TODO: Unsure what actual effect this has
2666 m_pMP
->put_WindowlessVideo(VARIANT_TRUE
);
2669 m_pAM
->put_MovieWindowSize(amvDoubleOriginalSize
);
2672 m_pAM
->put_AutoStart(VARIANT_FALSE
);
2673 //by default enabled
2674 wxAMMediaBackend::ShowPlayerControls(wxMEDIACTRLPLAYERCONTROLS_NONE
);
2675 //by default with AM only 0.5
2676 wxAMMediaBackend::SetVolume(1.0);
2678 // My problem with this was only with a previous patch, probably the
2679 // third rewrite fixed it as a side-effect. In fact, the erase
2680 // background style of drawing not only works now, but is much better
2681 // than paint-based updates (the paint event handler flickers if the
2682 // wxMediaCtrl shares a sizer with another child window, or is on a
2685 m_ctrl
->Connect(m_ctrl
->GetId(), wxEVT_ERASE_BACKGROUND
,
2686 wxEraseEventHandler(wxAMMediaEvtHandler::OnEraseBackground
),
2687 NULL
, (wxEvtHandler
*) this);
2693 //---------------------------------------------------------------------------
2694 // wxAMMediaBackend::Load (file version)
2695 //---------------------------------------------------------------------------
2696 bool wxAMMediaBackend::Load(const wxString
& fileName
)
2698 return DoLoad(fileName
);
2701 //---------------------------------------------------------------------------
2702 // wxAMMediaBackend::Load (URL Version)
2703 //---------------------------------------------------------------------------
2704 bool wxAMMediaBackend::Load(const wxURI
& location
)
2706 // Turn off loading from a proxy as user
2707 // may have set it previously
2708 INSPlay
* pPlay
= NULL
;
2709 m_pAM
->QueryInterface(IID_INSPlay
, (void**) &pPlay
);
2712 pPlay
->put_UseHTTPProxy(VARIANT_FALSE
);
2716 return DoLoad(location
.BuildURI());
2719 //---------------------------------------------------------------------------
2720 // wxAMMediaBackend::Load (URL Version with Proxy)
2721 //---------------------------------------------------------------------------
2722 bool wxAMMediaBackend::Load(const wxURI
& location
, const wxURI
& proxy
)
2724 // Set the proxy of the NETSHOW interface
2725 INSPlay
* pPlay
= NULL
;
2726 m_pAM
->QueryInterface(IID_INSPlay
, (void**) &pPlay
);
2730 pPlay
->put_UseHTTPProxy(VARIANT_TRUE
);
2731 pPlay
->put_HTTPProxyHost(wxBasicString(proxy
.GetServer()).Get());
2732 pPlay
->put_HTTPProxyPort(wxAtoi(proxy
.GetPort()));
2736 return DoLoad(location
.BuildURI());
2739 //---------------------------------------------------------------------------
2740 // wxAMMediaBackend::DoLoad
2742 // Called by all functions - this actually renders
2743 // the file and sets up the filter graph
2744 //---------------------------------------------------------------------------
2745 bool wxAMMediaBackend::DoLoad(const wxString
& location
)
2747 Clear(); //Clear up previously allocated memory
2751 // Play the movie the normal way through the embedded
2752 // WMP. Supposively Open is better in theory because
2753 // the docs say its async and put_FileName is not -
2754 // but in practice they both seem to be async anyway
2756 hr
= m_pMP
->Open( wxBasicString(location
).Get() );
2758 hr
= m_pAM
->put_FileName( wxBasicString(location
).Get() );
2766 // In AM playing will FAIL if
2767 // the user plays before the media is loaded
2768 m_pTimer
= new wxAMLoadTimer(this);
2769 m_pTimer
->Start(20);
2773 //---------------------------------------------------------------------------
2774 // wxAMMediaBackend::FinishLoad
2776 // Called by our wxAMLoadTimer when the
2777 // embedded WMP tells its the media is ready to play.
2779 // Here we get the original size of the video and
2780 // send the loaded event to our watcher :).
2781 //---------------------------------------------------------------------------
2782 void wxAMMediaBackend::FinishLoad()
2784 //Get the original video size
2785 m_pAM
->get_ImageSourceWidth((long*)&m_bestSize
.x
);
2786 m_pAM
->get_ImageSourceHeight((long*)&m_bestSize
.y
);
2789 //Start the play timer to catch stop events
2790 //Previous load timer cleans up itself
2792 m_pTimer
= new wxAMPlayTimer(this);
2794 //Here, if the parent of the control has a sizer - we
2795 //tell it to recalculate the size of this control since
2796 //the user opened a separate media file
2798 m_ctrl
->InvalidateBestSize();
2799 m_ctrl
->GetParent()->Layout();
2800 m_ctrl
->GetParent()->Refresh();
2801 m_ctrl
->GetParent()->Update();
2802 m_ctrl
->SetSize(m_ctrl
->GetSize());
2804 //Send event to our children
2805 wxMediaEvent
theEvent(wxEVT_MEDIA_LOADED
,
2807 m_ctrl
->AddPendingEvent(theEvent
);
2810 //---------------------------------------------------------------------------
2811 // wxAMMediaBackend::ShowPlayerControls
2812 //---------------------------------------------------------------------------
2813 bool wxAMMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags
)
2815 // Note that IMediaPlayer doesn't have a statusbar by
2816 // default but IActiveMovie does - so lets try to keep
2817 // the interface consistant
2820 m_pAM
->put_Enabled(VARIANT_FALSE
);
2821 m_pAM
->put_ShowControls(VARIANT_FALSE
);
2823 m_pMP
->put_ShowStatusBar(VARIANT_FALSE
);
2827 m_pAM
->put_Enabled(VARIANT_TRUE
);
2828 m_pAM
->put_ShowControls(VARIANT_TRUE
);
2830 m_pAM
->put_ShowPositionControls(
2831 (flags
& wxMEDIACTRLPLAYERCONTROLS_STEP
) ?
2832 VARIANT_TRUE
: VARIANT_FALSE
);
2836 m_pMP
->put_ShowStatusBar(VARIANT_TRUE
);
2837 m_pMP
->put_ShowAudioControls(
2838 (flags
& wxMEDIACTRLPLAYERCONTROLS_VOLUME
) ?
2839 VARIANT_TRUE
: VARIANT_FALSE
);
2846 //---------------------------------------------------------------------------
2847 // wxAMMediaBackend::Play
2849 // Plays the stream. If it is non-seekable, it will restart it (implicit).
2851 // Note that we use SUCCEEDED here because run/pause/stop tend to be overly
2852 // picky and return warnings on pretty much every call
2853 //---------------------------------------------------------------------------
2854 bool wxAMMediaBackend::Play()
2856 // if the movie isn't done loading yet
2857 // go into an sync getmessage loop until it is :)
2860 MPReadyStateConstants nState
;
2861 m_pMP
->get_ReadyState(&nState
);
2862 while(nState
== mpReadyStateLoading
&& wxYieldIfNeeded())
2864 m_pMP
->get_ReadyState(&nState
);
2869 IActiveMovie2
* pAM2
;
2870 ReadyStateConstants nState
;
2871 if(m_pAM
->QueryInterface(IID_IActiveMovie2
, (void**)&pAM2
) == 0 &&
2872 pAM2
->get_ReadyState(&nState
) == 0)
2874 while(nState
== amvLoading
&& wxYieldIfNeeded())
2876 pAM2
->get_ReadyState(&nState
);
2882 //Actually try to play the movie
2883 HRESULT hr
= m_pAM
->Run();
2886 m_pTimer
->Start(20);
2893 //---------------------------------------------------------------------------
2894 // wxAMMediaBackend::Pause
2896 // Pauses the stream.
2897 //---------------------------------------------------------------------------
2898 bool wxAMMediaBackend::Pause()
2900 HRESULT hr
= m_pAM
->Pause();
2907 //---------------------------------------------------------------------------
2908 // wxAMMediaBackend::Stop
2910 // Stops the stream.
2911 //---------------------------------------------------------------------------
2912 bool wxAMMediaBackend::Stop()
2914 HRESULT hr
= m_pAM
->Stop();
2918 wxAMMediaBackend::SetPosition(0);
2919 //Stop stop event timer
2927 //---------------------------------------------------------------------------
2928 // wxAMMediaBackend::SetPosition
2930 // 1) Translates the current position's time to directshow time,
2931 // which is in a scale of 1 second (in a double)
2932 // 2) Sets the play position of the IMediaSeeking interface -
2933 // passing NULL as the stop position means to keep the old
2935 //---------------------------------------------------------------------------
2936 bool wxAMMediaBackend::SetPosition(wxLongLong where
)
2938 HRESULT hr
= m_pAM
->put_CurrentPosition(
2939 ((LONGLONG
)where
.GetValue()) / 1000.0
2950 //---------------------------------------------------------------------------
2951 // wxAMMediaBackend::GetPosition
2953 // 1) Obtains the current play and stop positions from IMediaSeeking
2954 // 2) Returns the play position translated to our time base
2955 //---------------------------------------------------------------------------
2956 wxLongLong
wxAMMediaBackend::GetPosition()
2959 HRESULT hr
= m_pAM
->get_CurrentPosition(&outCur
);
2966 //h,m,s,milli - outdur is in 1 second (double)
2974 //---------------------------------------------------------------------------
2975 // wxAMMediaBackend::GetVolume
2977 // Gets the volume through the IBasicAudio interface -
2978 // value ranges from 0 (MAX volume) to -10000 (minimum volume).
2979 // -100 per decibel.
2980 //---------------------------------------------------------------------------
2981 double wxAMMediaBackend::GetVolume()
2984 HRESULT hr
= m_pAM
->get_Volume(&lVolume
);
2990 return pow(10.0, lVolume
/2000.0);
2993 //---------------------------------------------------------------------------
2994 // wxAMMediaBackend::SetVolume
2996 // Sets the volume through the IBasicAudio interface -
2997 // value ranges from 0 (MAX volume) to -10000 (minimum volume).
2998 // -100 per decibel.
2999 //---------------------------------------------------------------------------
3000 bool wxAMMediaBackend::SetVolume(double dVolume
)
3002 //pow(10.0, -80.0) to correct 0 == -INF
3003 long lVolume
= (long)(2000.0 * log10(pow(10.0, -80.0)+dVolume
));
3004 HRESULT hr
= m_pAM
->put_Volume( lVolume
);
3013 //---------------------------------------------------------------------------
3014 // wxAMMediaBackend::GetDuration
3016 // 1) Obtains the duration of the media from IAMMultiMediaStream
3017 // 2) Converts that value to our time base, and returns it
3019 // NB: With VBR MP3 files the default DirectShow MP3 render does not
3020 // read the Xing header correctly, resulting in skewed values for duration
3022 //---------------------------------------------------------------------------
3023 wxLongLong
wxAMMediaBackend::GetDuration()
3026 HRESULT hr
= m_pAM
->get_Duration(&outDuration
);
3033 //h,m,s,milli - outdur is in 1 second (double)
3034 outDuration
*= 1000;
3036 ll
.Assign(outDuration
);
3041 //---------------------------------------------------------------------------
3042 // wxAMMediaBackend::GetState
3044 // Returns the cached state
3045 //---------------------------------------------------------------------------
3046 wxMediaState
wxAMMediaBackend::GetState()
3048 StateConstants nState
;
3049 HRESULT hr
= m_pAM
->get_CurrentState(&nState
);
3053 return wxMEDIASTATE_STOPPED
;
3056 return (wxMediaState
)nState
;
3059 //---------------------------------------------------------------------------
3060 // wxAMMediaBackend::GetPlaybackRate
3062 // Pretty simple way of obtaining the playback rate from
3063 // the IMediaSeeking interface
3064 //---------------------------------------------------------------------------
3065 double wxAMMediaBackend::GetPlaybackRate()
3068 HRESULT hr
= m_pAM
->get_Rate(&dRate
);
3077 //---------------------------------------------------------------------------
3078 // wxAMMediaBackend::SetPlaybackRate
3080 // Sets the playback rate of the media - DirectShow is pretty good
3081 // about this, actually
3082 //---------------------------------------------------------------------------
3083 bool wxAMMediaBackend::SetPlaybackRate(double dRate
)
3085 HRESULT hr
= m_pAM
->put_Rate(dRate
);
3095 //---------------------------------------------------------------------------
3096 // wxAMMediaBackend::GetDownloadXXX
3098 // Queries for and gets the total size of the file and the current
3099 // progress in downloading that file from the IAMOpenProgress
3100 // interface from the media player interface's filter graph
3101 //---------------------------------------------------------------------------
3102 void wxAMMediaBackend::DoGetDownloadProgress(wxLongLong
* pLoadProgress
,
3103 wxLongLong
* pLoadTotal
)
3105 LONGLONG loadTotal
= 0, loadProgress
= 0;
3107 IAMOpenProgress
* pOP
;
3109 hr
= m_pAM
->get_FilterGraph(&pFG
);
3112 hr
= pFG
->QueryInterface(IID_IAMOpenProgress
, (void**)&pOP
);
3115 hr
= pOP
->QueryProgress(&loadTotal
, &loadProgress
);
3123 *pLoadProgress
= loadProgress
;
3124 *pLoadTotal
= loadTotal
;
3128 //When not loading from a URL QueryProgress will return
3129 //E_NOINTERFACE or whatever
3136 //---------------------------------------------------------------------------
3137 // wxAMMediaBackend::GetVideoSize
3139 // Obtains the cached original video size
3140 //---------------------------------------------------------------------------
3141 wxSize
wxAMMediaBackend::GetVideoSize() const
3146 //---------------------------------------------------------------------------
3147 // wxAMMediaBackend::Move
3149 // We take care of this in our redrawing
3150 //---------------------------------------------------------------------------
3151 void wxAMMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
),
3152 int WXUNUSED(w
), int WXUNUSED(h
))
3156 //---------------------------------------------------------------------------
3157 // wxAMMediaEvtHandler::OnEraseBackground
3159 // Tell WX not to erase the background of our control window
3160 // so that resizing is a bit smoother
3161 //---------------------------------------------------------------------------
3162 void wxAMMediaEvtHandler::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
))
3166 //---------------------------------------------------------------------------
3167 // End of wxAMMediaBackend
3168 //---------------------------------------------------------------------------
3170 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3172 // wxMCIMediaBackend
3174 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3176 IMPLEMENT_DYNAMIC_CLASS(wxMCIMediaBackend
, wxMediaBackend
);
3178 //---------------------------------------------------------------------------
3179 // Usual debugging macros for MCI returns
3180 //---------------------------------------------------------------------------
3183 #define wxMCIVERIFY(arg) \
3186 if ( (nRet = (arg)) != 0) \
3189 mciGetErrorString(nRet, sz, 5000); \
3190 wxFAIL_MSG(wxString::Format(_T("MCI Error:%s"), sz)); \
3194 #define wxMCIVERIFY(arg) (arg);
3197 //---------------------------------------------------------------------------
3198 // Simulation for <digitalv.h>
3200 // Mingw and possibly other compilers don't have the digitalv.h header
3201 // that is needed to have some essential features of mci work with
3202 // windows - so we provide the declarations for the types we use here
3203 //---------------------------------------------------------------------------
3206 DWORD_PTR dwCallback
;
3207 #ifdef MCI_USE_OFFEXT
3213 } MCI_DGV_RECT_PARMS
;
3216 DWORD_PTR dwCallback
;
3226 } MCI_DGV_WINDOW_PARMS
;
3229 DWORD_PTR dwCallback
;
3234 } MCI_DGV_SET_PARMS
;
3237 DWORD_PTR dwCallback
;
3241 wxChar
* lpstrAlgorithm
;
3242 wxChar
* lpstrQuality
;
3243 } MCI_DGV_SETAUDIO_PARMS
;
3245 //---------------------------------------------------------------------------
3246 // wxMCIMediaBackend Constructor
3248 // Here we don't need to do much except say we don't have any video :)
3249 //---------------------------------------------------------------------------
3250 wxMCIMediaBackend::wxMCIMediaBackend() : m_hNotifyWnd(NULL
), m_bVideo(false)
3254 //---------------------------------------------------------------------------
3255 // wxMCIMediaBackend Destructor
3257 // We close the mci device - note that there may not be an mci device here,
3258 // or it may fail - but we don't really care, since we're destructing
3259 //---------------------------------------------------------------------------
3260 wxMCIMediaBackend::~wxMCIMediaBackend()
3264 mciSendCommand(m_hDev
, MCI_CLOSE
, 0, 0);
3265 DestroyWindow(m_hNotifyWnd
);
3266 m_hNotifyWnd
= NULL
;
3270 //---------------------------------------------------------------------------
3271 // wxMCIMediaBackend::Create
3273 // Here we just tell wxMediaCtrl that mci does exist (which it does, on all
3274 // msw systems, at least in some form dating back to win16 days)
3275 //---------------------------------------------------------------------------
3276 bool wxMCIMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
3281 const wxValidator
& validator
,
3282 const wxString
& name
)
3286 // By default wxWindow(s) is created with a border -
3287 // so we need to get rid of those, and create with
3288 // wxCLIP_CHILDREN, so that if the driver/backend
3289 // is a child window, it refereshes properly
3291 if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
,
3292 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
| wxCLIP_CHILDREN
,
3300 //---------------------------------------------------------------------------
3301 // wxMCIMediaBackend::Load (file version)
3303 // Here we have MCI load a file and device, set the time format to our
3304 // default (milliseconds), and set the video (if any) to play in the control
3305 //---------------------------------------------------------------------------
3306 bool wxMCIMediaBackend::Load(const wxString
& fileName
)
3309 //if the user already called load close the previous MCI device
3313 mciSendCommand(m_hDev
, MCI_CLOSE
, 0, 0);
3314 DestroyWindow(m_hNotifyWnd
);
3315 m_hNotifyWnd
= NULL
;
3319 //Opens a file and has MCI select a device. Normally you'd put
3320 //MCI_OPEN_TYPE in addition to MCI_OPEN_ELEMENT - however if you
3321 //omit this it tells MCI to select the device instead. This is
3322 //good because we have no reliable way of "enumerating" the devices
3325 MCI_OPEN_PARMS openParms
;
3326 openParms
.lpstrElementName
= (wxChar
*) fileName
.c_str();
3328 if ( mciSendCommand(0, MCI_OPEN
, MCI_OPEN_ELEMENT
,
3329 (DWORD
)(LPVOID
)&openParms
) != 0)
3332 m_hDev
= openParms
.wDeviceID
;
3335 //Now set the time format for the device to milliseconds
3337 MCI_SET_PARMS setParms
;
3338 setParms
.dwCallback
= 0;
3339 setParms
.dwTimeFormat
= MCI_FORMAT_MILLISECONDS
;
3341 if (mciSendCommand(m_hDev
, MCI_SET
, MCI_SET_TIME_FORMAT
,
3342 (DWORD
)(LPVOID
)&setParms
) != 0)
3346 //Now tell the MCI device to display the video in our wxMediaCtrl
3348 MCI_DGV_WINDOW_PARMS windowParms
;
3349 windowParms
.hWnd
= (HWND
)m_ctrl
->GetHandle();
3351 m_bVideo
= (mciSendCommand(m_hDev
, MCI_WINDOW
,
3352 0x00010000L
, //MCI_DGV_WINDOW_HWND
3353 (DWORD
)(LPVOID
)&windowParms
) == 0);
3356 // Create a hidden window and register to handle
3358 // Note that wxCanvasClassName is already registered
3359 // and used by all wxWindows and normal wxControls
3361 m_hNotifyWnd
= ::CreateWindow
3375 wxLogSysError( wxT("Could not create hidden needed for ")
3376 wxT("registering for MCI events!") );
3381 wxSetWindowProc(m_hNotifyWnd
, wxMCIMediaBackend::NotifyWndProc
);
3382 wxSetWindowUserData(m_hNotifyWnd
, this);
3385 //Here, if the parent of the control has a sizer - we
3386 //tell it to recalculate the size of this control since
3387 //the user opened a separate media file
3389 m_ctrl
->InvalidateBestSize();
3390 m_ctrl
->GetParent()->Layout();
3391 m_ctrl
->GetParent()->Refresh();
3392 m_ctrl
->GetParent()->Update();
3393 m_ctrl
->SetSize(m_ctrl
->GetSize());
3396 wxMediaEvent
theEvent(wxEVT_MEDIA_LOADED
,
3398 m_ctrl
->AddPendingEvent(theEvent
);
3403 //---------------------------------------------------------------------------
3404 // wxMCIMediaBackend::Load (URL version)
3406 // MCI doesn't support URLs directly (?)
3408 // TODO: Use wxURL/wxFileSystem and mmioInstallProc
3409 //---------------------------------------------------------------------------
3410 bool wxMCIMediaBackend::Load(const wxURI
& WXUNUSED(location
))
3415 //---------------------------------------------------------------------------
3416 // wxMCIMediaBackend::Play
3418 // Plays/Resumes the MCI device... a couple notes:
3419 // 1) Certain drivers will crash and burn if we don't pass them an
3420 // MCI_PLAY_PARMS, despite the documentation that says otherwise...
3421 // 2) There is a MCI_RESUME command, but MCI_PLAY does the same thing
3422 // and will resume from a stopped state also, so there's no need to
3423 // call both, for example
3424 //---------------------------------------------------------------------------
3425 bool wxMCIMediaBackend::Play()
3427 MCI_PLAY_PARMS playParms
;
3428 playParms
.dwCallback
= (DWORD
)m_hNotifyWnd
;
3430 bool bOK
= ( mciSendCommand(m_hDev
, MCI_PLAY
, MCI_NOTIFY
,
3431 (DWORD
)(LPVOID
)&playParms
) == 0 );
3434 m_ctrl
->Show(m_bVideo
);
3439 //---------------------------------------------------------------------------
3440 // wxMCIMediaBackend::Pause
3442 // Pauses the MCI device - nothing special
3443 //---------------------------------------------------------------------------
3444 bool wxMCIMediaBackend::Pause()
3446 return (mciSendCommand(m_hDev
, MCI_PAUSE
, MCI_WAIT
, 0) == 0);
3449 //---------------------------------------------------------------------------
3450 // wxMCIMediaBackend::Stop
3452 // Stops the MCI device & seeks to the beginning as wxMediaCtrl docs outline
3453 //---------------------------------------------------------------------------
3454 bool wxMCIMediaBackend::Stop()
3456 return (mciSendCommand(m_hDev
, MCI_STOP
, MCI_WAIT
, 0) == 0) &&
3457 (mciSendCommand(m_hDev
, MCI_SEEK
, MCI_SEEK_TO_START
, 0) == 0);
3460 //---------------------------------------------------------------------------
3461 // wxMCIMediaBackend::GetState
3463 // Here we get the state and convert it to a wxMediaState -
3464 // since we use direct comparisons with MCI_MODE_PLAY and
3465 // MCI_MODE_PAUSE, we don't care if the MCI_STATUS call
3467 //---------------------------------------------------------------------------
3468 wxMediaState
wxMCIMediaBackend::GetState()
3470 MCI_STATUS_PARMS statusParms
;
3471 statusParms
.dwItem
= MCI_STATUS_MODE
;
3473 mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
3474 (DWORD
)(LPVOID
)&statusParms
);
3476 if(statusParms
.dwReturn
== MCI_MODE_PAUSE
)
3477 return wxMEDIASTATE_PAUSED
;
3478 else if(statusParms
.dwReturn
== MCI_MODE_PLAY
)
3479 return wxMEDIASTATE_PLAYING
;
3481 return wxMEDIASTATE_STOPPED
;
3484 //---------------------------------------------------------------------------
3485 // wxMCIMediaBackend::SetPosition
3487 // Here we set the position of the device in the stream.
3488 // Note that MCI actually stops the device after you seek it if the
3489 // device is playing/paused, so we need to play the file after
3490 // MCI seeks like normal APIs would
3491 //---------------------------------------------------------------------------
3492 bool wxMCIMediaBackend::SetPosition(wxLongLong where
)
3494 MCI_SEEK_PARMS seekParms
;
3495 seekParms
.dwCallback
= 0;
3496 #if wxUSE_LONGLONG_NATIVE && !wxUSE_LONGLONG_WX
3497 seekParms
.dwTo
= (DWORD
)where
.GetValue();
3498 #else /* wxUSE_LONGLONG_WX */
3499 /* no way to return it in one piece */
3500 wxASSERT( where
.GetHi()==0 );
3501 seekParms
.dwTo
= (DWORD
)where
.GetLo();
3502 #endif /* wxUSE_LONGLONG_* */
3504 //device was playing?
3505 bool bReplay
= GetState() == wxMEDIASTATE_PLAYING
;
3507 if( mciSendCommand(m_hDev
, MCI_SEEK
, MCI_TO
,
3508 (DWORD
)(LPVOID
)&seekParms
) != 0)
3511 //If the device was playing, resume it
3518 //---------------------------------------------------------------------------
3519 // wxMCIMediaBackend::GetPosition
3521 // Gets the position of the device in the stream using the current
3522 // time format... nothing special here...
3523 //---------------------------------------------------------------------------
3524 wxLongLong
wxMCIMediaBackend::GetPosition()
3526 MCI_STATUS_PARMS statusParms
;
3527 statusParms
.dwItem
= MCI_STATUS_POSITION
;
3529 if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
3530 (DWORD
)(LPSTR
)&statusParms
) != 0)
3533 return statusParms
.dwReturn
;
3536 //---------------------------------------------------------------------------
3537 // wxMCIMediaBackend::GetVolume
3539 // Gets the volume of the current media via the MCI_DGV_STATUS_VOLUME
3540 // message. Value ranges from 0 (minimum) to 1000 (maximum volume).
3541 //---------------------------------------------------------------------------
3542 double wxMCIMediaBackend::GetVolume()
3544 MCI_STATUS_PARMS statusParms
;
3545 statusParms
.dwCallback
= 0;
3546 statusParms
.dwItem
= 0x4019; //MCI_DGV_STATUS_VOLUME
3548 if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
3549 (DWORD
)(LPSTR
)&statusParms
) != 0)
3552 return ((double)statusParms
.dwReturn
) / 1000.0;
3555 //---------------------------------------------------------------------------
3556 // wxMCIMediaBackend::SetVolume
3558 // Sets the volume of the current media via the MCI_DGV_SETAUDIO_VOLUME
3559 // message. Value ranges from 0 (minimum) to 1000 (maximum volume).
3560 //---------------------------------------------------------------------------
3561 bool wxMCIMediaBackend::SetVolume(double dVolume
)
3563 MCI_DGV_SETAUDIO_PARMS audioParms
;
3564 audioParms
.dwCallback
= 0;
3565 audioParms
.dwItem
= 0x4002; //MCI_DGV_SETAUDIO_VOLUME
3566 audioParms
.dwValue
= (DWORD
) (dVolume
* 1000.0);
3567 audioParms
.dwOver
= 0;
3568 audioParms
.lpstrAlgorithm
= NULL
;
3569 audioParms
.lpstrQuality
= NULL
;
3571 if (mciSendCommand(m_hDev
, 0x0873, //MCI_SETAUDIO
3572 //MCI_DGV_SETAUDIO+(_ITEM | _VALUE)
3573 0x00800000L
| 0x01000000L
,
3574 (DWORD
)(LPSTR
)&audioParms
) != 0)
3579 //---------------------------------------------------------------------------
3580 // wxMCIMediaBackend::GetDuration
3582 // Gets the duration of the stream... nothing special
3583 //---------------------------------------------------------------------------
3584 wxLongLong
wxMCIMediaBackend::GetDuration()
3586 MCI_STATUS_PARMS statusParms
;
3587 statusParms
.dwItem
= MCI_STATUS_LENGTH
;
3589 if (mciSendCommand(m_hDev
, MCI_STATUS
, MCI_STATUS_ITEM
,
3590 (DWORD
)(LPSTR
)&statusParms
) != 0)
3593 return statusParms
.dwReturn
;
3596 //---------------------------------------------------------------------------
3597 // wxMCIMediaBackend::Move
3599 // Moves the window to a location
3600 //---------------------------------------------------------------------------
3601 void wxMCIMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
),
3604 if (m_hNotifyWnd
&& m_bVideo
)
3606 MCI_DGV_RECT_PARMS putParms
; //ifdefed MCI_DGV_PUT_PARMS
3607 memset(&putParms
, 0, sizeof(MCI_DGV_RECT_PARMS
));
3608 putParms
.rc
.bottom
= h
;
3609 putParms
.rc
.right
= w
;
3611 //wxStackWalker will crash and burn here on assert
3612 //and mci doesn't like 0 and 0 for some reason (out of range )
3613 //so just don't it in that case
3616 wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_PUT
,
3617 0x00040000L
, //MCI_DGV_PUT_DESTINATION
3618 (DWORD
)(LPSTR
)&putParms
) );
3623 //---------------------------------------------------------------------------
3624 // wxMCIMediaBackend::GetVideoSize
3626 // Gets the original size of the movie for sizers
3627 //---------------------------------------------------------------------------
3628 wxSize
wxMCIMediaBackend::GetVideoSize() const
3632 MCI_DGV_RECT_PARMS whereParms
; //ifdefed MCI_DGV_WHERE_PARMS
3634 wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_WHERE
,
3635 0x00020000L
, //MCI_DGV_WHERE_SOURCE
3636 (DWORD
)(LPSTR
)&whereParms
) );
3638 return wxSize(whereParms
.rc
.right
, whereParms
.rc
.bottom
);
3643 //---------------------------------------------------------------------------
3644 // wxMCIMediaBackend::GetPlaybackRate
3647 //---------------------------------------------------------------------------
3648 double wxMCIMediaBackend::GetPlaybackRate()
3653 //---------------------------------------------------------------------------
3654 // wxMCIMediaBackend::SetPlaybackRate
3657 //---------------------------------------------------------------------------
3658 bool wxMCIMediaBackend::SetPlaybackRate(double WXUNUSED(dRate
))
3661 MCI_WAVE_SET_SAMPLESPERSEC
3662 MCI_DGV_SET_PARMS setParms;
3663 setParms.dwSpeed = (DWORD) (dRate * 1000.0);
3665 return (mciSendCommand(m_hDev, MCI_SET,
3666 0x00020000L, //MCI_DGV_SET_SPEED
3667 (DWORD)(LPSTR)&setParms) == 0);
3672 //---------------------------------------------------------------------------
3673 // [static] wxMCIMediaBackend::MSWWindowProc
3675 // Here we process a message when MCI reaches the stopping point
3677 //---------------------------------------------------------------------------
3678 LRESULT CALLBACK
wxMCIMediaBackend::NotifyWndProc(HWND hWnd
, UINT nMsg
,
3682 wxMCIMediaBackend
* backend
=
3683 (wxMCIMediaBackend
*)wxGetWindowUserData(hWnd
);
3685 return backend
->OnNotifyWndProc(hWnd
, nMsg
, wParam
, lParam
);
3688 LRESULT CALLBACK
wxMCIMediaBackend::OnNotifyWndProc(HWND hWnd
, UINT nMsg
,
3692 if(nMsg
== MM_MCINOTIFY
)
3694 wxASSERT(lParam
== (LPARAM
) m_hDev
);
3695 if(wParam
== MCI_NOTIFY_SUCCESSFUL
&& lParam
== (LPARAM
)m_hDev
)
3697 wxMediaEvent
theEvent(wxEVT_MEDIA_STOP
, m_ctrl
->GetId());
3698 m_ctrl
->ProcessEvent(theEvent
);
3700 if(theEvent
.IsAllowed())
3702 wxMCIVERIFY( mciSendCommand(m_hDev
, MCI_SEEK
,
3703 MCI_SEEK_TO_START
, 0) );
3705 //send the event to our child
3706 wxMediaEvent
theEvent(wxEVT_MEDIA_FINISHED
,
3708 m_ctrl
->ProcessEvent(theEvent
);
3712 return DefWindowProc(hWnd
, nMsg
, wParam
, lParam
);
3715 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3719 // TODO: Use a less cludgy way to pause/get state/set state
3720 // FIXME: Greg Hazel reports that sometimes files that cannot be played
3721 // with this backend are treated as playable anyway - not verifyed though.
3722 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3724 IMPLEMENT_DYNAMIC_CLASS(wxQTMediaBackend
, wxMediaBackend
);
3726 //Time between timer calls - this is the Apple recommondation to the TCL
3728 #define MOVIE_DELAY 20
3730 #include "wx/timer.h"
3733 //---------------------------------------------------------------------------
3736 // QT, esp. QT for Windows is very picky about how you go about
3737 // async loading. If you were to go through a Windows message loop
3738 // or a MoviesTask or both and then check the movie load state
3739 // it would still return 1000 (loading)... even (pre)prerolling doesn't
3740 // help. However, making a load timer like this works
3741 //---------------------------------------------------------------------------
3742 class wxQTLoadTimer
: public wxTimer
3745 wxQTLoadTimer(Movie movie
, wxQTMediaBackend
* parent
, wxQuickTimeLibrary
* pLib
) :
3746 m_movie(movie
), m_parent(parent
), m_pLib(pLib
) {}
3750 m_pLib
->MoviesTask(m_movie
, 0);
3751 //kMovieLoadStatePlayable
3752 if(m_pLib
->GetMovieLoadState(m_movie
) >= 10000)
3754 m_parent
->FinishLoad();
3760 Movie m_movie
; //Our movie instance
3761 wxQTMediaBackend
* m_parent
; //Backend pointer
3762 wxQuickTimeLibrary
* m_pLib
; //Interfaces
3766 // --------------------------------------------------------------------------
3767 // wxQTPlayTimer - Handle Asyncronous Playing
3769 // 1) Checks to see if the movie is done, and if not continues
3770 // streaming the movie
3771 // 2) Sends the wxEVT_MEDIA_STOP event if we have reached the end of
3773 // --------------------------------------------------------------------------
3774 class wxQTPlayTimer
: public wxTimer
3777 wxQTPlayTimer(Movie movie
, wxQTMediaBackend
* parent
,
3778 wxQuickTimeLibrary
* pLib
) :
3779 m_movie(movie
), m_parent(parent
), m_pLib(pLib
) {}
3784 // OK, a little explaining - basically originally
3785 // we only called MoviesTask if the movie was actually
3786 // playing (not paused or stopped)... this was before
3787 // we realized MoviesTask actually handles repainting
3788 // of the current frame - so if you were to resize
3789 // or something it would previously not redraw that
3790 // portion of the movie.
3792 // So now we call MoviesTask always so that it repaints
3795 m_pLib
->MoviesTask(m_movie
, 0);
3798 // Handle the stop event - if the movie has reached
3799 // the end, notify our handler
3801 // m_bPlaying == !(Stopped | Paused)
3803 if (m_parent
->m_bPlaying
)
3805 if(m_pLib
->IsMovieDone(m_movie
))
3807 wxMediaEvent
theEvent(wxEVT_MEDIA_STOP
,
3808 m_parent
->m_ctrl
->GetId());
3809 m_parent
->m_ctrl
->ProcessEvent(theEvent
);
3811 if(theEvent
.IsAllowed())
3814 wxASSERT(m_pLib
->GetMoviesError() == noErr
);
3816 //send the event to our child
3817 wxMediaEvent
theEvent(wxEVT_MEDIA_FINISHED
,
3818 m_parent
->m_ctrl
->GetId());
3819 m_parent
->m_ctrl
->AddPendingEvent(theEvent
);
3826 Movie m_movie
; //Our movie instance
3827 wxQTMediaBackend
* m_parent
; //Backend pointer
3828 wxQuickTimeLibrary
* m_pLib
; //Interfaces
3832 //---------------------------------------------------------------------------
3833 // wxQTMediaBackend::QTWndProc
3835 // Forwards events to the Movie Controller so that it can
3836 // redraw itself/process messages etc..
3837 //---------------------------------------------------------------------------
3838 LRESULT CALLBACK
wxQTMediaBackend::QTWndProc(HWND hWnd
, UINT nMsg
,
3839 WPARAM wParam
, LPARAM lParam
)
3841 wxQTMediaBackend
* pThis
= (wxQTMediaBackend
*)wxGetWindowUserData(hWnd
);
3846 msg
.wParam
= wParam
;
3847 msg
.lParam
= lParam
;
3851 EventRecord theEvent
;
3852 pThis
->m_lib
.NativeEventToMacEvent(&msg
, &theEvent
);
3853 pThis
->m_lib
.MCIsPlayerEvent(pThis
->m_pMC
, &theEvent
);
3854 return pThis
->m_ctrl
->MSWWindowProc(nMsg
, wParam
, lParam
);
3857 //---------------------------------------------------------------------------
3858 // wxQTMediaBackend Destructor
3860 // Sets m_timer to NULL signifying we havn't loaded anything yet
3861 //---------------------------------------------------------------------------
3862 wxQTMediaBackend::wxQTMediaBackend()
3863 : m_movie(NULL
), m_bPlaying(false), m_timer(NULL
), m_pMC(NULL
)
3867 //---------------------------------------------------------------------------
3868 // wxQTMediaBackend Destructor
3870 // 1) Cleans up the QuickTime movie instance
3871 // 2) Decrements the QuickTime reference counter - if this reaches
3872 // 0, QuickTime shuts down
3873 // 3) Decrements the QuickTime Windows Media Layer reference counter -
3874 // if this reaches 0, QuickTime shuts down the Windows Media Layer
3875 //---------------------------------------------------------------------------
3876 wxQTMediaBackend::~wxQTMediaBackend()
3885 m_lib
.DisposeMovieController(m_pMC
);
3889 m_lib
.DestroyPortAssociation(
3890 (CGrafPtr
)m_lib
.GetNativeWindowPort(m_ctrl
->GetHWND()));
3892 //Note that ExitMovies() is not necessary, but
3893 //the docs are fuzzy on whether or not TerminateQTML is
3895 m_lib
.TerminateQTML();
3899 //---------------------------------------------------------------------------
3900 // wxQTMediaBackend::CreateControl
3902 // 1) Intializes QuickTime
3903 // 2) Creates the control window
3904 //---------------------------------------------------------------------------
3905 bool wxQTMediaBackend::CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
3910 const wxValidator
& validator
,
3911 const wxString
& name
)
3913 if(!m_lib
.Initialize())
3916 int nError
= m_lib
.InitializeQTML(0);
3917 if (nError
!= noErr
) //-2093 no dll
3919 wxFAIL_MSG(wxString::Format(wxT("Couldn't Initialize Quicktime-%i"),
3923 m_lib
.EnterMovies();
3927 // By default wxWindow(s) is created with a border -
3928 // so we need to get rid of those
3930 // Since we don't have a child window like most other
3931 // backends, we don't need wxCLIP_CHILDREN
3933 if ( !ctrl
->wxControl::Create(parent
, id
, pos
, size
,
3934 (style
& ~wxBORDER_MASK
) | wxBORDER_NONE
,
3939 m_ctrl
= ctrl
; //assign the control to our member
3941 // Create a port association for our window so we
3942 // can use it as a WindowRef
3943 m_lib
.CreatePortAssociation(m_ctrl
->GetHWND(), NULL
, 0L);
3945 //Part of a suggestion from Greg Hazel to repaint
3947 m_ctrl
->Connect(m_ctrl
->GetId(), wxEVT_ERASE_BACKGROUND
,
3948 wxEraseEventHandler(wxQTMediaEvtHandler::OnEraseBackground
),
3949 NULL
, (wxEvtHandler
*) this);
3955 //---------------------------------------------------------------------------
3956 // wxQTMediaBackend::Load (file version)
3958 // 1) Get an FSSpec from the Windows path name
3959 // 2) Open the movie
3960 // 3) Obtain the movie instance from the movie resource
3961 // 4) Close the movie resource
3962 // 5) Finish loading
3963 //---------------------------------------------------------------------------
3964 bool wxQTMediaBackend::Load(const wxString
& fileName
)
3969 short movieResFile
= 0; //= 0 because of annoying VC6 warning
3972 if (m_lib
.NativePathNameToFSSpec ((char*) (const char*) fileName
.mb_str(),
3973 &sfFile
, 0) != noErr
)
3976 if (m_lib
.OpenMovieFile (&sfFile
, &movieResFile
, fsRdPerm
) != noErr
)
3979 short movieResID
= 0;
3982 OSErr err
= m_lib
.NewMovieFromFile (
3991 //m_lib.GetMoviesStickyError() because it may not find the
3992 //proper codec and play black video and other strange effects,
3993 //not to mention mess up the dynamic backend loading scheme
3994 //of wxMediaCtrl - so it just does what the QuickTime player does
3995 if(err
== noErr
&& m_lib
.GetMoviesStickyError() == noErr
)
3997 m_lib
.CloseMovieFile (movieResFile
);
4007 //---------------------------------------------------------------------------
4008 // wxQTMediaBackend::PPRMProc (static)
4010 // Called when done PrePrerolling the movie.
4011 // Note that in 99% of the cases this does nothing...
4012 // Anyway we set up the loading timer here to tell us when the movie is done
4013 //---------------------------------------------------------------------------
4014 void wxQTMediaBackend::PPRMProc (Movie theMovie
,
4015 OSErr
WXUNUSED_UNLESS_DEBUG(theErr
),
4018 wxASSERT( theMovie
);
4019 wxASSERT( theRefCon
);
4020 wxASSERT( theErr
== noErr
);
4022 wxQTMediaBackend
* pBE
= (wxQTMediaBackend
*) theRefCon
;
4024 long lTime
= pBE
->m_lib
.GetMovieTime(theMovie
,NULL
);
4025 Fixed rate
= pBE
->m_lib
.GetMoviePreferredRate(theMovie
);
4026 pBE
->m_lib
.PrerollMovie(theMovie
,lTime
,rate
);
4027 pBE
->m_timer
= new wxQTLoadTimer(pBE
->m_movie
, pBE
, &pBE
->m_lib
);
4028 pBE
->m_timer
->Start(MOVIE_DELAY
);
4032 //---------------------------------------------------------------------------
4033 // wxQTMediaBackend::Load (URL Version)
4035 // 1) Build an escaped URI from location
4036 // 2) Create a handle to store the URI string
4037 // 3) Put the URI string inside the handle
4038 // 4) Make a QuickTime URL data ref from the handle with the URI in it
4039 // 5) Clean up the URI string handle
4040 // 6) Do some prerolling
4041 // 7) Finish Loading
4042 //---------------------------------------------------------------------------
4043 bool wxQTMediaBackend::Load(const wxURI
& location
)
4048 wxString theURI
= location
.BuildURI();
4050 Handle theHandle
= m_lib
.NewHandleClear(theURI
.length() + 1);
4051 wxASSERT(theHandle
);
4053 m_lib
.BlockMove(theURI
.mb_str(), *theHandle
, theURI
.length() + 1);
4055 //create the movie from the handle that refers to the URI
4056 OSErr err
= m_lib
.NewMovieFromDataRef(&m_movie
, newMovieActive
|
4058 /*|newMovieIdleImportOK*/,
4060 URLDataHandlerSubType
);
4062 m_lib
.DisposeHandle(theHandle
);
4069 timeNow
= m_lib
.GetMovieTime(m_movie
, NULL
);
4070 wxASSERT(m_lib
.GetMoviesError() == noErr
);
4072 playRate
= m_lib
.GetMoviePreferredRate(m_movie
);
4073 wxASSERT(m_lib
.GetMoviesError() == noErr
);
4076 // Note that the callback here is optional,
4077 // but without it PrePrerollMovie can be buggy
4078 // (see Apple ml). Also, some may wonder
4079 // why we need this at all - this is because
4080 // Apple docs say QuickTime streamed movies
4081 // require it if you don't use a Movie Controller,
4082 // which we don't by default.
4084 m_lib
.PrePrerollMovie(m_movie
, timeNow
, playRate
,
4085 (WXFARPROC
)wxQTMediaBackend::PPRMProc
,
4094 //---------------------------------------------------------------------------
4095 // wxQTMediaBackend::FinishLoad
4097 // 1) Create the movie timer
4098 // 2) Get real size of movie for GetBestSize/sizers
4099 // 3) Set the movie time scale to something usable so that seeking
4100 // etc. will work correctly
4101 // 4) Set our Movie Controller to display the movie if it exists,
4102 // otherwise set the bounds of the Movie
4103 // 5) Refresh parent window
4104 //---------------------------------------------------------------------------
4105 void wxQTMediaBackend::FinishLoad()
4107 // Create the playing/streaming timer
4108 m_timer
= new wxQTPlayTimer(m_movie
, (wxQTMediaBackend
*) this, &m_lib
);
4110 m_timer
->Start(MOVIE_DELAY
, wxTIMER_CONTINUOUS
);
4112 //get the real size of the movie
4114 memset(&outRect
, 0, sizeof(Rect
)); //for annoying VC6 warning
4115 m_lib
.GetMovieNaturalBoundsRect (m_movie
, &outRect
);
4116 wxASSERT(m_lib
.GetMoviesError() == noErr
);
4118 m_bestSize
.x
= outRect
.right
- outRect
.left
;
4119 m_bestSize
.y
= outRect
.bottom
- outRect
.top
;
4122 // Handle the movie GWorld
4127 thePoint
.h
= thePoint
.v
= 0;
4128 m_lib
.MCSetMovie(m_pMC
, m_movie
,
4129 m_lib
.GetNativeWindowPort(m_ctrl
->GetHandle()),
4131 m_lib
.MCSetVisible(m_pMC
, true);
4136 m_lib
.SetMovieGWorld(m_movie
,
4137 (CGrafPtr
) m_lib
.GetNativeWindowPort(m_ctrl
->GetHWND()),
4142 // Set the movie to millisecond precision
4144 m_lib
.SetMovieTimeScale(m_movie
, 1000);
4145 wxASSERT(m_lib
.GetMoviesError() == noErr
);
4148 //Here, if the parent of the control has a sizer - we
4149 //tell it to recalculate the size of this control since
4150 //the user opened a separate media file
4152 m_ctrl
->InvalidateBestSize();
4153 m_ctrl
->GetParent()->Layout();
4154 m_ctrl
->GetParent()->Refresh();
4155 m_ctrl
->GetParent()->Update();
4156 m_ctrl
->SetSize(m_ctrl
->GetSize());
4158 //loaded - note that MoviesTask must and will be called before this
4159 //by the previous timer since this gets appended to the event list after
4160 //the timer's first go
4161 wxMediaEvent
theEvent(wxEVT_MEDIA_LOADED
,
4163 m_ctrl
->AddPendingEvent(theEvent
);
4166 //---------------------------------------------------------------------------
4167 // wxQTMediaBackend::Play
4169 // 1) Start the QT movie
4170 // 2) Start the movie loading timer
4172 // NOTE: This will still return success even when
4173 // the movie is still loading, and as mentioned in wxQTLoadTimer
4174 // I don't know of a way to force this to be sync - so if its
4175 // still loading the function will return true but the movie will
4176 // still be in the stopped state
4177 //---------------------------------------------------------------------------
4178 bool wxQTMediaBackend::Play()
4180 m_lib
.StartMovie(m_movie
);
4182 return m_lib
.GetMoviesError() == noErr
;
4185 //---------------------------------------------------------------------------
4186 // wxQTMediaBackend::Pause
4188 // 1) Stop the movie
4189 // 2) Stop the movie timer
4190 //---------------------------------------------------------------------------
4191 bool wxQTMediaBackend::Pause()
4194 m_lib
.StopMovie(m_movie
);
4195 return m_lib
.GetMoviesError() == noErr
;
4198 //---------------------------------------------------------------------------
4199 // wxQTMediaBackend::Stop
4201 // 1) Stop the movie
4202 // 2) Stop the movie timer
4203 // 3) Seek to the beginning of the movie
4204 //---------------------------------------------------------------------------
4205 bool wxQTMediaBackend::Stop()
4209 m_lib
.StopMovie(m_movie
);
4210 if(m_lib
.GetMoviesError() != noErr
)
4213 m_lib
.GoToBeginningOfMovie(m_movie
);
4214 return m_lib
.GetMoviesError() == noErr
;
4217 //---------------------------------------------------------------------------
4218 // wxQTMediaBackend::GetPlaybackRate
4220 // 1) Get the movie playback rate from ::GetMovieRate
4221 //---------------------------------------------------------------------------
4222 double wxQTMediaBackend::GetPlaybackRate()
4224 return ( ((double)m_lib
.GetMovieRate(m_movie
)) / 0x10000);
4227 //---------------------------------------------------------------------------
4228 // wxQTMediaBackend::SetPlaybackRate
4230 // 1) Convert dRate to Fixed and Set the movie rate through SetMovieRate
4231 //---------------------------------------------------------------------------
4232 bool wxQTMediaBackend::SetPlaybackRate(double dRate
)
4234 m_lib
.SetMovieRate(m_movie
, (Fixed
) (dRate
* 0x10000));
4235 return m_lib
.GetMoviesError() == noErr
;
4238 //---------------------------------------------------------------------------
4239 // wxQTMediaBackend::SetPosition
4241 // 1) Create a time record struct (TimeRecord) with appropriate values
4242 // 2) Pass struct to SetMovieTime
4243 //---------------------------------------------------------------------------
4244 bool wxQTMediaBackend::SetPosition(wxLongLong where
)
4246 //NB: For some reason SetMovieTime does not work
4247 //correctly with the Quicktime Windows SDK (6)
4248 //From Muskelkatermann at the wxForum
4249 //http://www.solidsteel.nl/users/wxwidgets/viewtopic.php?t=2957
4250 //RN - note that I have not verified this but there
4251 //is no harm in calling SetMovieTimeValue instead
4253 TimeRecord theTimeRecord
;
4254 memset(&theTimeRecord
, 0, sizeof(TimeRecord
));
4255 theTimeRecord
.value
.lo
= where
.GetLo();
4256 theTimeRecord
.scale
= m_lib
.GetMovieTimeScale(m_movie
);
4257 theTimeRecord
.base
= m_lib
.GetMovieTimeBase(m_movie
);
4258 m_lib
.SetMovieTime(m_movie
, &theTimeRecord
);
4260 m_lib
.SetMovieTimeValue(m_movie
, where
.GetLo());
4262 if (m_lib
.GetMoviesError() != noErr
)
4268 //---------------------------------------------------------------------------
4269 // wxQTMediaBackend::GetPosition
4271 // 1) Calls GetMovieTime to get the position we are in in the movie
4272 // in milliseconds (we called
4273 //---------------------------------------------------------------------------
4274 wxLongLong
wxQTMediaBackend::GetPosition()
4276 return m_lib
.GetMovieTime(m_movie
, NULL
);
4279 //---------------------------------------------------------------------------
4280 // wxQTMediaBackend::GetVolume
4282 // Gets the volume through GetMovieVolume - which returns a 16 bit short -
4284 // +--------+--------+
4286 // +--------+--------+
4288 // (1) first 8 bits are value before decimal
4289 // (2) second 8 bits are value after decimal
4291 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to
4292 // 1 (full gain and sound)
4293 //---------------------------------------------------------------------------
4294 double wxQTMediaBackend::GetVolume()
4296 short sVolume
= m_lib
.GetMovieVolume(m_movie
);
4297 wxASSERT(m_lib
.GetMoviesError() == noErr
);
4299 if(sVolume
& (128 << 8)) //negative - no sound
4302 return sVolume
/256.0;
4305 //---------------------------------------------------------------------------
4306 // wxQTMediaBackend::SetVolume
4308 // Sets the volume through SetMovieVolume - which takes a 16 bit short -
4310 // +--------+--------+
4312 // +--------+--------+
4314 // (1) first 8 bits are value before decimal
4315 // (2) second 8 bits are value after decimal
4317 // Volume ranges from -1.0 (gain but no sound), 0 (no sound and no gain) to
4318 // 1 (full gain and sound)
4319 //---------------------------------------------------------------------------
4320 bool wxQTMediaBackend::SetVolume(double dVolume
)
4322 m_lib
.SetMovieVolume(m_movie
, (short) (dVolume
* 256));
4323 return m_lib
.GetMoviesError() == noErr
;
4326 //---------------------------------------------------------------------------
4327 // wxQTMediaBackend::GetDuration
4329 // Calls GetMovieDuration
4330 //---------------------------------------------------------------------------
4331 wxLongLong
wxQTMediaBackend::GetDuration()
4333 return m_lib
.GetMovieDuration(m_movie
);
4336 //---------------------------------------------------------------------------
4337 // wxQTMediaBackend::GetState
4339 // Determines the current state - if we are at the beginning we
4341 //---------------------------------------------------------------------------
4342 wxMediaState
wxQTMediaBackend::GetState()
4344 if (m_bPlaying
== true)
4345 return wxMEDIASTATE_PLAYING
;
4346 else if ( !m_movie
|| wxQTMediaBackend::GetPosition() == 0)
4347 return wxMEDIASTATE_STOPPED
;
4349 return wxMEDIASTATE_PAUSED
;
4352 //---------------------------------------------------------------------------
4353 // wxQTMediaBackend::Cleanup
4355 // Diposes of the movie timer, Disassociates the Movie Controller with
4356 // movie and hides it if it exists, and stops and disposes
4358 //---------------------------------------------------------------------------
4359 void wxQTMediaBackend::Cleanup()
4369 m_lib
.StopMovie(m_movie
);
4374 thePoint
.h
= thePoint
.v
= 0;
4375 m_lib
.MCSetVisible(m_pMC
, false);
4376 m_lib
.MCSetMovie(m_pMC
, NULL
, NULL
, thePoint
);
4379 m_lib
.DisposeMovie(m_movie
);
4383 //---------------------------------------------------------------------------
4384 // wxQTMediaBackend::ShowPlayerControls
4386 // Creates a movie controller for the Movie if the user wants it
4387 //---------------------------------------------------------------------------
4388 bool wxQTMediaBackend::ShowPlayerControls(wxMediaCtrlPlayerControls flags
)
4392 //restore old wndproc
4393 wxSetWindowProc((HWND
)m_ctrl
->GetHWND(), wxWndProc
);
4394 m_lib
.DisposeMovieController(m_pMC
);
4396 m_bestSize
.y
-= 16; //movie controller height
4399 if(flags
&& m_movie
)
4402 wxRect wxrect
= m_ctrl
->GetClientRect();
4404 //make room for controller
4405 if(wxrect
.width
< 320)
4408 rect
.top
= (short)wxrect
.y
;
4409 rect
.left
= (short)wxrect
.x
;
4410 rect
.right
= (short)(rect
.left
+ wxrect
.width
);
4411 rect
.bottom
= (short)(rect
.top
+ wxrect
.height
);
4415 m_pMC
= m_lib
.NewMovieController(m_movie
, &rect
, mcTopLeftMovie
|
4416 // mcScaleMovieToFit |
4419 m_lib
.MCDoAction(m_pMC
, 32, (void*)true); //mcActionSetKeysEnabled
4420 m_lib
.MCSetActionFilterWithRefCon(m_pMC
,
4421 (WXFARPROC
)wxQTMediaBackend::MCFilterProc
, (void*)this);
4422 m_bestSize
.y
+= 16; //movie controller height
4425 // By default the movie controller uses its own color
4426 // pallette for the movie which can be bad on some files -
4427 // so turn it off. Also turn off its frame/border for
4430 // Also we take care of a couple of the interface flags here
4433 m_lib
.MCDoAction(m_pMC
, 39/*mcActionGetFlags*/, (void*)&mcFlags
);
4434 mcFlags
|= ( //(1<<0)/*mcFlagSuppressMovieFrame*/ |
4435 (1<<3)/*mcFlagsUseWindowPalette*/
4436 | ((flags
& wxMEDIACTRLPLAYERCONTROLS_STEP
)
4437 ? 0 : (1<<1)/*mcFlagSuppressStepButtons*/)
4438 | ((flags
& wxMEDIACTRLPLAYERCONTROLS_VOLUME
)
4439 ? 0 : (1<<2)/*mcFlagSuppressSpeakerButton*/)
4440 // | (1<<4) /*mcFlagDontInvalidate*/ //if we take care of repainting ourselves
4442 m_lib
.MCDoAction(m_pMC
, 38/*mcActionSetFlags*/, (void*)mcFlags
);
4444 //intercept the wndproc of our control window
4445 wxSetWindowProc((HWND
)m_ctrl
->GetHWND(),
4446 wxQTMediaBackend::QTWndProc
);
4448 //set the user data of our window
4449 wxSetWindowUserData((HWND
)m_ctrl
->GetHWND(), this);
4454 //Here, if the parent of the control has a sizer - we
4455 //tell it to recalculate the size of this control since
4456 //the user opened a separate media file
4458 m_ctrl
->InvalidateBestSize();
4459 m_ctrl
->GetParent()->Layout();
4460 m_ctrl
->GetParent()->Refresh();
4461 m_ctrl
->GetParent()->Update();
4462 m_ctrl
->SetSize(m_ctrl
->GetSize());
4464 return m_lib
.GetMoviesError() == noErr
;
4467 //---------------------------------------------------------------------------
4468 // wxQTMediaBackend::MCFilterProc (static)
4470 // Callback for when the movie controller recieves a message
4471 //---------------------------------------------------------------------------
4473 wxQTMediaBackend::MCFilterProc(MovieController
WXUNUSED(theController
),
4475 void * WXUNUSED(params
),
4478 if(action
!= 1) //don't process idle events
4480 wxQTMediaBackend
* pThis
= (wxQTMediaBackend
*)refCon
;
4484 case 8: //play button triggered - MC will set movie to opposite state
4485 //of current - playing ? paused : playing
4486 pThis
->m_bPlaying
= !(pThis
->m_bPlaying
);
4488 // NB: Sometimes it doesn't redraw properly -
4489 // if you click on the button but don't move the mouse
4490 // the button will not change its state until you move
4491 // mcActionDraw and Refresh/Update combo do nothing
4492 // to help this unfortunately
4501 //---------------------------------------------------------------------------
4502 // wxQTMediaBackend::GetVideoSize
4504 // Returns the actual size of the QT movie
4505 //---------------------------------------------------------------------------
4506 wxSize
wxQTMediaBackend::GetVideoSize() const
4511 //---------------------------------------------------------------------------
4512 // wxQTMediaBackend::Move
4514 // Sets the bounds of either the Movie or Movie Controller
4515 //---------------------------------------------------------------------------
4516 void wxQTMediaBackend::Move(int WXUNUSED(x
), int WXUNUSED(y
), int w
, int h
)
4520 //make room for controller
4526 Rect theRect
= {0, 0, (short)h
, (short)w
};
4527 m_lib
.MCSetControllerBoundsRect(m_pMC
, &theRect
);
4531 Rect theRect
= {0, 0, (short)h
, (short)w
};
4532 m_lib
.SetMovieBox(m_movie
, &theRect
);
4535 wxASSERT(m_lib
.GetMoviesError() == noErr
);
4539 //---------------------------------------------------------------------------
4540 // wxQTMediaBackend::OnEraseBackground
4542 // Suggestion from Greg Hazel to repaint the movie when idle
4545 // TODO: We may be repainting too much here - under what exact circumstances
4546 // do we need this? I think Move also repaints correctly for the Movie
4547 // Controller, so in that instance we don't need this either
4548 //---------------------------------------------------------------------------
4549 void wxQTMediaEvtHandler::OnEraseBackground(wxEraseEvent
& evt
)
4551 wxQTMediaBackend
* qtb
= (wxQTMediaBackend
*)this;
4552 wxQuickTimeLibrary
* m_pLib
= &(qtb
->m_lib
);
4556 //repaint movie controller
4557 m_pLib
->MCDoAction(qtb
->m_pMC
, 2 /*mcActionDraw*/,
4558 m_pLib
->GetNativeWindowPort(qtb
->m_ctrl
->GetHWND())
4561 else if(qtb
->m_movie
)
4563 CGrafPtr port
= (CGrafPtr
)m_pLib
->GetNativeWindowPort
4564 (qtb
->m_ctrl
->GetHWND());
4566 m_pLib
->BeginUpdate(port
);
4567 m_pLib
->UpdateMovie(qtb
->m_movie
);
4568 wxASSERT(m_pLib
->GetMoviesError() == noErr
);
4569 m_pLib
->EndUpdate(port
);
4572 evt
.Skip(); //repaint with window background (TODO: maybe !m_movie?)
4575 //---------------------------------------------------------------------------
4577 //---------------------------------------------------------------------------
4579 //in source file that contains stuff you don't directly use
4580 #include <wx/html/forcelnk.h>
4581 FORCE_LINK_ME(basewxmediabackends
);
4583 //---------------------------------------------------------------------------
4584 // End wxMediaCtrl Compilation Guard and this file
4585 //---------------------------------------------------------------------------
4586 #endif //wxUSE_MEDIACTRL