]>
Commit | Line | Data |
---|---|---|
4d6306eb GL |
1 | //////////////////////////////////////////////////////////////////////////////// |
2 | // Name: vidwin.h | |
3 | // Purpose: wxMMedia | |
4 | // Author: Guilhem Lavaux | |
5 | // Created: February 1998 | |
6 | // Updated: | |
ef366f35 | 7 | // Copyright: (C) 1998, 1999, 2000 Guilhem Lavaux |
4d6306eb GL |
8 | // License: wxWindows license |
9 | //////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifdef __GNUG__ | |
12 | #pragma implementation "vidwin.h" | |
13 | #endif | |
14 | ||
4d6306eb | 15 | #include "wx/wxprec.h" |
ebaad2cc GL |
16 | |
17 | #ifndef WX_PRECOMP | |
4d6306eb GL |
18 | #include "wx/wx.h" |
19 | #endif | |
20 | ||
ebaad2cc GL |
21 | #include "wx/stream.h" |
22 | #include "wx/wfstream.h" | |
23 | ||
4d6306eb GL |
24 | #define WXMMEDIA_INTERNAL |
25 | #include <windows.h> | |
26 | #include <mmsystem.h> | |
27 | #include <digitalv.h> | |
4d6306eb GL |
28 | #include "vidwin.h" |
29 | ||
30 | #ifdef __BORLANDC__ | |
31 | #pragma hdrstop | |
32 | #endif | |
33 | ||
ebaad2cc GL |
34 | IMPLEMENT_DYNAMIC_CLASS(wxVideoWindows, wxVideoBaseDriver) |
35 | ||
36 | wxVideoWindows::wxVideoWindows() | |
4d6306eb GL |
37 | { |
38 | } | |
39 | ||
ebaad2cc GL |
40 | wxVideoWindows::wxVideoWindows(wxInputStream& str) |
41 | : wxVideoBaseDriver(str) | |
4d6306eb | 42 | { |
ebaad2cc GL |
43 | m_internal = new wxVIDWinternal; |
44 | m_remove_file = TRUE; | |
45 | m_filename = wxGetTempFileName("wxvid"); | |
46 | m_paused = FALSE; | |
47 | m_stopped = TRUE; | |
48 | ||
49 | wxFileOutputStream temp_file(m_filename); | |
50 | temp_file << str; | |
51 | ||
52 | OpenFile(); | |
4d6306eb GL |
53 | } |
54 | ||
ebaad2cc GL |
55 | wxVideoWindows::wxVideoWindows(const wxString& filename) |
56 | : wxVideoBaseDriver(filename) | |
4d6306eb | 57 | { |
ebaad2cc GL |
58 | m_internal = new wxVIDWinternal; |
59 | m_remove_file = FALSE; | |
60 | m_filename = filename; | |
61 | m_paused = FALSE; | |
62 | m_stopped = TRUE; | |
63 | OpenFile(); | |
4d6306eb GL |
64 | } |
65 | ||
66 | wxVideoWindows::~wxVideoWindows(void) | |
67 | { | |
ebaad2cc | 68 | mciSendCommand(m_internal->m_dev_id, MCI_CLOSE, 0, 0); |
4d6306eb | 69 | |
ebaad2cc GL |
70 | if (m_internal) |
71 | delete m_internal; | |
4d6306eb GL |
72 | } |
73 | ||
ebaad2cc | 74 | void wxVideoWindows::OpenFile() |
4d6306eb | 75 | { |
ebaad2cc GL |
76 | MCI_DGV_OPEN_PARMS open_struct; |
77 | DWORD ret; | |
78 | ||
79 | open_struct.lpstrDeviceType = "avivideo"; | |
80 | open_struct.lpstrElementName = (LPSTR)(m_filename.mb_str()); | |
81 | open_struct.hWndParent = 0; | |
82 | ||
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; | |
87 | } | |
4d6306eb | 88 | |
ebaad2cc GL |
89 | bool wxVideoWindows::Pause() |
90 | { | |
91 | if (m_paused || m_stopped) | |
92 | return TRUE; | |
93 | m_paused = TRUE; | |
94 | return (mciSendCommand(m_internal->m_dev_id, MCI_PAUSE, 0, 0) == 0); | |
95 | } | |
4d6306eb | 96 | |
ebaad2cc GL |
97 | bool wxVideoWindows::Resume() |
98 | { | |
99 | if (!m_paused || m_stopped) | |
100 | return TRUE; | |
101 | m_paused = FALSE; | |
102 | return (mciSendCommand(m_internal->m_dev_id, MCI_PAUSE, 0, 0) == 0); | |
4d6306eb GL |
103 | } |
104 | ||
ebaad2cc | 105 | bool wxVideoWindows::IsPaused() |
4d6306eb | 106 | { |
ebaad2cc | 107 | return m_paused; |
4d6306eb GL |
108 | } |
109 | ||
ebaad2cc | 110 | bool wxVideoWindows::IsStopped() |
4d6306eb | 111 | { |
ebaad2cc | 112 | return m_stopped; |
4d6306eb GL |
113 | } |
114 | ||
ebaad2cc | 115 | bool wxVideoWindows::GetSize(wxSize& size) const |
4d6306eb | 116 | { |
ebaad2cc | 117 | return TRUE; |
4d6306eb GL |
118 | } |
119 | ||
120 | bool wxVideoWindows::Resize(wxUint16 w, wxUint16 h) | |
121 | { | |
ebaad2cc | 122 | return TRUE; |
4d6306eb GL |
123 | } |
124 | ||
125 | bool wxVideoWindows::IsCapable(wxVideoType v_type) | |
126 | { | |
ebaad2cc | 127 | return (v_type == wxVIDEO_MSAVI); |
4d6306eb GL |
128 | } |
129 | ||
ebaad2cc | 130 | bool wxVideoWindows::AttachOutput(wxWindow& output) |
4d6306eb | 131 | { |
ebaad2cc GL |
132 | MCI_DGV_WINDOW_PARMS win_struct; |
133 | ||
134 | if (!wxVideoBaseDriver::AttachOutput(output)) | |
135 | return FALSE; | |
136 | ||
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); | |
140 | return TRUE; | |
4d6306eb GL |
141 | } |
142 | ||
ebaad2cc | 143 | void wxVideoWindows::DetachOutput() |
4d6306eb | 144 | { |
ebaad2cc | 145 | MCI_DGV_WINDOW_PARMS win_struct; |
4d6306eb | 146 | |
ebaad2cc GL |
147 | wxVideoBaseDriver::DetachOutput(); |
148 | ||
149 | win_struct.hWnd = 0; | |
150 | mciSendCommand(m_internal->m_dev_id, MCI_WINDOW, | |
151 | MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct); | |
4d6306eb GL |
152 | } |
153 | ||
ebaad2cc | 154 | bool wxVideoWindows::Play() |
4d6306eb | 155 | { |
ebaad2cc GL |
156 | if (!m_stopped) |
157 | return FALSE; | |
158 | m_stopped = FALSE; | |
159 | return (mciSendCommand(m_internal->m_dev_id, MCI_PLAY, 0, NULL) == 0); | |
4d6306eb GL |
160 | } |
161 | ||
ebaad2cc | 162 | bool wxVideoWindows::Stop() |
4d6306eb | 163 | { |
ebaad2cc GL |
164 | if (m_stopped) |
165 | return FALSE; | |
166 | m_stopped = TRUE; | |
167 | return (mciSendCommand(m_internal->m_dev_id, MCI_STOP, 0, NULL) == 0); | |
4d6306eb | 168 | } |