1 ////////////////////////////////////////////////////////////////////////////////
4 // Author: Guilhem Lavaux
5 // Created: February 1998
7 // Copyright: (C) 1998, 1999, 2000 Guilhem Lavaux
8 // License: wxWindows license
9 ////////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "vidwin.h"
15 #include "wx/wxprec.h"
21 #include "wx/stream.h"
22 #include "wx/wfstream.h"
24 #define WXMMEDIA_INTERNAL
34 IMPLEMENT_DYNAMIC_CLASS(wxVideoWindows
, wxVideoBaseDriver
)
36 wxVideoWindows::wxVideoWindows()
40 wxVideoWindows::wxVideoWindows(wxInputStream
& str
)
41 : wxVideoBaseDriver(str
)
43 m_internal
= new wxVIDWinternal
;
45 m_filename
= wxGetTempFileName("wxvid");
49 wxFileOutputStream
temp_file(m_filename
);
55 wxVideoWindows::wxVideoWindows(const wxString
& filename
)
56 : wxVideoBaseDriver(filename
)
58 m_internal
= new wxVIDWinternal
;
59 m_remove_file
= FALSE
;
60 m_filename
= filename
;
66 wxVideoWindows::~wxVideoWindows(void)
68 mciSendCommand(m_internal
->m_dev_id
, MCI_CLOSE
, 0, 0);
74 void wxVideoWindows::OpenFile()
76 MCI_DGV_OPEN_PARMS open_struct
;
79 open_struct
.lpstrDeviceType
= "avivideo";
80 open_struct
.lpstrElementName
= (LPSTR
)(m_filename
.mb_str());
81 open_struct
.hWndParent
= 0;
83 ret
= mciSendCommand(0, MCI_OPEN
,
84 MCI_OPEN_ELEMENT
|MCI_DGV_OPEN_PARENT
|MCI_OPEN_TYPE
|MCI_DGV_OPEN_32BIT
,
85 (DWORD
)(LPVOID
)&open_struct
);
86 m_internal
->m_dev_id
= open_struct
.wDeviceID
;
89 bool wxVideoWindows::Pause()
91 if (m_paused
|| m_stopped
)
94 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PAUSE
, 0, 0) == 0);
97 bool wxVideoWindows::Resume()
99 if (!m_paused
|| m_stopped
)
102 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PAUSE
, 0, 0) == 0);
105 bool wxVideoWindows::IsPaused()
110 bool wxVideoWindows::IsStopped()
115 bool wxVideoWindows::GetSize(wxSize
& size
) const
120 bool wxVideoWindows::Resize(wxUint16 w
, wxUint16 h
)
125 bool wxVideoWindows::IsCapable(wxVideoType v_type
)
127 return (v_type
== wxVIDEO_MSAVI
);
130 bool wxVideoWindows::AttachOutput(wxWindow
& output
)
132 MCI_DGV_WINDOW_PARMS win_struct
;
134 if (!wxVideoBaseDriver::AttachOutput(output
))
137 win_struct
.hWnd
= (HWND
)output
.GetHWND();
138 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
139 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
143 void wxVideoWindows::DetachOutput()
145 MCI_DGV_WINDOW_PARMS win_struct
;
147 wxVideoBaseDriver::DetachOutput();
150 mciSendCommand(m_internal
->m_dev_id
, MCI_WINDOW
,
151 MCI_DGV_WINDOW_HWND
, (DWORD
)(LPVOID
)&win_struct
);
154 bool wxVideoWindows::Play()
159 return (mciSendCommand(m_internal
->m_dev_id
, MCI_PLAY
, 0, NULL
) == 0);
162 bool wxVideoWindows::Stop()
167 return (mciSendCommand(m_internal
->m_dev_id
, MCI_STOP
, 0, NULL
) == 0);