29 files changed, 1229 insertions, 893 deletions
diff --git a/core/multimedia/opieplayer/Makefile.in b/core/multimedia/opieplayer/Makefile.in index 1b0307a..8d33fb4 100644 --- a/core/multimedia/opieplayer/Makefile.in +++ b/core/multimedia/opieplayer/Makefile.in | |||
@@ -136,6 +136,8 @@ REQUIRES= | |||
136 | 136 | ||
137 | main.o: main.cpp \ | 137 | main.o: main.cpp \ |
138 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 138 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
139 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
140 | $(OPIEDIR)/include/timestring.h \ | ||
139 | mediaplayerstate.h \ | 141 | mediaplayerstate.h \ |
140 | playlistwidget.h \ | 142 | playlistwidget.h \ |
141 | $(OPIEDIR)/include/qpe/applnk.h \ | 143 | $(OPIEDIR)/include/qpe/applnk.h \ |
@@ -146,11 +148,12 @@ main.o: main.cpp \ | |||
146 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 148 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
147 | $(OPIEDIR)/include/qpe/qcom.h \ | 149 | $(OPIEDIR)/include/qpe/qcom.h \ |
148 | $(OPIEDIR)/include/qpe/quuid.h \ | 150 | $(OPIEDIR)/include/qpe/quuid.h \ |
149 | $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h | 151 | mediaplayerplugininterface.h |
150 | 152 | ||
151 | loopcontrol.o: loopcontrol.cpp \ | 153 | loopcontrol.o: loopcontrol.cpp \ |
152 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 154 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
153 | $(OPIEDIR)/include/qpe/qcopenvelope_qws.h \ | 155 | $(OPIEDIR)/include/qpedecoration_qws.h \ |
156 | $(OPIEDIR)/include/timestring.h \ | ||
154 | loopcontrol.h \ | 157 | loopcontrol.h \ |
155 | videowidget.h \ | 158 | videowidget.h \ |
156 | audiodevice.h \ | 159 | audiodevice.h \ |
@@ -166,11 +169,13 @@ playlistselection.o: playlistselection.cpp \ | |||
166 | 169 | ||
167 | mediaplayerstate.o: mediaplayerstate.cpp \ | 170 | mediaplayerstate.o: mediaplayerstate.cpp \ |
168 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 171 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
172 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
173 | $(OPIEDIR)/include/timestring.h \ | ||
169 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 174 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
170 | $(OPIEDIR)/include/qpe/qcom.h \ | 175 | $(OPIEDIR)/include/qpe/qcom.h \ |
171 | $(OPIEDIR)/include/qpe/quuid.h \ | 176 | $(OPIEDIR)/include/qpe/quuid.h \ |
172 | $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h \ | ||
173 | $(OPIEDIR)/include/qpe/config.h \ | 177 | $(OPIEDIR)/include/qpe/config.h \ |
178 | mediaplayerplugininterface.h \ | ||
174 | mediaplayerstate.h \ | 179 | mediaplayerstate.h \ |
175 | libmad/libmadpluginimpl.h \ | 180 | libmad/libmadpluginimpl.h \ |
176 | libmpeg3/libmpeg3pluginimpl.h \ | 181 | libmpeg3/libmpeg3pluginimpl.h \ |
@@ -178,7 +183,7 @@ mediaplayerstate.o: mediaplayerstate.cpp \ | |||
178 | 183 | ||
179 | videowidget.o: videowidget.cpp \ | 184 | videowidget.o: videowidget.cpp \ |
180 | $(OPIEDIR)/include/qpe/resource.h \ | 185 | $(OPIEDIR)/include/qpe/resource.h \ |
181 | $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h \ | 186 | mediaplayerplugininterface.h \ |
182 | $(OPIEDIR)/include/qpe/qcom.h \ | 187 | $(OPIEDIR)/include/qpe/qcom.h \ |
183 | $(OPIEDIR)/include/qpe/quuid.h \ | 188 | $(OPIEDIR)/include/qpe/quuid.h \ |
184 | videowidget.h \ | 189 | videowidget.h \ |
@@ -193,6 +198,11 @@ playlistwidget.o: playlistwidget.cpp \ | |||
193 | $(OPIEDIR)/include/qpe/qpemenubar.h \ | 198 | $(OPIEDIR)/include/qpe/qpemenubar.h \ |
194 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ | 199 | $(OPIEDIR)/include/qpe/qpetoolbar.h \ |
195 | $(OPIEDIR)/include/qpe/fileselector.h \ | 200 | $(OPIEDIR)/include/qpe/fileselector.h \ |
201 | $(OPIEDIR)/include/filemanager.h \ | ||
202 | $(OPIEDIR)/include/applnk.h \ | ||
203 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | ||
204 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
205 | $(OPIEDIR)/include/timestring.h \ | ||
196 | $(OPIEDIR)/include/qpe/applnk.h \ | 206 | $(OPIEDIR)/include/qpe/applnk.h \ |
197 | $(OPIEDIR)/include/qpe/config.h \ | 207 | $(OPIEDIR)/include/qpe/config.h \ |
198 | $(OPIEDIR)/include/qpe/global.h \ | 208 | $(OPIEDIR)/include/qpe/global.h \ |
@@ -203,13 +213,15 @@ playlistwidget.o: playlistwidget.cpp \ | |||
203 | 213 | ||
204 | mediaplayer.o: mediaplayer.cpp \ | 214 | mediaplayer.o: mediaplayer.cpp \ |
205 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 215 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
216 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
217 | $(OPIEDIR)/include/timestring.h \ | ||
206 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 218 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
207 | $(OPIEDIR)/include/qpe/qcom.h \ | 219 | $(OPIEDIR)/include/qpe/qcom.h \ |
208 | $(OPIEDIR)/include/qpe/quuid.h \ | 220 | $(OPIEDIR)/include/qpe/quuid.h \ |
209 | $(OPIEDIR)/include/qpe/resource.h \ | 221 | $(OPIEDIR)/include/qpe/resource.h \ |
210 | $(OPIEDIR)/include/qpe/config.h \ | 222 | $(OPIEDIR)/include/qpe/config.h \ |
211 | mediaplayer.h \ | 223 | mediaplayer.h \ |
212 | $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h \ | 224 | mediaplayerplugininterface.h \ |
213 | playlistwidget.h \ | 225 | playlistwidget.h \ |
214 | $(OPIEDIR)/include/qpe/applnk.h \ | 226 | $(OPIEDIR)/include/qpe/applnk.h \ |
215 | audiowidget.h \ | 227 | audiowidget.h \ |
@@ -219,9 +231,10 @@ mediaplayer.o: mediaplayer.cpp \ | |||
219 | 231 | ||
220 | audiodevice.o: audiodevice.cpp \ | 232 | audiodevice.o: audiodevice.cpp \ |
221 | $(OPIEDIR)/include/qpe/qpeapplication.h \ | 233 | $(OPIEDIR)/include/qpe/qpeapplication.h \ |
234 | $(OPIEDIR)/include/qpedecoration_qws.h \ | ||
235 | $(OPIEDIR)/include/timestring.h \ | ||
222 | $(OPIEDIR)/include/qpe/config.h \ | 236 | $(OPIEDIR)/include/qpe/config.h \ |
223 | audiodevice.h \ | 237 | audiodevice.h |
224 | $(OPIEDIR)/include/qpe/qcopenvelope_qws.h | ||
225 | 238 | ||
226 | moc_loopcontrol.o: moc_loopcontrol.cpp \ | 239 | moc_loopcontrol.o: moc_loopcontrol.cpp \ |
227 | loopcontrol.h | 240 | loopcontrol.h |
@@ -248,7 +261,7 @@ moc_mediaplayer.o: moc_mediaplayer.cpp \ | |||
248 | $(OPIEDIR)/include/qpe/qlibrary.h \ | 261 | $(OPIEDIR)/include/qpe/qlibrary.h \ |
249 | $(OPIEDIR)/include/qpe/qcom.h \ | 262 | $(OPIEDIR)/include/qpe/qcom.h \ |
250 | $(OPIEDIR)/include/qpe/quuid.h \ | 263 | $(OPIEDIR)/include/qpe/quuid.h \ |
251 | $(OPIEDIR)/include/qpe/mediaplayerplugininterface.h | 264 | mediaplayerplugininterface.h |
252 | 265 | ||
253 | moc_audiodevice.o: moc_audiodevice.cpp \ | 266 | moc_audiodevice.o: moc_audiodevice.cpp \ |
254 | audiodevice.h | 267 | audiodevice.h |
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 8861015..59136af 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp | |||
@@ -17,7 +17,11 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added better error code Fri 02-15-2002 14:37:47 | ||
21 | |||
22 | |||
20 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <stdio.h> | ||
21 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
23 | #include "audiodevice.h" | 27 | #include "audiodevice.h" |
@@ -105,17 +109,18 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume | |||
105 | formatData.wBitsPerSample = 16; | 109 | formatData.wBitsPerSample = 16; |
106 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); | 110 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); |
107 | if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) | 111 | if ( waveOutGetVolume( handle, (LPDWORD)&volume ) ) |
108 | qDebug( "get volume of audio device failed" ); | 112 | qDebug( "get volume of audio device failed" ); |
109 | waveOutClose( handle ); | 113 | waveOutClose( handle ); |
110 | leftVolume = volume & 0xFFFF; | 114 | leftVolume = volume & 0xFFFF; |
111 | rightVolume = volume >> 16; | 115 | rightVolume = volume >> 16; |
112 | #else | 116 | #else |
113 | int mixerHandle = open( "/dev/mixer", O_RDWR ); | 117 | int mixerHandle = open( "/dev/mixer", O_RDWR ); |
114 | if ( mixerHandle >= 0 ) { | 118 | if ( mixerHandle >= 0 ) { |
115 | ioctl( mixerHandle, MIXER_READ(0), &volume ); | 119 | if(ioctl( mixerHandle, MIXER_READ(0), &volume )==-1) |
120 | perror("ioctl(\"MIXER_READ\")"); | ||
116 | close( mixerHandle ); | 121 | close( mixerHandle ); |
117 | } else | 122 | } else |
118 | qDebug( "get volume of audio device failed" ); | 123 | perror("open(\"/dev/mixer\")"); |
119 | leftVolume = ((volume & 0x00FF) << 16) / 101; | 124 | leftVolume = ((volume & 0x00FF) << 16) / 101; |
120 | rightVolume = ((volume & 0xFF00) << 8) / 101; | 125 | rightVolume = ((volume & 0xFF00) << 8) / 101; |
121 | #endif | 126 | #endif |
@@ -125,13 +130,13 @@ void AudioDevice::getVolume( unsigned int& leftVolume, unsigned int& rightVolume | |||
125 | void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { | 130 | void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, bool muted ) { |
126 | AudioDevicePrivate::muted = muted; | 131 | AudioDevicePrivate::muted = muted; |
127 | if ( muted ) { | 132 | if ( muted ) { |
128 | AudioDevicePrivate::leftVolume = leftVolume; | 133 | AudioDevicePrivate::leftVolume = leftVolume; |
129 | AudioDevicePrivate::rightVolume = rightVolume; | 134 | AudioDevicePrivate::rightVolume = rightVolume; |
130 | leftVolume = 0; | 135 | leftVolume = 0; |
131 | rightVolume = 0; | 136 | rightVolume = 0; |
132 | } else { | 137 | } else { |
133 | leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); | 138 | leftVolume = ( (int) leftVolume < 0 ) ? 0 : (( leftVolume > 0xFFFF ) ? 0xFFFF : leftVolume ); |
134 | rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); | 139 | rightVolume = ( (int)rightVolume < 0 ) ? 0 : (( rightVolume > 0xFFFF ) ? 0xFFFF : rightVolume ); |
135 | } | 140 | } |
136 | #ifdef Q_OS_WIN32 | 141 | #ifdef Q_OS_WIN32 |
137 | HWAVEOUT handle; | 142 | HWAVEOUT handle; |
@@ -146,7 +151,7 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, | |||
146 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); | 151 | waveOutOpen(&handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL); |
147 | unsigned int volume = (rightVolume << 16) | leftVolume; | 152 | unsigned int volume = (rightVolume << 16) | leftVolume; |
148 | if ( waveOutSetVolume( handle, volume ) ) | 153 | if ( waveOutSetVolume( handle, volume ) ) |
149 | qDebug( "set volume of audio device failed" ); | 154 | qDebug( "set volume of audio device failed" ); |
150 | waveOutClose( handle ); | 155 | waveOutClose( handle ); |
151 | #else | 156 | #else |
152 | // Volume can be from 0 to 100 which is 101 distinct values | 157 | // Volume can be from 0 to 100 which is 101 distinct values |
@@ -157,10 +162,12 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, | |||
157 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); | 162 | unsigned int volume = ((rV << 8) & 0xFF00) | (lV & 0x00FF); |
158 | int mixerHandle = 0; | 163 | int mixerHandle = 0; |
159 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 164 | if ( ( mixerHandle = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
160 | ioctl( mixerHandle, MIXER_WRITE(0), &volume ); | 165 | if(ioctl( mixerHandle, MIXER_WRITE(0), &volume ) ==-1) |
166 | perror("ioctl(\"MIXER_WRITE\")"); | ||
161 | close( mixerHandle ); | 167 | close( mixerHandle ); |
162 | } else | 168 | } else |
163 | qDebug( "set volume of audio device failed" ); | 169 | perror("open(\"/dev/mixer\")"); |
170 | |||
164 | # else | 171 | # else |
165 | // This is the way this has to be done now I guess, doesn't allow for | 172 | // This is the way this has to be done now I guess, doesn't allow for |
166 | // independant right and left channel setting, or setting for different outputs | 173 | // independant right and left channel setting, or setting for different outputs |
@@ -185,68 +192,47 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | |||
185 | d->frequency = f; | 192 | d->frequency = f; |
186 | d->channels = chs; | 193 | d->channels = chs; |
187 | d->bytesPerSample = bps; | 194 | d->bytesPerSample = bps; |
195 | qDebug("%d",bps); | ||
196 | int format=0; | ||
197 | if( bps == 8) format = AFMT_U8; | ||
198 | else if( bps <= 0) format = AFMT_S16_LE; | ||
199 | else format = AFMT_S16_LE; | ||
188 | 200 | ||
201 | qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); | ||
189 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 202 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
190 | 203 | ||
191 | #ifdef Q_OS_WIN32 | ||
192 | UINT result; | ||
193 | WAVEFORMATEX formatData; | ||
194 | formatData.cbSize = sizeof(WAVEFORMATEX); | ||
195 | /* | ||
196 | // Other possible formats windows supports | ||
197 | formatData.wFormatTag = WAVE_FORMAT_MPEG; | ||
198 | formatData.wFormatTag = WAVE_FORMAT_MPEGLAYER3; | ||
199 | formatData.wFormatTag = WAVE_FORMAT_ADPCM; | ||
200 | */ | ||
201 | formatData.wFormatTag = WAVE_FORMAT_PCM; | ||
202 | formatData.nAvgBytesPerSec = bps * chs * f; | ||
203 | formatData.nBlockAlign = bps * chs; | ||
204 | formatData.nChannels = chs; | ||
205 | formatData.nSamplesPerSec = f; | ||
206 | formatData.wBitsPerSample = bps * 8; | ||
207 | // Open a waveform device for output | ||
208 | if (result = waveOutOpen((LPHWAVEOUT)&d->handle, WAVE_MAPPER, &formatData, 0L, 0L, CALLBACK_NULL)) { | ||
209 | QString errorMsg = "error opening audio device.\nReason: %i - "; | ||
210 | switch (result) { | ||
211 | case MMSYSERR_ALLOCATED:errorMsg += "Specified resource is already allocated."; break; | ||
212 | case MMSYSERR_BADDEVICEID:errorMsg += "Specified device identifier is out of range."; break; | ||
213 | case MMSYSERR_NODRIVER:errorMsg += "No device driver is present."; break; | ||
214 | case MMSYSERR_NOMEM:errorMsg += "Unable to allocate or lock memory."; break; | ||
215 | case WAVERR_BADFORMAT:errorMsg += "Attempted to open with an unsupported waveform-audio format."; break; | ||
216 | case WAVERR_SYNC: errorMsg += "The device is synchronous but waveOutOpen was called without using the WAVE_ALLOWSYNC flag."; break; | ||
217 | default: errorMsg += "Undefined error"; break; | ||
218 | } | ||
219 | qDebug( errorMsg, result ); | ||
220 | } | ||
221 | |||
222 | d->bufferSize = sound_fragment_bytes; | ||
223 | #else | ||
224 | 204 | ||
225 | int fragments = 0x10000 * 8 + sound_fragment_shift; | 205 | int fragments = 0x10000 * 8 + sound_fragment_shift; |
226 | int format = AFMT_S16_LE; | ||
227 | int capabilities = 0; | 206 | int capabilities = 0; |
228 | 207 | ||
229 | #ifdef KEEP_DEVICE_OPEN | 208 | #ifdef KEEP_DEVICE_OPEN |
230 | if ( AudioDevicePrivate::dspFd == 0 ) { | 209 | if ( AudioDevicePrivate::dspFd == 0 ) { |
231 | #endif | 210 | #endif |
232 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { | 211 | if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { |
233 | qDebug( "error opening audio device /dev/dsp, sending data to /dev/null instead" ); | 212 | perror("open(\"/dev/dsp\") sending to /dev/null instead"); |
234 | d->handle = ::open( "/dev/null", O_WRONLY ); | 213 | d->handle = ::open( "/dev/null", O_WRONLY ); |
235 | } | 214 | } |
236 | #ifdef KEEP_DEVICE_OPEN | 215 | #ifdef KEEP_DEVICE_OPEN |
237 | AudioDevicePrivate::dspFd = d->handle; | 216 | AudioDevicePrivate::dspFd = d->handle; |
238 | } else { | 217 | } else { |
239 | d->handle = AudioDevicePrivate::dspFd; | 218 | d->handle = AudioDevicePrivate::dspFd; |
240 | } | 219 | } |
241 | #endif | 220 | #endif |
242 | 221 | ||
243 | ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities ); | 222 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) |
244 | ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments ); | 223 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); |
245 | ioctl( d->handle, SNDCTL_DSP_SETFMT, &format ); | 224 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) |
246 | ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency ); | 225 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); |
226 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) | ||
227 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | ||
228 | qDebug("freq %d", d->frequency); | ||
229 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) | ||
230 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | ||
231 | qDebug("channels %d",d->channels); | ||
247 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { | 232 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { |
248 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; | 233 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; |
249 | ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ); | 234 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) |
235 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | ||
250 | } | 236 | } |
251 | 237 | ||
252 | d->bufferSize = sound_fragment_bytes; | 238 | d->bufferSize = sound_fragment_bytes; |
@@ -254,13 +240,12 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | |||
254 | d->unwritten = 0; | 240 | d->unwritten = 0; |
255 | d->can_GETOSPACE = TRUE; // until we find otherwise | 241 | d->can_GETOSPACE = TRUE; // until we find otherwise |
256 | 242 | ||
257 | //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); | 243 | //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); |
258 | //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); | 244 | //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); |
259 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); | 245 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); |
260 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); | 246 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); |
261 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); | 247 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); |
262 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); | 248 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); |
263 | #endif | ||
264 | } | 249 | } |
265 | 250 | ||
266 | 251 | ||
@@ -269,7 +254,7 @@ AudioDevice::~AudioDevice() { | |||
269 | waveOutClose( (HWAVEOUT)d->handle ); | 254 | waveOutClose( (HWAVEOUT)d->handle ); |
270 | #else | 255 | #else |
271 | # ifndef KEEP_DEVICE_OPEN | 256 | # ifndef KEEP_DEVICE_OPEN |
272 | close( d->handle ); // Now it should be safe to shut the handle | 257 | close( d->handle ); // Now it should be safe to shut the handle |
273 | # endif | 258 | # endif |
274 | delete d->unwrittenBuffer; | 259 | delete d->unwrittenBuffer; |
275 | delete d; | 260 | delete d; |
@@ -296,15 +281,15 @@ void AudioDevice::write( char *buffer, unsigned int length ) | |||
296 | waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); | 281 | waveOutPrepareHeader( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ); |
297 | // waveOutWrite returns immediately. the data is sent in the background. | 282 | // waveOutWrite returns immediately. the data is sent in the background. |
298 | if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) | 283 | if ( waveOutWrite( (HWAVEOUT)d->handle, lpWaveHdr, sizeof(WAVEHDR) ) ) |
299 | qDebug( "failed to write block to audio device" ); | 284 | qDebug( "failed to write block to audio device" ); |
300 | // emit completedIO(); | 285 | // emit completedIO(); |
301 | #else | 286 | #else |
302 | int t = ::write( d->handle, buffer, length ); | 287 | int t = ::write( d->handle, buffer, length ); |
303 | if ( t<0 ) t = 0; | 288 | if ( t<0 ) t = 0; |
304 | if ( t != (int)length) { | 289 | if ( t != (int)length) { |
305 | qDebug("Ahhh!! memcpys 1"); | 290 | qDebug("Ahhh!! memcpys 1"); |
306 | memcpy(d->unwrittenBuffer,buffer+t,length-t); | 291 | memcpy(d->unwrittenBuffer,buffer+t,length-t); |
307 | d->unwritten = length-t; | 292 | d->unwritten = length-t; |
308 | } | 293 | } |
309 | #endif | 294 | #endif |
310 | } | 295 | } |
@@ -340,27 +325,27 @@ unsigned int AudioDevice::canWrite() const | |||
340 | #else | 325 | #else |
341 | audio_buf_info info; | 326 | audio_buf_info info; |
342 | if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) { | 327 | if ( d->can_GETOSPACE && ioctl(d->handle,SNDCTL_DSP_GETOSPACE,&info) ) { |
343 | d->can_GETOSPACE = FALSE; | 328 | d->can_GETOSPACE = FALSE; |
344 | fcntl( d->handle, F_SETFL, O_NONBLOCK ); | 329 | fcntl( d->handle, F_SETFL, O_NONBLOCK ); |
345 | } | 330 | } |
346 | if ( d->can_GETOSPACE ) { | 331 | if ( d->can_GETOSPACE ) { |
347 | int t = info.fragments * sound_fragment_bytes; | 332 | int t = info.fragments * sound_fragment_bytes; |
348 | return QMIN(t,(int)bufferSize()); | 333 | return QMIN(t,(int)bufferSize()); |
349 | } else { | 334 | } else { |
350 | if ( d->unwritten ) { | 335 | if ( d->unwritten ) { |
351 | int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten ); | 336 | int t = ::write( d->handle, d->unwrittenBuffer, d->unwritten ); |
352 | if ( t<0 ) t = 0; | 337 | if ( t<0 ) t = 0; |
353 | if ( (unsigned)t!=d->unwritten ) { | 338 | if ( (unsigned)t!=d->unwritten ) { |
354 | memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t); | 339 | memcpy(d->unwrittenBuffer,d->unwrittenBuffer+t,d->unwritten-t); |
355 | d->unwritten -= t; | 340 | d->unwritten -= t; |
356 | } else { | 341 | } else { |
357 | d->unwritten = 0; | 342 | d->unwritten = 0; |
358 | } | 343 | } |
359 | } | 344 | } |
360 | if ( d->unwritten ) | 345 | if ( d->unwritten ) |
361 | return 0; | 346 | return 0; |
362 | else | 347 | else |
363 | return d->bufferSize; | 348 | return d->bufferSize; |
364 | } | 349 | } |
365 | #endif | 350 | #endif |
366 | } | 351 | } |
@@ -370,15 +355,15 @@ int AudioDevice::bytesWritten() { | |||
370 | #ifdef Q_OS_WIN32 | 355 | #ifdef Q_OS_WIN32 |
371 | MMTIME pmmt = { TIME_BYTES, 0 }; | 356 | MMTIME pmmt = { TIME_BYTES, 0 }; |
372 | if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) { | 357 | if ( ( waveOutGetPosition( (HWAVEOUT)d->handle, &pmmt, sizeof(MMTIME) ) != MMSYSERR_NOERROR ) || ( pmmt.wType != TIME_BYTES ) ) { |
373 | qDebug( "failed to get audio device position" ); | 358 | qDebug( "failed to get audio device position" ); |
374 | return -1; | 359 | return -1; |
375 | } | 360 | } |
376 | return pmmt.u.cb; | 361 | return pmmt.u.cb; |
377 | #else | 362 | #else |
378 | int buffered = 0; | 363 | int buffered = 0; |
379 | if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { | 364 | if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { |
380 | qDebug( "failed to get audio device position" ); | 365 | qDebug( "failed to get audio device position" ); |
381 | return -1; | 366 | return -1; |
382 | } | 367 | } |
383 | return buffered; | 368 | return buffered; |
384 | #endif | 369 | #endif |
diff --git a/core/multimedia/opieplayer/audiodevice.h b/core/multimedia/opieplayer/audiodevice.h index 928f134..dcd79fe 100644 --- a/core/multimedia/opieplayer/audiodevice.h +++ b/core/multimedia/opieplayer/audiodevice.h | |||
@@ -17,11 +17,15 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
22 | |||
20 | #ifndef AUDIODEVICE_H | 23 | #ifndef AUDIODEVICE_H |
21 | #define AUDIODEVICE_H | 24 | #define AUDIODEVICE_H |
22 | 25 | ||
23 | 26 | ||
24 | #include <qobject.h> | 27 | #include <qobject.h> |
28 | #include <sys/soundcard.h> | ||
25 | 29 | ||
26 | 30 | ||
27 | class AudioDevicePrivate; | 31 | class AudioDevicePrivate; |
@@ -30,7 +34,7 @@ class AudioDevicePrivate; | |||
30 | class AudioDevice : public QObject { | 34 | class AudioDevice : public QObject { |
31 | Q_OBJECT | 35 | Q_OBJECT |
32 | public: | 36 | public: |
33 | AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = 2 ); | 37 | AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = AFMT_S16_LE ); |
34 | ~AudioDevice(); | 38 | ~AudioDevice(); |
35 | 39 | ||
36 | unsigned int canWrite() const; | 40 | unsigned int canWrite() const; |
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index 243c58c..0d88591 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -61,7 +61,7 @@ static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | |||
61 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 61 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
62 | QWidget( parent, name, f ) | 62 | QWidget( parent, name, f ) |
63 | { | 63 | { |
64 | setCaption( tr("MediaPlayer") ); | 64 | setCaption( tr("OpiePlayer") ); |
65 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 65 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
66 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); | 66 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); |
67 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); | 67 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); |
@@ -104,7 +104,7 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
104 | 104 | ||
105 | AudioWidget::~AudioWidget() { | 105 | AudioWidget::~AudioWidget() { |
106 | for ( int i = 0; i < 4; i++ ) | 106 | for ( int i = 0; i < 4; i++ ) |
107 | delete pixmaps[i]; | 107 | delete pixmaps[i]; |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
@@ -119,7 +119,7 @@ void AudioWidget::sliderPressed() { | |||
119 | void AudioWidget::sliderReleased() { | 119 | void AudioWidget::sliderReleased() { |
120 | audioSliderBeingMoved = FALSE; | 120 | audioSliderBeingMoved = FALSE; |
121 | if ( slider->width() == 0 ) | 121 | if ( slider->width() == 0 ) |
122 | return; | 122 | return; |
123 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 123 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
124 | mediaPlayerState->setPosition( val ); | 124 | mediaPlayerState->setPosition( val ); |
125 | } | 125 | } |
@@ -137,34 +137,34 @@ void AudioWidget::setLength( long max ) { | |||
137 | 137 | ||
138 | void AudioWidget::setView( char view ) { | 138 | void AudioWidget::setView( char view ) { |
139 | if ( view == 'a' ) { | 139 | if ( view == 'a' ) { |
140 | startTimer( 150 ); | 140 | startTimer( 150 ); |
141 | showMaximized(); | 141 | showMaximized(); |
142 | } else { | 142 | } else { |
143 | killTimers(); | 143 | killTimers(); |
144 | hide(); | 144 | hide(); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
149 | void AudioWidget::updateSlider( long i, long max ) { | 149 | void AudioWidget::updateSlider( long i, long max ) { |
150 | if ( max == 0 ) | 150 | if ( max == 0 ) |
151 | return; | 151 | return; |
152 | // Will flicker too much if we don't do this | 152 | // Will flicker too much if we don't do this |
153 | // Scale to something reasonable | 153 | // Scale to something reasonable |
154 | int width = slider->width(); | 154 | int width = slider->width(); |
155 | int val = int((double)i * width / max); | 155 | int val = int((double)i * width / max); |
156 | if ( !audioSliderBeingMoved ) { | 156 | if ( !audioSliderBeingMoved ) { |
157 | if ( slider->value() != val ) | 157 | if ( slider->value() != val ) |
158 | slider->setValue( val ); | 158 | slider->setValue( val ); |
159 | if ( slider->maxValue() != width ) | 159 | if ( slider->maxValue() != width ) |
160 | slider->setMaxValue( width ); | 160 | slider->setMaxValue( width ); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | void AudioWidget::setToggleButton( int i, bool down ) { | 165 | void AudioWidget::setToggleButton( int i, bool down ) { |
166 | if ( down != audioButtons[i].isDown ) | 166 | if ( down != audioButtons[i].isDown ) |
167 | toggleButton( i ); | 167 | toggleButton( i ); |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
@@ -188,61 +188,61 @@ void AudioWidget::paintButton( QPainter *p, int i ) { | |||
188 | void AudioWidget::timerEvent( QTimerEvent * ) { | 188 | void AudioWidget::timerEvent( QTimerEvent * ) { |
189 | static int frame = 0; | 189 | static int frame = 0; |
190 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { | 190 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { |
191 | frame = frame >= 7 ? 0 : frame + 1; | 191 | frame = frame >= 7 ? 0 : frame + 1; |
192 | int x = audioButtons[AudioPlay].xPos; | 192 | int x = audioButtons[AudioPlay].xPos; |
193 | int y = audioButtons[AudioPlay].yPos; | 193 | int y = audioButtons[AudioPlay].yPos; |
194 | QPainter p( this ); | 194 | QPainter p( this ); |
195 | // Optimize to only draw the little bit of the changing images which is different | 195 | // Optimize to only draw the little bit of the changing images which is different |
196 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); | 196 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); |
197 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); | 197 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | 201 | ||
202 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 202 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
203 | for ( int i = 0; i < numButtons; i++ ) { | 203 | for ( int i = 0; i < numButtons; i++ ) { |
204 | int size = audioButtons[i].isBig; | 204 | int size = audioButtons[i].isBig; |
205 | int x = audioButtons[i].xPos; | 205 | int x = audioButtons[i].xPos; |
206 | int y = audioButtons[i].yPos; | 206 | int y = audioButtons[i].yPos; |
207 | if ( event->state() == QMouseEvent::LeftButton ) { | 207 | if ( event->state() == QMouseEvent::LeftButton ) { |
208 | // The test to see if the mouse click is inside the circular button or not | 208 | // The test to see if the mouse click is inside the circular button or not |
209 | // (compared with the radius squared to avoid a square-root of our distance) | 209 | // (compared with the radius squared to avoid a square-root of our distance) |
210 | int radius = 32 + 13 * size; | 210 | int radius = 32 + 13 * size; |
211 | QPoint center = QPoint( x + radius, y + radius ); | 211 | QPoint center = QPoint( x + radius, y + radius ); |
212 | QPoint dXY = center - event->pos(); | 212 | QPoint dXY = center - event->pos(); |
213 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 213 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
214 | bool isOnButton = dist <= (radius * radius); | 214 | bool isOnButton = dist <= (radius * radius); |
215 | // QRect r( x, y, 64 + 22*size, 64 + 22*size ); | 215 | // QRect r( x, y, 64 + 22*size, 64 + 22*size ); |
216 | // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code | 216 | // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code |
217 | if ( isOnButton && !audioButtons[i].isHeld ) { | 217 | if ( isOnButton && !audioButtons[i].isHeld ) { |
218 | audioButtons[i].isHeld = TRUE; | 218 | audioButtons[i].isHeld = TRUE; |
219 | toggleButton(i); | 219 | toggleButton(i); |
220 | switch (i) { | 220 | switch (i) { |
221 | case AudioVolumeUp: emit moreClicked(); return; | 221 | case AudioVolumeUp: emit moreClicked(); return; |
222 | case AudioVolumeDown: emit lessClicked(); return; | 222 | case AudioVolumeDown: emit lessClicked(); return; |
223 | } | 223 | } |
224 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 224 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
225 | audioButtons[i].isHeld = FALSE; | 225 | audioButtons[i].isHeld = FALSE; |
226 | toggleButton(i); | 226 | toggleButton(i); |
227 | } | 227 | } |
228 | } else { | 228 | } else { |
229 | if ( audioButtons[i].isHeld ) { | 229 | if ( audioButtons[i].isHeld ) { |
230 | audioButtons[i].isHeld = FALSE; | 230 | audioButtons[i].isHeld = FALSE; |
231 | if ( !audioButtons[i].isToggle ) | 231 | if ( !audioButtons[i].isToggle ) |
232 | setToggleButton( i, FALSE ); | 232 | setToggleButton( i, FALSE ); |
233 | switch (i) { | 233 | switch (i) { |
234 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; | 234 | case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; |
235 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 235 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
236 | case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; | 236 | case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; |
237 | case AudioNext: mediaPlayerState->setNext(); return; | 237 | case AudioNext: mediaPlayerState->setNext(); return; |
238 | case AudioPrevious: mediaPlayerState->setPrev(); return; | 238 | case AudioPrevious: mediaPlayerState->setPrev(); return; |
239 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 239 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
240 | case AudioVolumeUp: emit moreReleased(); return; | 240 | case AudioVolumeUp: emit moreReleased(); return; |
241 | case AudioVolumeDown: emit lessReleased(); return; | 241 | case AudioVolumeDown: emit lessReleased(); return; |
242 | case AudioPlayList: mediaPlayerState->setList(); return; | 242 | case AudioPlayList: mediaPlayerState->setList(); return; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | } | 245 | } |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
@@ -271,7 +271,7 @@ void AudioWidget::closeEvent( QCloseEvent* ) { | |||
271 | void AudioWidget::paintEvent( QPaintEvent * ) { | 271 | void AudioWidget::paintEvent( QPaintEvent * ) { |
272 | QPainter p( this ); | 272 | QPainter p( this ); |
273 | for ( int i = 0; i < numButtons; i++ ) | 273 | for ( int i = 0; i < numButtons; i++ ) |
274 | paintButton( &p, i ); | 274 | paintButton( &p, i ); |
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
diff --git a/core/multimedia/opieplayer/libflash/libflashplugin.h b/core/multimedia/opieplayer/libflash/libflashplugin.h index 532bca2..a2f1c42 100644 --- a/core/multimedia/opieplayer/libflash/libflashplugin.h +++ b/core/multimedia/opieplayer/libflash/libflashplugin.h | |||
@@ -24,7 +24,8 @@ | |||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | #include "flash.h" | 26 | #include "flash.h" |
27 | #include "mediaplayerplugininterface.h" | 27 | //#include <qpe/mediaplayerplugininterface.h> |
28 | #include "../mediaplayerplugininterface.h" | ||
28 | 29 | ||
29 | 30 | ||
30 | class LibFlashPlugin : public MediaPlayerDecoder { | 31 | class LibFlashPlugin : public MediaPlayerDecoder { |
@@ -48,6 +49,7 @@ public: | |||
48 | int audioChannels( int /*stream*/ ) { return 2; } | 49 | int audioChannels( int /*stream*/ ) { return 2; } |
49 | int audioFrequency( int /*stream*/ ) { return 44100; } | 50 | int audioFrequency( int /*stream*/ ) { return 44100; } |
50 | int audioSamples( int /*stream*/ ) { return 1000000; } | 51 | int audioSamples( int /*stream*/ ) { return 1000000; } |
52 | int audioBitsPerSample(int) { return 0;} | ||
51 | bool audioSetSample( long sample, int stream ); | 53 | bool audioSetSample( long sample, int stream ); |
52 | long audioGetSample( int stream ); | 54 | long audioGetSample( int stream ); |
53 | //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 55 | //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
diff --git a/core/multimedia/opieplayer/libflash/libflashpluginimpl.h b/core/multimedia/opieplayer/libflash/libflashpluginimpl.h index b5cc869..cb8d959 100644 --- a/core/multimedia/opieplayer/libflash/libflashpluginimpl.h +++ b/core/multimedia/opieplayer/libflash/libflashpluginimpl.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #define LIBFLASH_PLUGIN_IMPL_H | 21 | #define LIBFLASH_PLUGIN_IMPL_H |
22 | 22 | ||
23 | 23 | ||
24 | //#include <qpe/mediaplayerplugininterface.h> | ||
24 | #include "../mediaplayerplugininterface.h" | 25 | #include "../mediaplayerplugininterface.h" |
25 | 26 | ||
26 | 27 | ||
diff --git a/core/multimedia/opieplayer/libflash/swf.h b/core/multimedia/opieplayer/libflash/swf.h index 5f5e4f7..48986cc 100644 --- a/core/multimedia/opieplayer/libflash/swf.h +++ b/core/multimedia/opieplayer/libflash/swf.h | |||
@@ -208,7 +208,7 @@ extern "C" { | |||
208 | }; | 208 | }; |
209 | extern "C" { | 209 | extern "C" { |
210 | //#include "zlib.h" | 210 | //#include "zlib.h" |
211 | #include "../src/3rdparty/zlib/zlib.h" | 211 | #include "/opt/qt-2.3.2-embedded/src/3rdparty/zlib/zlib.h" |
212 | }; | 212 | }; |
213 | 213 | ||
214 | #include "graphic.h" | 214 | #include "graphic.h" |
diff --git a/core/multimedia/opieplayer/libmad/Makefile.in b/core/multimedia/opieplayer/libmad/Makefile.in index e9f74e7..552043c 100644 --- a/core/multimedia/opieplayer/libmad/Makefile.in +++ b/core/multimedia/opieplayer/libmad/Makefile.in | |||
@@ -214,10 +214,12 @@ huffman.o: huffman.c \ | |||
214 | 214 | ||
215 | libmadplugin.o: libmadplugin.cpp \ | 215 | libmadplugin.o: libmadplugin.cpp \ |
216 | libmadplugin.h \ | 216 | libmadplugin.h \ |
217 | ../mediaplayerplugininterface.h \ | ||
217 | mad.h | 218 | mad.h |
218 | 219 | ||
219 | libmadpluginimpl.o: libmadpluginimpl.cpp \ | 220 | libmadpluginimpl.o: libmadpluginimpl.cpp \ |
220 | libmadplugin.h \ | 221 | libmadplugin.h \ |
222 | ../mediaplayerplugininterface.h \ | ||
221 | libmadpluginimpl.h | 223 | libmadpluginimpl.h |
222 | 224 | ||
223 | 225 | ||
diff --git a/core/multimedia/opieplayer/libmad/libmad.pro b/core/multimedia/opieplayer/libmad/libmad.pro index 6c40a15..b54ca6b 100644 --- a/core/multimedia/opieplayer/libmad/libmad.pro +++ b/core/multimedia/opieplayer/libmad/libmad.pro | |||
@@ -1,12 +1,14 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h decoder.h \ | 3 | HEADERS = libmad_version.h fixed.h bit.h timer.h stream.h frame.h synth.h decoder.h \ |
4 | layer12.h layer3.h huffman.h libmad_global.h mad.h libmadplugin.h libmadpluginimpl.h | 4 | layer12.h layer3.h huffman.h libmad_global.h mad.h libmadplugin.h libmadpluginimpl.h |
5 | SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c synth.c decoder.c \ | 5 | SOURCES = version.c fixed.c bit.c timer.c stream.c frame.c synth.c decoder.c \ |
6 | layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp | 6 | layer12.c layer3.c huffman.c libmadplugin.cpp libmadpluginimpl.cpp |
7 | TARGET = madplugin | 7 | TARGET = madplugin |
8 | DESTDIR = ../../plugins/codecs | 8 | DESTDIR = ../../plugins/codecs |
9 | INCLUDEPATH += $(OPIEDIR)/include .. | 9 | INCLUDEPATH += $(OPIEDIR)/include .. |
10 | DEPENDPATH += ../$(OPIEDIR)/include .. | 10 | DEPENDPATH += ../$(OPIEDIR)/include .. |
11 | TMAKE_CFLAGS += -DFPM_64BIT | ||
12 | TMAKE_CXXFLAGS += -DFPM_64BIT | ||
11 | LIBS += -lqpe -lm | 13 | LIBS += -lqpe -lm |
12 | VERSION = 1.0.0 | 14 | VERSION = 1.0.0 |
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.h b/core/multimedia/opieplayer/libmad/libmadplugin.h index 88647ae..ff84c27 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.h +++ b/core/multimedia/opieplayer/libmad/libmadplugin.h | |||
@@ -22,7 +22,11 @@ | |||
22 | 22 | ||
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include "mediaplayerplugininterface.h" | 25 | //#include <qpe/mediaplayerplugininterface.h> |
26 | #include "../mediaplayerplugininterface.h" | ||
27 | |||
28 | |||
29 | // #define OLD_MEDIAPLAYER_API | ||
26 | 30 | ||
27 | 31 | ||
28 | class LibMadPluginData; | 32 | class LibMadPluginData; |
@@ -50,12 +54,16 @@ public: | |||
50 | int audioFrequency( int stream ); | 54 | int audioFrequency( int stream ); |
51 | int audioSamples( int stream ); | 55 | int audioSamples( int stream ); |
52 | bool audioSetSample( long sample, int stream ); | 56 | bool audioSetSample( long sample, int stream ); |
57 | int audioBitsPerSample(int) {return 0;} | ||
53 | long audioGetSample( int stream ); | 58 | long audioGetSample( int stream ); |
54 | // bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 59 | #ifdef OLD_MEDIAPLAYER_API |
55 | // bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 60 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
61 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | ||
62 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | ||
63 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
64 | #else | ||
56 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 65 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
57 | // bool audioReadSamples( short *output, int channel, long samples, int stream ); | 66 | #endif |
58 | // bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
59 | 67 | ||
60 | 68 | ||
61 | bool read(); | 69 | bool read(); |
@@ -91,6 +99,8 @@ public: | |||
91 | bool supportsStereo() { return TRUE; } | 99 | bool supportsStereo() { return TRUE; } |
92 | bool supportsScaling() { return FALSE; } | 100 | bool supportsScaling() { return FALSE; } |
93 | 101 | ||
102 | long getPlayTime() { return -1; } | ||
103 | |||
94 | private: | 104 | private: |
95 | LibMadPluginData *d; | 105 | LibMadPluginData *d; |
96 | QString info; | 106 | QString info; |
diff --git a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h index a26b421..8ad4956 100644 --- a/core/multimedia/opieplayer/libmad/libmadpluginimpl.h +++ b/core/multimedia/opieplayer/libmad/libmadpluginimpl.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #define LIBMAD_PLUGIN_IMPL_H | 21 | #define LIBMAD_PLUGIN_IMPL_H |
22 | 22 | ||
23 | 23 | ||
24 | //#include <qpe/mediaplayerplugininterface.h> | ||
24 | #include "../mediaplayerplugininterface.h" | 25 | #include "../mediaplayerplugininterface.h" |
25 | 26 | ||
26 | 27 | ||
@@ -42,7 +43,6 @@ public: | |||
42 | 43 | ||
43 | virtual MediaPlayerDecoder *decoder(); | 44 | virtual MediaPlayerDecoder *decoder(); |
44 | virtual MediaPlayerEncoder *encoder(); | 45 | virtual MediaPlayerEncoder *encoder(); |
45 | |||
46 | private: | 46 | private: |
47 | LibMadPlugin *libmadplugin; | 47 | LibMadPlugin *libmadplugin; |
48 | ulong ref; | 48 | ulong ref; |
diff --git a/core/multimedia/opieplayer/libmad/version.c b/core/multimedia/opieplayer/libmad/version.c index 413d54b..1baba26 100644 --- a/core/multimedia/opieplayer/libmad/version.c +++ b/core/multimedia/opieplayer/libmad/version.c | |||
@@ -88,4 +88,4 @@ char const mad_build[] = | |||
88 | # elif defined(NDEBUG) | 88 | # elif defined(NDEBUG) |
89 | "NDEBUG " | 89 | "NDEBUG " |
90 | # endif | 90 | # endif |
91 | ; | 91 | ; \ No newline at end of file |
diff --git a/core/multimedia/opieplayer/libmpeg3/Makefile.in b/core/multimedia/opieplayer/libmpeg3/Makefile.in index 154f85d..d255e4f 100644 --- a/core/multimedia/opieplayer/libmpeg3/Makefile.in +++ b/core/multimedia/opieplayer/libmpeg3/Makefile.in | |||
@@ -176,7 +176,8 @@ libmpeg3plugin.o: libmpeg3plugin.cpp \ | |||
176 | audio/mpeg3audio.h \ | 176 | audio/mpeg3audio.h \ |
177 | mpeg3vtrack.h \ | 177 | mpeg3vtrack.h \ |
178 | video/mpeg3video.h \ | 178 | video/mpeg3video.h \ |
179 | mpeg3protos.h | 179 | mpeg3protos.h \ |
180 | ../mediaplayerplugininterface.h | ||
180 | 181 | ||
181 | libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \ | 182 | libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \ |
182 | libmpeg3plugin.h \ | 183 | libmpeg3plugin.h \ |
@@ -192,6 +193,7 @@ libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \ | |||
192 | mpeg3vtrack.h \ | 193 | mpeg3vtrack.h \ |
193 | video/mpeg3video.h \ | 194 | video/mpeg3video.h \ |
194 | mpeg3protos.h \ | 195 | mpeg3protos.h \ |
196 | ../mediaplayerplugininterface.h \ | ||
195 | libmpeg3pluginimpl.h | 197 | libmpeg3pluginimpl.h |
196 | 198 | ||
197 | bitstream.o: bitstream.c \ | 199 | bitstream.o: bitstream.c \ |
@@ -414,7 +416,7 @@ audio/layer2.o: audio/layer2.c \ | |||
414 | audio/tables.h | 416 | audio/tables.h |
415 | 417 | ||
416 | audio/layer3.o: audio/layer3.c \ | 418 | audio/layer3.o: audio/layer3.c \ |
417 | audio/huffman.h \ | 419 | huffman.h \ |
418 | audio/mpeg3audio.h \ | 420 | audio/mpeg3audio.h \ |
419 | audio/ac3.h \ | 421 | audio/ac3.h \ |
420 | audio/mpeg3real.h \ | 422 | audio/mpeg3real.h \ |
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h index 0a06264..54f259b 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h | |||
@@ -25,7 +25,11 @@ | |||
25 | #include <qapplication.h> | 25 | #include <qapplication.h> |
26 | #include "libmpeg3.h" | 26 | #include "libmpeg3.h" |
27 | #include "mpeg3protos.h" | 27 | #include "mpeg3protos.h" |
28 | #include "mediaplayerplugininterface.h" | 28 | //#include <qpe/mediaplayerplugininterface.h> |
29 | #include "../mediaplayerplugininterface.h" | ||
30 | |||
31 | |||
32 | // #define OLD_MEDIAPLAYER_API | ||
29 | 33 | ||
30 | 34 | ||
31 | class LibMpeg3Plugin : public MediaPlayerDecoder { | 35 | class LibMpeg3Plugin : public MediaPlayerDecoder { |
@@ -42,20 +46,24 @@ public: | |||
42 | bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; } | 46 | bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; } |
43 | bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; } | 47 | bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; } |
44 | bool isOpen() { return file != NULL; } | 48 | bool isOpen() { return file != NULL; } |
45 | const QString &fileInfo() { return strInfo = QString( "" ); } | 49 | const QString &fileInfo() { return strInfo = ""; } |
46 | 50 | ||
47 | // If decoder doesn't support audio then return 0 here | 51 | // If decoder doesn't support audio then return 0 here |
48 | int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; } | 52 | int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; } |
49 | int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; } | 53 | int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; } |
50 | int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; } | 54 | int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; } |
55 | int audioBitsPerSample(int) { return 0;} | ||
51 | int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } | 56 | int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; } |
52 | bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; } | 57 | bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; } |
53 | long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; } | 58 | long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; } |
54 | // bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 59 | #ifdef OLD_MEDIAPLAYER_API |
55 | // bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 60 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
61 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | ||
62 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | ||
63 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
64 | #else | ||
56 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 65 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
57 | // bool audioReadSamples( short *output, int channel, long samples, int stream ); | 66 | #endif |
58 | // bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
59 | 67 | ||
60 | // If decoder doesn't support video then return 0 here | 68 | // If decoder doesn't support video then return 0 here |
61 | int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; } | 69 | int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; } |
@@ -102,6 +110,8 @@ public: | |||
102 | bool supportsStereo() { return TRUE; } | 110 | bool supportsStereo() { return TRUE; } |
103 | bool supportsScaling() { return TRUE; } | 111 | bool supportsScaling() { return TRUE; } |
104 | 112 | ||
113 | long getPlayTime() { return -1; } | ||
114 | |||
105 | private: | 115 | private: |
106 | mpeg3_t *file; | 116 | mpeg3_t *file; |
107 | QString strInfo; | 117 | QString strInfo; |
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h index 29ec6ba..89abf97 100644 --- a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h +++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #define LIBMPEG3_PLUGIN_IMPL_H | 21 | #define LIBMPEG3_PLUGIN_IMPL_H |
22 | 22 | ||
23 | 23 | ||
24 | //#include <qpe/mediaplayerplugininterface.h> | ||
24 | #include "../mediaplayerplugininterface.h" | 25 | #include "../mediaplayerplugininterface.h" |
25 | 26 | ||
26 | 27 | ||
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 6dfd057..859a67a 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp | |||
@@ -17,7 +17,10 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
20 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | |||
21 | #ifdef Q_WS_QWS | 24 | #ifdef Q_WS_QWS |
22 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
23 | #endif | 26 | #endif |
@@ -42,13 +45,13 @@ extern MediaPlayerState *mediaPlayerState; | |||
42 | #define DecodeLoopDebug(x) | 45 | #define DecodeLoopDebug(x) |
43 | 46 | ||
44 | 47 | ||
45 | static char *audioBuffer = NULL; | 48 | static char *audioBuffer = NULL; |
46 | static AudioDevice *audioDevice = NULL; | 49 | static AudioDevice *audioDevice = NULL; |
47 | static bool disabledSuspendScreenSaver = FALSE; | 50 | static bool disabledSuspendScreenSaver = FALSE; |
48 | static bool previousSuspendMode = FALSE; | 51 | static bool previousSuspendMode = FALSE; |
49 | 52 | ||
50 | 53 | ||
51 | pthread_taudio_tid; | 54 | pthread_t audio_tid; |
52 | pthread_attr_t audio_attr; | 55 | pthread_attr_t audio_attr; |
53 | bool threadOkToGo = FALSE; | 56 | bool threadOkToGo = FALSE; |
54 | 57 | ||
@@ -56,22 +59,22 @@ bool threadOkToGo = FALSE; | |||
56 | class Mutex { | 59 | class Mutex { |
57 | public: | 60 | public: |
58 | Mutex() { | 61 | Mutex() { |
59 | pthread_mutexattr_t attr; | 62 | pthread_mutexattr_t attr; |
60 | pthread_mutexattr_init( &attr ); | 63 | pthread_mutexattr_init( &attr ); |
61 | pthread_mutex_init( &mutex, &attr ); | 64 | pthread_mutex_init( &mutex, &attr ); |
62 | pthread_mutexattr_destroy( &attr ); | 65 | pthread_mutexattr_destroy( &attr ); |
63 | } | 66 | } |
64 | 67 | ||
65 | ~Mutex() { | 68 | ~Mutex() { |
66 | pthread_mutex_destroy( &mutex ); | 69 | pthread_mutex_destroy( &mutex ); |
67 | } | 70 | } |
68 | 71 | ||
69 | void lock() { | 72 | void lock() { |
70 | pthread_mutex_lock( &mutex ); | 73 | pthread_mutex_lock( &mutex ); |
71 | } | 74 | } |
72 | 75 | ||
73 | void unlock() { | 76 | void unlock() { |
74 | pthread_mutex_unlock( &mutex ); | 77 | pthread_mutex_unlock( &mutex ); |
75 | } | 78 | } |
76 | private: | 79 | private: |
77 | pthread_mutex_t mutex; | 80 | pthread_mutex_t mutex; |
@@ -81,10 +84,10 @@ private: | |||
81 | void *startAudioThread( void *ptr ) { | 84 | void *startAudioThread( void *ptr ) { |
82 | LoopControl *mpegView = (LoopControl *)ptr; | 85 | LoopControl *mpegView = (LoopControl *)ptr; |
83 | while ( TRUE ) { | 86 | while ( TRUE ) { |
84 | if ( threadOkToGo && mpegView->moreAudio ) | 87 | if ( threadOkToGo && mpegView->moreAudio ) |
85 | mpegView->startAudio(); | 88 | mpegView->startAudio(); |
86 | else | 89 | else |
87 | usleep( 10000 ); // Semi-buzy-wait till we are playing again | 90 | usleep( 10000 ); // Semi-buzy-wait till we are playing again |
88 | } | 91 | } |
89 | return 0; | 92 | return 0; |
90 | } | 93 | } |
@@ -105,13 +108,13 @@ LoopControl::LoopControl( QObject *parent, const char *name ) | |||
105 | #ifdef USE_REALTIME_AUDIO_THREAD | 108 | #ifdef USE_REALTIME_AUDIO_THREAD |
106 | // Attempt to set it to real-time round robin | 109 | // Attempt to set it to real-time round robin |
107 | if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { | 110 | if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { |
108 | sched_param params; | 111 | sched_param params; |
109 | params.sched_priority = 50; | 112 | params.sched_priority = 50; |
110 | pthread_attr_setschedparam(&audio_attr,¶ms); | 113 | pthread_attr_setschedparam(&audio_attr,¶ms); |
111 | } else { | 114 | } else { |
112 | qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); | 115 | qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); |
113 | pthread_attr_destroy(&audio_attr); | 116 | pthread_attr_destroy(&audio_attr); |
114 | pthread_attr_init(&audio_attr); | 117 | pthread_attr_init(&audio_attr); |
115 | } | 118 | } |
116 | #endif | 119 | #endif |
117 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); | 120 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); |
@@ -130,14 +133,14 @@ static int currentSample = 0; | |||
130 | void LoopControl::timerEvent( QTimerEvent *te ) { | 133 | void LoopControl::timerEvent( QTimerEvent *te ) { |
131 | 134 | ||
132 | if ( te->timerId() == videoId ) | 135 | if ( te->timerId() == videoId ) |
133 | startVideo(); | 136 | startVideo(); |
134 | 137 | ||
135 | if ( te->timerId() == sliderId ) { | 138 | if ( te->timerId() == sliderId ) { |
136 | if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { | 139 | if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { |
137 | mediaPlayerState->updatePosition( audioSampleCounter ); | 140 | mediaPlayerState->updatePosition( audioSampleCounter ); |
138 | } else if ( hasVideoChannel && moreVideo ) { | 141 | } else if ( hasVideoChannel && moreVideo ) { |
139 | mediaPlayerState->updatePosition( current_frame ); | 142 | mediaPlayerState->updatePosition( current_frame ); |
140 | } | 143 | } |
141 | } | 144 | } |
142 | 145 | ||
143 | if ( !moreVideo && !moreAudio ) { | 146 | if ( !moreVideo && !moreAudio ) { |
@@ -151,26 +154,26 @@ void LoopControl::setPosition( long pos ) { | |||
151 | audioMutex->lock(); | 154 | audioMutex->lock(); |
152 | 155 | ||
153 | if ( hasVideoChannel && hasAudioChannel ) { | 156 | if ( hasVideoChannel && hasAudioChannel ) { |
154 | playtime.restart(); | 157 | playtime.restart(); |
155 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); | 158 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); |
156 | current_frame = pos + 1; | 159 | current_frame = pos + 1; |
157 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 160 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
158 | prev_frame = current_frame - 1; | 161 | prev_frame = current_frame - 1; |
159 | currentSample = (int)( (double)current_frame * freq / framerate ); | 162 | currentSample = (int)( (double)current_frame * freq / framerate ); |
160 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); | 163 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); |
161 | audioSampleCounter = currentSample - 1; | 164 | audioSampleCounter = currentSample - 1; |
162 | } else if ( hasVideoChannel ) { | 165 | } else if ( hasVideoChannel ) { |
163 | playtime.restart(); | 166 | playtime.restart(); |
164 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); | 167 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); |
165 | current_frame = pos + 1; | 168 | current_frame = pos + 1; |
166 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 169 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
167 | prev_frame = current_frame - 1; | 170 | prev_frame = current_frame - 1; |
168 | } else if ( hasAudioChannel ) { | 171 | } else if ( hasAudioChannel ) { |
169 | playtime.restart(); | 172 | playtime.restart(); |
170 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); | 173 | playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); |
171 | currentSample = pos + 1; | 174 | currentSample = pos + 1; |
172 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); | 175 | mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); |
173 | audioSampleCounter = currentSample - 1; | 176 | audioSampleCounter = currentSample - 1; |
174 | } | 177 | } |
175 | 178 | ||
176 | audioMutex->unlock(); | 179 | audioMutex->unlock(); |
@@ -183,32 +186,32 @@ void LoopControl::startVideo() { | |||
183 | 186 | ||
184 | if ( mediaPlayerState->curDecoder() ) { | 187 | if ( mediaPlayerState->curDecoder() ) { |
185 | 188 | ||
186 | if ( hasAudioChannel && !isMuted ) { | 189 | if ( hasAudioChannel && !isMuted ) { |
187 | 190 | ||
188 | current_frame = long( playtime.elapsed() * framerate / 1000 ); | 191 | current_frame = long( playtime.elapsed() * framerate / 1000 ); |
189 | 192 | ||
190 | if ( prev_frame != -1 && current_frame <= prev_frame ) | 193 | if ( prev_frame != -1 && current_frame <= prev_frame ) |
191 | return; | 194 | return; |
192 | 195 | ||
193 | } else { | 196 | } else { |
194 | // Don't skip | 197 | // Don't skip |
195 | current_frame++; | 198 | current_frame++; |
196 | } | 199 | } |
197 | 200 | ||
198 | if ( prev_frame == -1 || current_frame > prev_frame ) { | 201 | if ( prev_frame == -1 || current_frame > prev_frame ) { |
199 | if ( current_frame > prev_frame + 1 ) { | 202 | if ( current_frame > prev_frame + 1 ) { |
200 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); | 203 | mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); |
201 | } | 204 | } |
202 | moreVideo = videoUI->playVideo(); | 205 | moreVideo = videoUI->playVideo(); |
203 | prev_frame = current_frame; | 206 | prev_frame = current_frame; |
204 | } | 207 | } |
205 | 208 | ||
206 | } else { | 209 | } else { |
207 | 210 | ||
208 | moreVideo = FALSE; | 211 | moreVideo = FALSE; |
209 | killTimer( videoId ); | 212 | killTimer( videoId ); |
210 | 213 | ||
211 | } | 214 | } |
212 | 215 | ||
213 | } | 216 | } |
214 | } | 217 | } |
@@ -220,36 +223,37 @@ void LoopControl::startAudio() { | |||
220 | 223 | ||
221 | if ( moreAudio ) { | 224 | if ( moreAudio ) { |
222 | 225 | ||
223 | if ( !isMuted && mediaPlayerState->curDecoder() ) { | 226 | if ( !isMuted && mediaPlayerState->curDecoder() ) { |
224 | 227 | ||
225 | currentSample = audioSampleCounter + 1; | 228 | currentSample = audioSampleCounter + 1; |
226 | 229 | ||
227 | if ( currentSample != audioSampleCounter + 1 ) | 230 | if ( currentSample != audioSampleCounter + 1 ) |
228 | qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); | 231 | qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); |
229 | 232 | ||
230 | long samplesRead = 0; | 233 | long samplesRead = 0; |
231 | bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); | 234 | bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); |
232 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; | 235 | long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; |
233 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; | 236 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; |
234 | 237 | ||
235 | if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { | 238 | // if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 5000 ) ) { |
236 | usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); | 239 | // usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); |
237 | } else if ( sampleWaitTime <= -5000 ) { | 240 | // } |
238 | qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); | 241 | // else if ( sampleWaitTime <= -5000 ) { |
239 | //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); | 242 | // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); |
240 | currentSample = sampleWeShouldBeAt; | 243 | // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); |
241 | } | 244 | // currentSample = sampleWeShouldBeAt; |
245 | // } | ||
242 | 246 | ||
243 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); | 247 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); |
244 | audioSampleCounter = currentSample + samplesRead - 1; | 248 | audioSampleCounter = currentSample + samplesRead - 1; |
245 | 249 | ||
246 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); | 250 | moreAudio = readOk && (audioSampleCounter <= total_audio_samples); |
247 | 251 | ||
248 | } else { | 252 | } else { |
249 | 253 | ||
250 | moreAudio = FALSE; | 254 | moreAudio = FALSE; |
251 | 255 | ||
252 | } | 256 | } |
253 | 257 | ||
254 | } | 258 | } |
255 | 259 | ||
@@ -262,7 +266,7 @@ void LoopControl::killTimers() { | |||
262 | audioMutex->lock(); | 266 | audioMutex->lock(); |
263 | 267 | ||
264 | if ( hasVideoChannel ) | 268 | if ( hasVideoChannel ) |
265 | killTimer( videoId ); | 269 | killTimer( videoId ); |
266 | killTimer( sliderId ); | 270 | killTimer( sliderId ); |
267 | threadOkToGo = FALSE; | 271 | threadOkToGo = FALSE; |
268 | 272 | ||
@@ -278,14 +282,14 @@ void LoopControl::startTimers() { | |||
278 | moreAudio = FALSE; | 282 | moreAudio = FALSE; |
279 | 283 | ||
280 | if ( hasVideoChannel ) { | 284 | if ( hasVideoChannel ) { |
281 | moreVideo = TRUE; | 285 | moreVideo = TRUE; |
282 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value | 286 | int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value |
283 | videoId = startTimer( mSecsBetweenFrames ); | 287 | videoId = startTimer( mSecsBetweenFrames ); |
284 | } | 288 | } |
285 | 289 | ||
286 | if ( hasAudioChannel ) { | 290 | if ( hasAudioChannel ) { |
287 | moreAudio = TRUE; | 291 | moreAudio = TRUE; |
288 | threadOkToGo = TRUE; | 292 | threadOkToGo = TRUE; |
289 | } | 293 | } |
290 | 294 | ||
291 | sliderId = startTimer( 300 ); // update slider every 1/3 second | 295 | sliderId = startTimer( 300 ); // update slider every 1/3 second |
@@ -297,16 +301,16 @@ void LoopControl::startTimers() { | |||
297 | void LoopControl::setPaused( bool pause ) { | 301 | void LoopControl::setPaused( bool pause ) { |
298 | 302 | ||
299 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) | 303 | if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) |
300 | return; | 304 | return; |
301 | 305 | ||
302 | if ( pause ) { | 306 | if ( pause ) { |
303 | killTimers(); | 307 | killTimers(); |
304 | } else { | 308 | } else { |
305 | // Force an update of the position | 309 | // Force an update of the position |
306 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 310 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
307 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 311 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
308 | // Just like we never stopped | 312 | // Just like we never stopped |
309 | startTimers(); | 313 | startTimers(); |
310 | } | 314 | } |
311 | } | 315 | } |
312 | 316 | ||
@@ -315,28 +319,28 @@ void LoopControl::stop( bool willPlayAgainShortly ) { | |||
315 | 319 | ||
316 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 320 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
317 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { | 321 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { |
318 | disabledSuspendScreenSaver = FALSE; | 322 | disabledSuspendScreenSaver = FALSE; |
319 | // Re-enable the suspend mode | 323 | // Re-enable the suspend mode |
320 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 324 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
321 | } | 325 | } |
322 | #endif | 326 | #endif |
323 | 327 | ||
324 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { | 328 | if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { |
325 | 329 | ||
326 | killTimers(); | 330 | killTimers(); |
327 | 331 | ||
328 | audioMutex->lock(); | 332 | audioMutex->lock(); |
329 | 333 | ||
330 | mediaPlayerState->curDecoder()->close(); | 334 | mediaPlayerState->curDecoder()->close(); |
331 | 335 | ||
332 | if ( audioDevice ) { | 336 | if ( audioDevice ) { |
333 | delete audioDevice; | 337 | delete audioDevice; |
334 | delete audioBuffer; | 338 | delete audioBuffer; |
335 | audioDevice = 0; | 339 | audioDevice = 0; |
336 | audioBuffer = 0; | 340 | audioBuffer = 0; |
337 | } | 341 | } |
338 | 342 | ||
339 | audioMutex->unlock(); | 343 | audioMutex->unlock(); |
340 | 344 | ||
341 | } | 345 | } |
342 | } | 346 | } |
@@ -355,67 +359,67 @@ bool LoopControl::init( const QString& filename ) { | |||
355 | 359 | ||
356 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin | 360 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin |
357 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { | 361 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { |
358 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { | 362 | if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { |
359 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); | 363 | total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); |
360 | mediaPlayerState->libMpeg3Decoder()->close(); | 364 | mediaPlayerState->libMpeg3Decoder()->close(); |
361 | } | 365 | } |
362 | } | 366 | } |
363 | 367 | ||
364 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { | 368 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { |
365 | audioMutex->unlock(); | 369 | audioMutex->unlock(); |
366 | return FALSE; | 370 | return FALSE; |
367 | } | 371 | } |
368 | 372 | ||
369 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; | 373 | hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; |
370 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; | 374 | hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; |
371 | 375 | ||
372 | if ( hasAudioChannel ) { | 376 | if ( hasAudioChannel ) { |
373 | int astream = 0; | 377 | int astream = 0; |
374 | 378 | ||
375 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); | 379 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); |
376 | DecodeLoopDebug(( "channels = %d\n", channels )); | 380 | qDebug( "LC- channels = %d", channels ); |
377 | 381 | ||
378 | if ( !total_audio_samples ) | 382 | if ( !total_audio_samples ) |
379 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); | 383 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); |
380 | 384 | ||
381 | total_audio_samples += 1000; | 385 | // total_audio_samples += 1000; |
382 | 386 | ||
383 | mediaPlayerState->setLength( total_audio_samples ); | 387 | mediaPlayerState->setLength( total_audio_samples ); |
384 | 388 | ||
385 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); | 389 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); |
386 | DecodeLoopDebug(( "frequency = %d\n", freq )); | 390 | qDebug( "LC- frequency = %d", freq ); |
387 | 391 | ||
388 | audioSampleCounter = 0; | 392 | audioSampleCounter = 0; |
389 | 393 | ||
390 | static const int bytes_per_sample = 2; //16 bit | 394 | int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream); |
391 | 395 | ||
392 | audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); | 396 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); |
393 | audioBuffer = new char[ audioDevice->bufferSize() ]; | 397 | audioBuffer = new char[ audioDevice->bufferSize() ]; |
394 | channels = audioDevice->channels(); | 398 | channels = audioDevice->channels(); |
395 | 399 | ||
396 | //### must check which frequency is actually used. | 400 | //### must check which frequency is actually used. |
397 | static const int size = 1; | 401 | static const int size = 1; |
398 | short int buf[size]; | 402 | short int buf[size]; |
399 | long samplesRead = 0; | 403 | long samplesRead = 0; |
400 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); | 404 | mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); |
401 | } | 405 | } |
402 | 406 | ||
403 | if ( hasVideoChannel ) { | 407 | if ( hasVideoChannel ) { |
404 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); | 408 | total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); |
405 | 409 | ||
406 | mediaPlayerState->setLength( total_video_frames ); | 410 | mediaPlayerState->setLength( total_video_frames ); |
407 | 411 | ||
408 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); | 412 | framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); |
409 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); | 413 | DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); |
410 | 414 | ||
411 | if ( framerate <= 1.0 ) { | 415 | if ( framerate <= 1.0 ) { |
412 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); | 416 | DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); |
413 | framerate = 25; | 417 | framerate = 25; |
414 | } | 418 | } |
415 | 419 | ||
416 | if ( total_video_frames == 1 ) { | 420 | if ( total_video_frames == 1 ) { |
417 | DecodeLoopDebug(( "Cannot seek to frame" )); | 421 | DecodeLoopDebug(( "Cannot seek to frame" )); |
418 | } | 422 | } |
419 | 423 | ||
420 | } | 424 | } |
421 | 425 | ||
@@ -435,11 +439,11 @@ void LoopControl::play() { | |||
435 | 439 | ||
436 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 440 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
437 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { | 441 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { |
438 | disabledSuspendScreenSaver = TRUE; | 442 | disabledSuspendScreenSaver = TRUE; |
439 | previousSuspendMode = hasVideoChannel; | 443 | previousSuspendMode = hasVideoChannel; |
440 | // Stop the screen from blanking and power saving state | 444 | // Stop the screen from blanking and power saving state |
441 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 445 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
442 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 446 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
443 | } | 447 | } |
444 | #endif | 448 | #endif |
445 | 449 | ||
@@ -450,14 +454,14 @@ void LoopControl::play() { | |||
450 | 454 | ||
451 | void LoopControl::setMute( bool on ) { | 455 | void LoopControl::setMute( bool on ) { |
452 | if ( on != isMuted ) { | 456 | if ( on != isMuted ) { |
453 | isMuted = on; | 457 | isMuted = on; |
454 | if ( !on ) { | 458 | if ( !on ) { |
455 | // Force an update of the position | 459 | // Force an update of the position |
456 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); | 460 | mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); |
457 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); | 461 | mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); |
458 | // Resume playing audio | 462 | // Resume playing audio |
459 | moreAudio = TRUE; | 463 | moreAudio = TRUE; |
460 | } | 464 | } |
461 | } | 465 | } |
462 | } | 466 | } |
463 | 467 | ||
diff --git a/core/multimedia/opieplayer/loopcontrol.h b/core/multimedia/opieplayer/loopcontrol.h index 967ee25..fc7d316 100644 --- a/core/multimedia/opieplayer/loopcontrol.h +++ b/core/multimedia/opieplayer/loopcontrol.h | |||
@@ -17,6 +17,8 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
20 | #ifndef MPEGVIEW_H | 22 | #ifndef MPEGVIEW_H |
21 | #define MPEGVIEW_H | 23 | #define MPEGVIEW_H |
22 | 24 | ||
diff --git a/core/multimedia/opieplayer/loopcontrol_threaded.cpp b/core/multimedia/opieplayer/loopcontrol_threaded.cpp index 2ec4a48..2e49bb7 100644 --- a/core/multimedia/opieplayer/loopcontrol_threaded.cpp +++ b/core/multimedia/opieplayer/loopcontrol_threaded.cpp | |||
@@ -26,6 +26,7 @@ | |||
26 | #ifdef Q_WS_QWS | 26 | #ifdef Q_WS_QWS |
27 | #include <qpe/qcopenvelope_qws.h> | 27 | #include <qpe/qcopenvelope_qws.h> |
28 | #endif | 28 | #endif |
29 | #include "mediaplayerplugininterface.h" | ||
29 | #include <stdio.h> | 30 | #include <stdio.h> |
30 | #include <stdlib.h> | 31 | #include <stdlib.h> |
31 | #include <string.h> | 32 | #include <string.h> |
@@ -36,7 +37,6 @@ | |||
36 | #include "audiodevice.h" | 37 | #include "audiodevice.h" |
37 | #include "videowidget.h" | 38 | #include "videowidget.h" |
38 | #include "audiowidget.h" | 39 | #include "audiowidget.h" |
39 | #include "mediaplayerplugininterface.h" | ||
40 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
41 | 41 | ||
42 | 42 | ||
diff --git a/core/multimedia/opieplayer/main.cpp b/core/multimedia/opieplayer/main.cpp index 5246e40..9f7ef73 100644 --- a/core/multimedia/opieplayer/main.cpp +++ b/core/multimedia/opieplayer/main.cpp | |||
@@ -48,7 +48,7 @@ int main(int argc, char **argv) { | |||
48 | loopControl = &lc; | 48 | loopControl = &lc; |
49 | MediaPlayer mp( 0, "mediaPlayer" ); | 49 | MediaPlayer mp( 0, "mediaPlayer" ); |
50 | 50 | ||
51 | pl.setCaption( MediaPlayer::tr("Media Player") ); | 51 | pl.setCaption( MediaPlayer::tr("Opie Player") ); |
52 | a.showMainDocumentWidget(&pl); | 52 | a.showMainDocumentWidget(&pl); |
53 | 53 | ||
54 | return a.exec(); | 54 | return a.exec(); |
diff --git a/core/multimedia/opieplayer/mediaplayerplugininterface.h b/core/multimedia/opieplayer/mediaplayerplugininterface.h index 24d5a80..339b2e4 100644 --- a/core/multimedia/opieplayer/mediaplayerplugininterface.h +++ b/core/multimedia/opieplayer/mediaplayerplugininterface.h | |||
@@ -61,12 +61,7 @@ public: | |||
61 | virtual int audioSamples( int stream ) = 0; | 61 | virtual int audioSamples( int stream ) = 0; |
62 | virtual bool audioSetSample( long sample, int stream ) = 0; | 62 | virtual bool audioSetSample( long sample, int stream ) = 0; |
63 | virtual long audioGetSample( int stream ) = 0; | 63 | virtual long audioGetSample( int stream ) = 0; |
64 | // virtual bool audioReadMonoSamples( short *samples, long samples, long& samplesRead, int stream ) = 0; | ||
65 | // virtual bool audioReadStereoSamples( short *samples, long samples, long& samplesRead, int stream ) = 0; | ||
66 | virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0; | 64 | virtual bool audioReadSamples( short *samples, int channels, long samples, long& samplesRead, int stream ) = 0; |
67 | // Libmpeg3 functions, perhaps good for reading an audio file with 5 channels or something! | ||
68 | // virtual bool audioReadSamples( short *samples, int channel, long samples, int stream ) = 0; | ||
69 | // virtual bool audioReReadSamples( short *samples, int channel, long samples, int stream ) = 0; | ||
70 | 65 | ||
71 | // If decoder doesn't support video then return 0 here | 66 | // If decoder doesn't support video then return 0 here |
72 | virtual int videoStreams() = 0; | 67 | virtual int videoStreams() = 0; |
@@ -96,6 +91,9 @@ public: | |||
96 | virtual bool supportsStereo() = 0; | 91 | virtual bool supportsStereo() = 0; |
97 | virtual bool supportsScaling() = 0; | 92 | virtual bool supportsScaling() = 0; |
98 | 93 | ||
94 | // File Properies | ||
95 | virtual long getPlayTime() { return -1; } | ||
96 | virtual int audioBitsPerSample( int stream ) = 0; | ||
99 | }; | 97 | }; |
100 | 98 | ||
101 | 99 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp index 9b9d133..2a6bca3 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.cpp +++ b/core/multimedia/opieplayer/mediaplayerstate.cpp | |||
@@ -26,6 +26,8 @@ | |||
26 | #include "mediaplayerplugininterface.h" | 26 | #include "mediaplayerplugininterface.h" |
27 | #include "mediaplayerstate.h" | 27 | #include "mediaplayerstate.h" |
28 | 28 | ||
29 | |||
30 | |||
29 | #ifdef QT_NO_COMPONENT | 31 | #ifdef QT_NO_COMPONENT |
30 | // Plugins which are compiled in when no plugin architecture available | 32 | // Plugins which are compiled in when no plugin architecture available |
31 | #include "libmad/libmadpluginimpl.h" | 33 | #include "libmad/libmadpluginimpl.h" |
@@ -34,7 +36,7 @@ | |||
34 | #endif | 36 | #endif |
35 | 37 | ||
36 | 38 | ||
37 | //#define MediaPlayerDebug(x)qDebug x | 39 | //#define MediaPlayerDebug(x) qDebug x |
38 | #define MediaPlayerDebug(x) | 40 | #define MediaPlayerDebug(x) |
39 | 41 | ||
40 | 42 | ||
@@ -95,10 +97,10 @@ MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { | |||
95 | MediaPlayerDecoder *tmpDecoder = NULL; | 97 | MediaPlayerDecoder *tmpDecoder = NULL; |
96 | QValueList<MediaPlayerPlugin>::Iterator it; | 98 | QValueList<MediaPlayerPlugin>::Iterator it; |
97 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { | 99 | for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { |
98 | if ( (*it).decoder->isFileSupported( file ) ) { | 100 | if ( (*it).decoder->isFileSupported( file ) ) { |
99 | tmpDecoder = (*it).decoder; | 101 | tmpDecoder = (*it).decoder; |
100 | break; | 102 | break; |
101 | } | 103 | } |
102 | } | 104 | } |
103 | return decoder = tmpDecoder; | 105 | return decoder = tmpDecoder; |
104 | } | 106 | } |
@@ -114,15 +116,19 @@ MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { | |||
114 | return libmpeg3decoder; | 116 | return libmpeg3decoder; |
115 | } | 117 | } |
116 | 118 | ||
119 | // ### hack to get true sample count | ||
120 | // MediaPlayerDecoder *MediaPlayerState::libWavDecoder() { | ||
121 | // return libwavdecoder; | ||
122 | // } | ||
117 | 123 | ||
118 | void MediaPlayerState::loadPlugins() { | 124 | void MediaPlayerState::loadPlugins() { |
119 | 125 | ||
120 | #ifndef QT_NO_COMPONENT | 126 | #ifndef QT_NO_COMPONENT |
121 | QValueList<MediaPlayerPlugin>::Iterator mit; | 127 | QValueList<MediaPlayerPlugin>::Iterator mit; |
122 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { | 128 | for ( mit = pluginList.begin(); mit != pluginList.end(); ++mit ) { |
123 | (*mit).iface->release(); | 129 | (*mit).iface->release(); |
124 | (*mit).library->unload(); | 130 | (*mit).library->unload(); |
125 | delete (*mit).library; | 131 | delete (*mit).library; |
126 | } | 132 | } |
127 | pluginList.clear(); | 133 | pluginList.clear(); |
128 | 134 | ||
@@ -131,29 +137,29 @@ void MediaPlayerState::loadPlugins() { | |||
131 | QStringList list = dir.entryList(); | 137 | QStringList list = dir.entryList(); |
132 | QStringList::Iterator it; | 138 | QStringList::Iterator it; |
133 | for ( it = list.begin(); it != list.end(); ++it ) { | 139 | for ( it = list.begin(); it != list.end(); ++it ) { |
134 | MediaPlayerPluginInterface *iface = 0; | 140 | MediaPlayerPluginInterface *iface = 0; |
135 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 141 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
136 | 142 | ||
137 | MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); | 143 | MediaPlayerDebug(( "querying: %s", QString( path + "/" + *it ).latin1() )); |
138 | 144 | ||
139 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { | 145 | if ( lib->queryInterface( IID_MediaPlayerPlugin, (QUnknownInterface**)&iface ) == QS_OK ) { |
140 | 146 | ||
141 | MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); | 147 | MediaPlayerDebug(( "loading: %s", QString( path + "/" + *it ).latin1() )); |
142 | 148 | ||
143 | MediaPlayerPlugin plugin; | 149 | MediaPlayerPlugin plugin; |
144 | plugin.library = lib; | 150 | plugin.library = lib; |
145 | plugin.iface = iface; | 151 | plugin.iface = iface; |
146 | plugin.decoder = plugin.iface->decoder(); | 152 | plugin.decoder = plugin.iface->decoder(); |
147 | plugin.encoder = plugin.iface->encoder(); | 153 | plugin.encoder = plugin.iface->encoder(); |
148 | pluginList.append( plugin ); | 154 | pluginList.append( plugin ); |
149 | 155 | ||
150 | // ### hack to get true sample count | 156 | // ### hack to get true sample count |
151 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) | 157 | if ( plugin.decoder->pluginName() == QString("LibMpeg3Plugin") ) |
152 | libmpeg3decoder = plugin.decoder; | 158 | libmpeg3decoder = plugin.decoder; |
153 | 159 | ||
154 | } else { | 160 | } else { |
155 | delete lib; | 161 | delete lib; |
156 | } | 162 | } |
157 | } | 163 | } |
158 | #else | 164 | #else |
159 | pluginList.clear(); | 165 | pluginList.clear(); |
@@ -178,8 +184,8 @@ void MediaPlayerState::loadPlugins() { | |||
178 | #endif | 184 | #endif |
179 | 185 | ||
180 | if ( pluginList.count() ) | 186 | if ( pluginList.count() ) |
181 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); | 187 | MediaPlayerDebug(( "%i decoders found", pluginList.count() )); |
182 | else | 188 | else |
183 | MediaPlayerDebug(( "No decoders found" )); | 189 | MediaPlayerDebug(( "No decoders found" )); |
184 | } | 190 | } |
185 | 191 | ||
diff --git a/core/multimedia/opieplayer/mediaplayerstate.h b/core/multimedia/opieplayer/mediaplayerstate.h index 5d95b92..1a23742 100644 --- a/core/multimedia/opieplayer/mediaplayerstate.h +++ b/core/multimedia/opieplayer/mediaplayerstate.h | |||
@@ -34,47 +34,47 @@ public: | |||
34 | MediaPlayerState( QObject *parent, const char *name ); | 34 | MediaPlayerState( QObject *parent, const char *name ); |
35 | ~MediaPlayerState(); | 35 | ~MediaPlayerState(); |
36 | 36 | ||
37 | bool fullscreen() { return isFullscreen; } | 37 | bool fullscreen() { return isFullscreen; } |
38 | bool scaled() { return isScaled; } | 38 | bool scaled() { return isScaled; } |
39 | bool looping() { return isLooping; } | 39 | bool looping() { return isLooping; } |
40 | bool shuffled() { return isShuffled; } | 40 | bool shuffled() { return isShuffled; } |
41 | bool playlist() { return usePlaylist; } | 41 | bool playlist() { return usePlaylist; } |
42 | bool paused() { return isPaused; } | 42 | bool paused() { return isPaused; } |
43 | bool playing() { return isPlaying; } | 43 | bool playing() { return isPlaying; } |
44 | long position() { return curPosition; } | 44 | long position() { return curPosition; } |
45 | long length() { return curLength; } | 45 | long length() { return curLength; } |
46 | char view() { return curView; } | 46 | char view() { return curView; } |
47 | 47 | ||
48 | MediaPlayerDecoder *newDecoder( const QString& file ); | 48 | MediaPlayerDecoder *newDecoder( const QString& file ); |
49 | MediaPlayerDecoder *curDecoder(); | 49 | MediaPlayerDecoder *curDecoder(); |
50 | MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the | 50 | MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the |
51 | // number of audio samples if we are using the libmad plugin | 51 | // number of audio samples if we are using the libmad plugin |
52 | public slots: | 52 | public slots: |
53 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } | 53 | void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } |
54 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } | 54 | void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } |
55 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } | 55 | void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } |
56 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } | 56 | void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } |
57 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } | 57 | void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } |
58 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } | 58 | void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } |
59 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } | 59 | void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } |
60 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } | 60 | void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } |
61 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } | 61 | void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } |
62 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } | 62 | void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } |
63 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } | 63 | void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } |
64 | 64 | ||
65 | void setPrev() { emit prev(); } | 65 | void setPrev() { emit prev(); } |
66 | void setNext() { emit next(); } | 66 | void setNext() { emit next(); } |
67 | void setList() { setPlaying( FALSE ); setView('l'); } | 67 | void setList() { setPlaying( FALSE ); setView('l'); } |
68 | void setVideo() { setView('v'); } | 68 | void setVideo() { setView('v'); } |
69 | void setAudio() { setView('a'); } | 69 | void setAudio() { setView('a'); } |
70 | 70 | ||
71 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } | 71 | void toggleFullscreen() { setFullscreen( !isFullscreen ); } |
72 | void toggleScaled() { setScaled( !isScaled); } | 72 | void toggleScaled() { setScaled( !isScaled); } |
73 | void toggleLooping() { setLooping( !isLooping); } | 73 | void toggleLooping() { setLooping( !isLooping); } |
74 | void toggleShuffled() { setShuffled( !isShuffled); } | 74 | void toggleShuffled() { setShuffled( !isShuffled); } |
75 | void togglePlaylist() { setPlaylist( !usePlaylist); } | 75 | void togglePlaylist() { setPlaylist( !usePlaylist); } |
76 | void togglePaused() { setPaused( !isPaused); } | 76 | void togglePaused() { setPaused( !isPaused); } |
77 | void togglePlaying() { setPlaying( !isPlaying); } | 77 | void togglePlaying() { setPlaying( !isPlaying); } |
78 | 78 | ||
79 | signals: | 79 | signals: |
80 | void fullscreenToggled( bool ); | 80 | void fullscreenToggled( bool ); |
@@ -106,6 +106,7 @@ private: | |||
106 | 106 | ||
107 | MediaPlayerDecoder *decoder; | 107 | MediaPlayerDecoder *decoder; |
108 | MediaPlayerDecoder *libmpeg3decoder; | 108 | MediaPlayerDecoder *libmpeg3decoder; |
109 | // MediaPlayerDecoder *libwavdecoder; | ||
109 | 110 | ||
110 | void loadPlugins(); | 111 | void loadPlugins(); |
111 | void readConfig( Config& cfg ); | 112 | void readConfig( Config& cfg ); |
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index fbfb946..f17ab6f 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -34,8 +34,8 @@ | |||
34 | class PlayListSelectionItem : public QListViewItem { | 34 | class PlayListSelectionItem : public QListViewItem { |
35 | public: | 35 | public: |
36 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 36 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
37 | setText( 0, f->name() ); | 37 | setText( 0, f->name() ); |
38 | setPixmap( 0, f->pixmap() ); | 38 | setPixmap( 0, f->pixmap() ); |
39 | } | 39 | } |
40 | 40 | ||
41 | ~PlayListSelectionItem() { | 41 | ~PlayListSelectionItem() { |
@@ -71,19 +71,19 @@ void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | |||
71 | p->fillRect( r, QBrush( white ) ); | 71 | p->fillRect( r, QBrush( white ) ); |
72 | QImage logo = Resource::loadImage( "mpegplayer/background" ); | 72 | QImage logo = Resource::loadImage( "mpegplayer/background" ); |
73 | if ( !logo.isNull() ) | 73 | if ( !logo.isNull() ) |
74 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 74 | p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
75 | } | 75 | } |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | 78 | ||
79 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 79 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
80 | if ( event->state() == QMouseEvent::LeftButton ) { | 80 | if ( event->state() == QMouseEvent::LeftButton ) { |
81 | QListViewItem *currentItem = selectedItem(); | 81 | QListViewItem *currentItem = selectedItem(); |
82 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 82 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
83 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 83 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
84 | moveSelectedUp(); | 84 | moveSelectedUp(); |
85 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 85 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
86 | moveSelectedDown(); | 86 | moveSelectedDown(); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
@@ -91,13 +91,13 @@ void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | |||
91 | const DocLnk *PlayListSelection::current() { | 91 | const DocLnk *PlayListSelection::current() { |
92 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 92 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
93 | if ( item ) | 93 | if ( item ) |
94 | return item->file(); | 94 | return item->file(); |
95 | return NULL; | 95 | return NULL; |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 99 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
100 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 100 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
101 | QListViewItem *current = selectedItem(); | 101 | QListViewItem *current = selectedItem(); |
102 | if ( current ) | 102 | if ( current ) |
103 | item->moveItem( current ); | 103 | item->moveItem( current ); |
@@ -109,7 +109,7 @@ void PlayListSelection::addToSelection( const DocLnk &lnk ) { | |||
109 | void PlayListSelection::removeSelected() { | 109 | void PlayListSelection::removeSelected() { |
110 | QListViewItem *item = selectedItem(); | 110 | QListViewItem *item = selectedItem(); |
111 | if ( item ) | 111 | if ( item ) |
112 | delete item; | 112 | delete item; |
113 | setSelected( currentItem(), TRUE ); | 113 | setSelected( currentItem(), TRUE ); |
114 | ensureItemVisible( selectedItem() ); | 114 | ensureItemVisible( selectedItem() ); |
115 | } | 115 | } |
@@ -118,7 +118,7 @@ void PlayListSelection::removeSelected() { | |||
118 | void PlayListSelection::moveSelectedUp() { | 118 | void PlayListSelection::moveSelectedUp() { |
119 | QListViewItem *item = selectedItem(); | 119 | QListViewItem *item = selectedItem(); |
120 | if ( item && item->itemAbove() ) | 120 | if ( item && item->itemAbove() ) |
121 | item->itemAbove()->moveItem( item ); | 121 | item->itemAbove()->moveItem( item ); |
122 | ensureItemVisible( selectedItem() ); | 122 | ensureItemVisible( selectedItem() ); |
123 | } | 123 | } |
124 | 124 | ||
@@ -136,7 +136,7 @@ bool PlayListSelection::prev() { | |||
136 | if ( item && item->itemAbove() ) | 136 | if ( item && item->itemAbove() ) |
137 | setSelected( item->itemAbove(), TRUE ); | 137 | setSelected( item->itemAbove(), TRUE ); |
138 | else | 138 | else |
139 | return FALSE; | 139 | return FALSE; |
140 | ensureItemVisible( selectedItem() ); | 140 | ensureItemVisible( selectedItem() ); |
141 | return TRUE; | 141 | return TRUE; |
142 | } | 142 | } |
@@ -147,7 +147,7 @@ bool PlayListSelection::next() { | |||
147 | if ( item && item->itemBelow() ) | 147 | if ( item && item->itemBelow() ) |
148 | setSelected( item->itemBelow(), TRUE ); | 148 | setSelected( item->itemBelow(), TRUE ); |
149 | else | 149 | else |
150 | return FALSE; | 150 | return FALSE; |
151 | ensureItemVisible( selectedItem() ); | 151 | ensureItemVisible( selectedItem() ); |
152 | return TRUE; | 152 | return TRUE; |
153 | } | 153 | } |
@@ -158,7 +158,7 @@ bool PlayListSelection::first() { | |||
158 | if ( item ) | 158 | if ( item ) |
159 | setSelected( item, TRUE ); | 159 | setSelected( item, TRUE ); |
160 | else | 160 | else |
161 | return FALSE; | 161 | return FALSE; |
162 | ensureItemVisible( selectedItem() ); | 162 | ensureItemVisible( selectedItem() ); |
163 | return TRUE; | 163 | return TRUE; |
164 | } | 164 | } |
@@ -168,11 +168,11 @@ bool PlayListSelection::last() { | |||
168 | QListViewItem *prevItem = NULL; | 168 | QListViewItem *prevItem = NULL; |
169 | QListViewItem *item = firstChild(); | 169 | QListViewItem *item = firstChild(); |
170 | while ( ( item = item->nextSibling() ) ) | 170 | while ( ( item = item->nextSibling() ) ) |
171 | prevItem = item; | 171 | prevItem = item; |
172 | if ( prevItem ) | 172 | if ( prevItem ) |
173 | setSelected( prevItem, TRUE ); | 173 | setSelected( prevItem, TRUE ); |
174 | else | 174 | else |
175 | return FALSE; | 175 | return FALSE; |
176 | ensureItemVisible( selectedItem() ); | 176 | ensureItemVisible( selectedItem() ); |
177 | return TRUE; | 177 | return TRUE; |
178 | } | 178 | } |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 969fc4b..4e1543e 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -20,6 +20,8 @@ | |||
20 | #include <qpe/qpemenubar.h> | 20 | #include <qpe/qpemenubar.h> |
21 | #include <qpe/qpetoolbar.h> | 21 | #include <qpe/qpetoolbar.h> |
22 | #include <qpe/fileselector.h> | 22 | #include <qpe/fileselector.h> |
23 | #include <qpe/qpeapplication.h> | ||
24 | |||
23 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
24 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
25 | #include <qpe/global.h> | 27 | #include <qpe/global.h> |
@@ -34,6 +36,10 @@ | |||
34 | #include <qmainwindow.h> | 36 | #include <qmainwindow.h> |
35 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
36 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
39 | #include <qtabwidget.h> | ||
40 | #include <qlistview.h> | ||
41 | #include <qpoint.h> | ||
42 | #include <qtimer.h> | ||
37 | 43 | ||
38 | #include "playlistselection.h" | 44 | #include "playlistselection.h" |
39 | #include "playlistwidget.h" | 45 | #include "playlistwidget.h" |
@@ -41,18 +47,18 @@ | |||
41 | 47 | ||
42 | #include <stdlib.h> | 48 | #include <stdlib.h> |
43 | 49 | ||
50 | #define BUTTONS_ON_TOOLBAR | ||
51 | #define SIDE_BUTTONS | ||
52 | #define CAN_SAVE_LOAD_PLAYLISTS | ||
44 | 53 | ||
45 | extern MediaPlayerState *mediaPlayerState; | 54 | extern MediaPlayerState *mediaPlayerState; |
46 | 55 | ||
56 | // class myFileSelector { | ||
47 | 57 | ||
58 | // }; | ||
48 | class PlayListWidgetPrivate { | 59 | class PlayListWidgetPrivate { |
49 | public: | 60 | public: |
50 | QToolButton *tbPlay; | 61 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
51 | QToolButton *tbFull; | ||
52 | QToolButton *tbLoop; | ||
53 | QToolButton *tbScale; | ||
54 | QToolButton *tbShuffle; | ||
55 | |||
56 | QFrame *playListFrame; | 62 | QFrame *playListFrame; |
57 | FileSelector *files; | 63 | FileSelector *files; |
58 | PlayListSelection *selectedFiles; | 64 | PlayListSelection *selectedFiles; |
@@ -64,14 +70,14 @@ public: | |||
64 | class ToolButton : public QToolButton { | 70 | class ToolButton : public QToolButton { |
65 | public: | 71 | public: |
66 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 72 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
67 | : QToolButton( parent, name ) { | 73 | : QToolButton( parent, name ) { |
68 | setTextLabel( name ); | 74 | setTextLabel( name ); |
69 | setPixmap( Resource::loadPixmap( icon ) ); | 75 | setPixmap( Resource::loadPixmap( icon ) ); |
70 | setAutoRaise( TRUE ); | 76 | setAutoRaise( TRUE ); |
71 | setFocusPolicy( QWidget::NoFocus ); | 77 | setFocusPolicy( QWidget::NoFocus ); |
72 | setToggleButton( t ); | 78 | setToggleButton( t ); |
73 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 79 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
74 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 80 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
75 | } | 81 | } |
76 | }; | 82 | }; |
77 | 83 | ||
@@ -79,9 +85,9 @@ public: | |||
79 | class MenuItem : public QAction { | 85 | class MenuItem : public QAction { |
80 | public: | 86 | public: |
81 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 87 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
82 | : QAction( text, QString::null, 0, 0 ) { | 88 | : QAction( text, QString::null, 0, 0 ) { |
83 | connect( this, SIGNAL( activated() ), handler, slot ); | 89 | connect( this, SIGNAL( activated() ), handler, slot ); |
84 | addTo( parent ); | 90 | addTo( parent ); |
85 | } | 91 | } |
86 | }; | 92 | }; |
87 | 93 | ||
@@ -92,10 +98,12 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
92 | d = new PlayListWidgetPrivate; | 98 | d = new PlayListWidgetPrivate; |
93 | d->setDocumentUsed = FALSE; | 99 | d->setDocumentUsed = FALSE; |
94 | d->current = NULL; | 100 | d->current = NULL; |
101 | menuTimer = new QTimer( this ,"menu timer"), | ||
102 | connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | ||
95 | 103 | ||
96 | setBackgroundMode( PaletteButton ); | 104 | setBackgroundMode( PaletteButton ); |
97 | 105 | ||
98 | setCaption( tr("MediaPlayer") ); | 106 | setCaption( tr("OpiePlayer") ); |
99 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); | 107 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); |
100 | 108 | ||
101 | setToolBarsMovable( FALSE ); | 109 | setToolBarsMovable( FALSE ); |
@@ -110,77 +118,161 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
110 | 118 | ||
111 | QPEToolBar *bar = new QPEToolBar( this ); | 119 | QPEToolBar *bar = new QPEToolBar( this ); |
112 | bar->setLabel( tr( "Play Operations" ) ); | 120 | bar->setLabel( tr( "Play Operations" ) ); |
113 | #ifdef BUTTONS_ON_TOOLBAR | 121 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", |
114 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); | 122 | this , SLOT(addSelected()) ); |
115 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 123 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", |
116 | #endif | 124 | this , SLOT(removeSelected()) ); |
117 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 125 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", |
118 | d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE ); | 126 | mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); |
119 | d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE ); | 127 | |
128 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ), "mpegplayer/shuffle", | ||
129 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | ||
130 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "mpegplayer/loop", | ||
131 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | ||
132 | |||
133 | // d->tbFull = new ToolButton( bar, tr( "Fullscreen" ), "fullscreen", mediaPlayerState, SLOT(setFullscreen(bool)), TRUE ); | ||
134 | // d->tbScale = new ToolButton( bar, tr( "Scale" ), "mpegplayer/scale", mediaPlayerState, SLOT(setScaled(bool)), TRUE ); | ||
120 | 135 | ||
121 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 136 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
122 | menu->insertItem( tr( "PlayList" ), pmPlayList ); | 137 | menu->insertItem( tr( "File" ), pmPlayList ); |
123 | new MenuItem( pmPlayList, tr( "Toggle PlayList" ), mediaPlayerState, SLOT( togglePlaylist() ) ); | ||
124 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 138 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
125 | new MenuItem( pmPlayList, tr( "Add all music files" ), this, SLOT( addAllMusicToList() ) ); | 139 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
126 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 140 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
127 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 141 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
128 | #ifdef CAN_SAVE_LOAD_PLAYLISTS | ||
129 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 142 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
130 | new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); | 143 | new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); |
131 | #endif | 144 | |
145 | QPopupMenu *pmView = new QPopupMenu( this ); | ||
146 | menu->insertItem( tr( "View" ), pmView ); | ||
147 | |||
148 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | ||
149 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | ||
150 | fullScreenButton->addTo(pmView); | ||
151 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); | ||
152 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | ||
153 | scaleButton->addTo(pmView); | ||
132 | 154 | ||
133 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 155 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
156 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | ||
157 | // vbox4->setMargin(4); | ||
158 | // libString = new QLabel( tr(" Media Library"), vbox4 ); | ||
159 | // libString->setBackgroundMode( QButton::PaletteButton ); | ||
160 | // libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); | ||
161 | |||
162 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | ||
163 | |||
164 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | ||
165 | tabWidget->setTabShape(QTabWidget::Triangular); | ||
166 | |||
167 | |||
168 | QWidget *pTab; | ||
169 | pTab = new QWidget( tabWidget, "pTab" ); | ||
170 | playlistView = new QListView( pTab, "Videoview" ); | ||
171 | playlistView->setMinimumSize(236,260); | ||
172 | tabWidget->insertTab( pTab,"Playlist"); | ||
134 | 173 | ||
135 | // Add the playlist area | 174 | // Add the playlist area |
136 | QVBox *vbox3 = new QVBox( vbox5 ); vbox3->setBackgroundMode( PaletteButton ); | ||
137 | d->playListFrame = vbox3; | ||
138 | 175 | ||
139 | QLabel *plString = new QLabel( tr(" PlayList"), vbox3 ); | 176 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
140 | plString->setBackgroundMode( QButton::PaletteButton ); | 177 | d->playListFrame = vbox3; |
141 | plString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); | 178 | d->playListFrame ->setMinimumSize(235,260); |
142 | 179 | ||
143 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 180 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
144 | d->selectedFiles = new PlayListSelection( hbox2 ); | 181 | d->selectedFiles = new PlayListSelection( hbox2); |
145 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 182 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
146 | 183 | ||
147 | #ifndef BUTTONS_ON_TOOLBAR | 184 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
148 | d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); | 185 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
149 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 186 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
150 | #endif | 187 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
151 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 188 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
152 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 189 | |
153 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 190 | QWidget *aTab; |
154 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 191 | aTab = new QWidget( tabWidget, "aTab" ); |
155 | #ifndef BUTTONS_ON_TOOLBAR | 192 | audioView = new QListView( aTab, "Audioview" ); |
156 | d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 193 | audioView->setMinimumSize(233,260); |
157 | #endif | 194 | audioView->addColumn( "Title",150); |
195 | audioView->addColumn("Size", 45); | ||
196 | audioView->addColumn("Media",35); | ||
197 | audioView->setColumnAlignment(1, Qt::AlignRight); | ||
198 | audioView->setColumnAlignment(2, Qt::AlignRight); | ||
199 | tabWidget->insertTab(aTab,"Audio"); | ||
200 | // audioView | ||
201 | Global::findDocuments(&files, "audio/*"); | ||
202 | QListIterator<DocLnk> dit( files.children() ); | ||
203 | QString storage; | ||
204 | for ( ; dit.current(); ++dit ) { | ||
205 | QListViewItem * newItem; | ||
206 | if(dit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
207 | else if(dit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
208 | else storage="RAM"; | ||
209 | |||
210 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | ||
211 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | ||
212 | } | ||
213 | // videowidget | ||
214 | |||
215 | QWidget *vTab; | ||
216 | vTab = new QWidget( tabWidget, "vTab" ); | ||
217 | videoView = new QListView( vTab, "Videoview" ); | ||
218 | videoView->setMinimumSize(233,260); | ||
219 | |||
220 | videoView->addColumn("Title",150); | ||
221 | videoView->addColumn("Size",45); | ||
222 | videoView->addColumn("Media",35); | ||
223 | videoView->setColumnAlignment(1, Qt::AlignRight); | ||
224 | videoView->setColumnAlignment(2, Qt::AlignRight); | ||
225 | |||
226 | tabWidget->insertTab( vTab,"Video"); | ||
227 | |||
228 | Global::findDocuments(&vFiles, "video/*"); | ||
229 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
230 | for ( ; Vdit.current(); ++Vdit ) { | ||
231 | if( Vdit.current()->file().find("/mnt/cf") != -1 ) storage="CF"; | ||
232 | else if( Vdit.current()->file().find("/mnt/card") != -1 ) storage="SD"; | ||
233 | else storage="RAM"; | ||
234 | QListViewItem * newItem; | ||
235 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | ||
236 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | ||
237 | } | ||
238 | |||
239 | |||
240 | // d->tbPlay = new ToolButton( vbox1, tr( "Play" ), "mpegplayer/play", mediaPlayerState, SLOT(setPlaying(bool)), TRUE ); | ||
241 | // d->tbShuffle = new ToolButton( vbox1, tr( "Randomize" ), "mpegplayer/shuffle", mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | ||
158 | 242 | ||
159 | // add the library area | 243 | // add the library area |
160 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | ||
161 | 244 | ||
162 | QLabel *libString = new QLabel( tr(" Media Library"), vbox4 ); | 245 | // d->files->setBackgroundMode( PaletteButton ); |
163 | libString->setBackgroundMode( QButton::PaletteButton ); | 246 | // QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); |
164 | libString->setFont( QFont( "Helvetica", 8, QFont::Bold ) ); | ||
165 | 247 | ||
166 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 248 | // #ifdef SIDE_BUTTONS |
167 | d->files = new FileSelector( "video/*;audio/*", hbox6, "Find Media Files", FALSE, FALSE ); | 249 | // QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch |
168 | d->files->setBackgroundMode( PaletteButton ); | 250 | // #endif |
169 | QVBox *vbox7 = new QVBox( hbox6 ); vbox7->setBackgroundMode( PaletteButton ); | 251 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
252 | |||
253 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | ||
254 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | ||
170 | 255 | ||
171 | #ifdef SIDE_BUTTONS | 256 | connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
172 | new ToolButton( vbox7, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", d->selectedFiles, SLOT(addSelected()) ); | 257 | connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
173 | new ToolButton( vbox7, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", d->selectedFiles, SLOT(removeSelected()) ); | ||
174 | QVBox *stretch3 = new QVBox( vbox1 ); stretch3->setBackgroundMode( PaletteButton ); // add stretch | ||
175 | #endif | ||
176 | 258 | ||
177 | connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | 259 | connect( audioView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), |
260 | this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); | ||
261 | connect( videoView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint&, int ) ), | ||
262 | this, SLOT( addToSelection( QListViewItem *, const QPoint&, int )) ); | ||
263 | |||
264 | connect( playlistView, SIGNAL( pressed( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | ||
265 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | ||
266 | // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | ||
267 | // connect( d->files, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | ||
178 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 268 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
179 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 269 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
180 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 270 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
181 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbFull, SLOT( setOn( bool ) ) ); | 271 | |
182 | connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), d->tbScale, SLOT( setOn( bool ) ) ); | 272 | // connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setOn( bool ) ) ); |
183 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), d->tbScale, SLOT( setEnabled( bool ) ) ); | 273 | // connect( mediaPlayerState, SIGNAL( scaledToggled( bool ) ), scaleButton, SLOT( setEnabled( bool ) ) ); |
274 | // connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), fullScreenButton, SLOT( setEnabled( bool ) ) ); | ||
275 | |||
184 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 276 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
185 | 277 | ||
186 | setCentralWidget( vbox5 ); | 278 | setCentralWidget( vbox5 ); |
@@ -197,19 +289,20 @@ PlayListWidget::~PlayListWidget() { | |||
197 | writeConfig( cfg ); | 289 | writeConfig( cfg ); |
198 | 290 | ||
199 | if ( d->current ) | 291 | if ( d->current ) |
200 | delete d->current; | 292 | delete d->current; |
201 | delete d; | 293 | delete d; |
202 | } | 294 | } |
203 | 295 | ||
204 | 296 | ||
205 | void PlayListWidget::initializeStates() { | 297 | void PlayListWidget::initializeStates() { |
298 | |||
206 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 299 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
207 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 300 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
208 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 301 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
209 | d->tbFull->setOn( mediaPlayerState->fullscreen() ); | 302 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); |
210 | d->tbScale->setOn( mediaPlayerState->scaled() ); | 303 | // d->tbScale->setOn( mediaPlayerState->scaled() ); |
211 | d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | 304 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); |
212 | setPlaylist( mediaPlayerState->playlist() ); | 305 | // setPlaylist( mediaPlayerState->playlist() ); |
213 | } | 306 | } |
214 | 307 | ||
215 | 308 | ||
@@ -219,11 +312,11 @@ void PlayListWidget::readConfig( Config& cfg ) { | |||
219 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 312 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
220 | 313 | ||
221 | for ( int i = 0; i < noOfFiles; i++ ) { | 314 | for ( int i = 0; i < noOfFiles; i++ ) { |
222 | QString entryName; | 315 | QString entryName; |
223 | entryName.sprintf( "File%i", i + 1 ); | 316 | entryName.sprintf( "File%i", i + 1 ); |
224 | QString linkFile = cfg.readEntry( entryName ); | 317 | QString linkFile = cfg.readEntry( entryName ); |
225 | DocLnk lnk( linkFile ); | 318 | DocLnk lnk( linkFile ); |
226 | if ( lnk.isValid() ) | 319 | if ( lnk.isValid() ) |
227 | d->selectedFiles->addToSelection( lnk ); | 320 | d->selectedFiles->addToSelection( lnk ); |
228 | 321 | ||
229 | } | 322 | } |
@@ -237,28 +330,28 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
237 | 330 | ||
238 | d->selectedFiles->first(); | 331 | d->selectedFiles->first(); |
239 | do { | 332 | do { |
240 | const DocLnk *lnk = d->selectedFiles->current(); | 333 | const DocLnk *lnk = d->selectedFiles->current(); |
241 | if ( lnk ) { | 334 | if ( lnk ) { |
242 | QString entryName; | 335 | QString entryName; |
243 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 336 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
244 | cfg.writeEntry( entryName, lnk->linkFile() ); | 337 | cfg.writeEntry( entryName, lnk->linkFile() ); |
245 | // if this link does exist, add it so we have the file | 338 | // if this link does exist, add it so we have the file |
246 | // next time... | 339 | // next time... |
247 | if ( !QFile::exists( lnk->linkFile() ) ) { | 340 | if ( !QFile::exists( lnk->linkFile() ) ) { |
248 | // the way writing lnks doesn't really check for out | 341 | // the way writing lnks doesn't really check for out |
249 | // of disk space, but check it anyway. | 342 | // of disk space, but check it anyway. |
250 | if ( !lnk->writeLink() ) { | 343 | if ( !lnk->writeLink() ) { |
251 | QMessageBox::critical( 0, tr("Out of space"), | 344 | QMessageBox::critical( 0, tr("Out of space"), |
252 | tr( "There was a problem saving " | 345 | tr( "There was a problem saving " |
253 | "the playlist.\n" | 346 | "the playlist.\n" |
254 | "Your playlist " | 347 | "Your playlist " |
255 | "may be missing some entries\n" | 348 | "may be missing some entries\n" |
256 | "the next time you start it." ) | 349 | "the next time you start it." ) |
257 | ); | 350 | ); |
258 | } | 351 | } |
259 | } | 352 | } |
260 | noOfFiles++; | 353 | noOfFiles++; |
261 | } | 354 | } |
262 | } while ( d->selectedFiles->next() ); | 355 | } while ( d->selectedFiles->next() ); |
263 | 356 | ||
264 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 357 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
@@ -266,17 +359,27 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
266 | 359 | ||
267 | 360 | ||
268 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 361 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
269 | d->setDocumentUsed = FALSE; | 362 | d->setDocumentUsed = FALSE; |
270 | if ( mediaPlayerState->playlist() ) | 363 | if ( mediaPlayerState->playlist() ) |
271 | d->selectedFiles->addToSelection( lnk ); | 364 | d->selectedFiles->addToSelection( lnk ); |
272 | else | 365 | else |
273 | mediaPlayerState->setPlaying( TRUE ); | 366 | mediaPlayerState->setPlaying( TRUE ); |
367 | } | ||
368 | |||
369 | |||
370 | void PlayListWidget::addToSelection( QListViewItem *it ,const QPoint & p, int index) { | ||
371 | qDebug("add"); | ||
372 | // d->selectedFiles->addToSelection( lnk ); | ||
373 | // } | ||
374 | // else | ||
375 | // mediaPlayerState->setPlaying( TRUE ); | ||
376 | // | ||
274 | } | 377 | } |
275 | 378 | ||
276 | 379 | ||
277 | void PlayListWidget::clearList() { | 380 | void PlayListWidget::clearList() { |
278 | while ( first() ) | 381 | while ( first() ) |
279 | d->selectedFiles->removeSelected(); | 382 | d->selectedFiles->removeSelected(); |
280 | } | 383 | } |
281 | 384 | ||
282 | 385 | ||
@@ -309,16 +412,16 @@ void PlayListWidget::addAllVideoToList() { | |||
309 | 412 | ||
310 | void PlayListWidget::setDocument(const QString& fileref) { | 413 | void PlayListWidget::setDocument(const QString& fileref) { |
311 | if ( fileref.isNull() ) { | 414 | if ( fileref.isNull() ) { |
312 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 415 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
313 | return; | 416 | return; |
314 | } | 417 | } |
315 | if ( mediaPlayerState->playlist() ) | 418 | if ( mediaPlayerState->playlist() ) |
316 | addToSelection( DocLnk( fileref ) ); | 419 | addToSelection( DocLnk( fileref ) ); |
317 | else { | 420 | else { |
318 | d->setDocumentUsed = TRUE; | 421 | d->setDocumentUsed = TRUE; |
319 | if ( d->current ) | 422 | if ( d->current ) |
320 | delete d->current; | 423 | delete d->current; |
321 | d->current = new DocLnk( fileref ); | 424 | d->current = new DocLnk( fileref ); |
322 | } | 425 | } |
323 | mediaPlayerState->setPlaying( FALSE ); | 426 | mediaPlayerState->setPlaying( FALSE ); |
324 | mediaPlayerState->setPlaying( TRUE ); | 427 | mediaPlayerState->setPlaying( TRUE ); |
@@ -340,76 +443,76 @@ void PlayListWidget::useSelectedDocument() { | |||
340 | 443 | ||
341 | const DocLnk *PlayListWidget::current() { | 444 | const DocLnk *PlayListWidget::current() { |
342 | if ( mediaPlayerState->playlist() ) | 445 | if ( mediaPlayerState->playlist() ) |
343 | return d->selectedFiles->current(); | 446 | return d->selectedFiles->current(); |
344 | else if ( d->setDocumentUsed && d->current ) { | 447 | else if ( d->setDocumentUsed && d->current ) { |
345 | return d->current; | 448 | return d->current; |
346 | } else | 449 | } else |
347 | return d->files->selected(); | 450 | return d->files->selected(); |
348 | } | 451 | } |
349 | 452 | ||
350 | 453 | ||
351 | bool PlayListWidget::prev() { | 454 | bool PlayListWidget::prev() { |
352 | if ( mediaPlayerState->playlist() ) { | 455 | if ( mediaPlayerState->playlist() ) { |
353 | if ( mediaPlayerState->shuffled() ) { | 456 | if ( mediaPlayerState->shuffled() ) { |
354 | const DocLnk *cur = current(); | 457 | const DocLnk *cur = current(); |
355 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 458 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
356 | for ( int i = 0; i < j; i++ ) { | 459 | for ( int i = 0; i < j; i++ ) { |
357 | if ( !d->selectedFiles->next() ) | 460 | if ( !d->selectedFiles->next() ) |
358 | d->selectedFiles->first(); | 461 | d->selectedFiles->first(); |
359 | } | 462 | } |
360 | if ( cur == current() ) | 463 | if ( cur == current() ) |
361 | if ( !d->selectedFiles->next() ) | 464 | if ( !d->selectedFiles->next() ) |
362 | d->selectedFiles->first(); | 465 | d->selectedFiles->first(); |
363 | return TRUE; | 466 | return TRUE; |
364 | } else { | 467 | } else { |
365 | if ( !d->selectedFiles->prev() ) { | 468 | if ( !d->selectedFiles->prev() ) { |
366 | if ( mediaPlayerState->looping() ) { | 469 | if ( mediaPlayerState->looping() ) { |
367 | return d->selectedFiles->last(); | 470 | return d->selectedFiles->last(); |
368 | } else { | 471 | } else { |
369 | return FALSE; | 472 | return FALSE; |
370 | } | 473 | } |
371 | } | 474 | } |
372 | return TRUE; | 475 | return TRUE; |
373 | } | 476 | } |
374 | } else { | 477 | } else { |
375 | return mediaPlayerState->looping(); | 478 | return mediaPlayerState->looping(); |
376 | } | 479 | } |
377 | } | 480 | } |
378 | 481 | ||
379 | 482 | ||
380 | bool PlayListWidget::next() { | 483 | bool PlayListWidget::next() { |
381 | if ( mediaPlayerState->playlist() ) { | 484 | if ( mediaPlayerState->playlist() ) { |
382 | if ( mediaPlayerState->shuffled() ) { | 485 | if ( mediaPlayerState->shuffled() ) { |
383 | return prev(); | 486 | return prev(); |
384 | } else { | 487 | } else { |
385 | if ( !d->selectedFiles->next() ) { | 488 | if ( !d->selectedFiles->next() ) { |
386 | if ( mediaPlayerState->looping() ) { | 489 | if ( mediaPlayerState->looping() ) { |
387 | return d->selectedFiles->first(); | 490 | return d->selectedFiles->first(); |
388 | } else { | ||
389 | return FALSE; | ||
390 | } | ||
391 | } | ||
392 | return TRUE; | ||
393 | } | ||
394 | } else { | 491 | } else { |
395 | return mediaPlayerState->looping(); | 492 | return FALSE; |
493 | } | ||
494 | } | ||
495 | return TRUE; | ||
496 | } | ||
497 | } else { | ||
498 | return mediaPlayerState->looping(); | ||
396 | } | 499 | } |
397 | } | 500 | } |
398 | 501 | ||
399 | 502 | ||
400 | bool PlayListWidget::first() { | 503 | bool PlayListWidget::first() { |
401 | if ( mediaPlayerState->playlist() ) | 504 | if ( mediaPlayerState->playlist() ) |
402 | return d->selectedFiles->first(); | 505 | return d->selectedFiles->first(); |
403 | else | 506 | else |
404 | return mediaPlayerState->looping(); | 507 | return mediaPlayerState->looping(); |
405 | } | 508 | } |
406 | 509 | ||
407 | 510 | ||
408 | bool PlayListWidget::last() { | 511 | bool PlayListWidget::last() { |
409 | if ( mediaPlayerState->playlist() ) | 512 | if ( mediaPlayerState->playlist() ) |
410 | return d->selectedFiles->last(); | 513 | return d->selectedFiles->last(); |
411 | else | 514 | else |
412 | return mediaPlayerState->looping(); | 515 | return mediaPlayerState->looping(); |
413 | } | 516 | } |
414 | 517 | ||
415 | 518 | ||
@@ -433,16 +536,158 @@ void PlayListWidget::loadList() { | |||
433 | 536 | ||
434 | void PlayListWidget::setPlaylist( bool shown ) { | 537 | void PlayListWidget::setPlaylist( bool shown ) { |
435 | if ( shown ) | 538 | if ( shown ) |
436 | d->playListFrame->show(); | 539 | d->playListFrame->show(); |
437 | else | 540 | else |
438 | d->playListFrame->hide(); | 541 | d->playListFrame->hide(); |
439 | } | 542 | } |
440 | 543 | ||
441 | 544 | ||
442 | void PlayListWidget::setView( char view ) { | 545 | void PlayListWidget::setView( char view ) { |
443 | if ( view == 'l' ) | 546 | if ( view == 'l' ) |
444 | showMaximized(); | 547 | showMaximized(); |
445 | else | 548 | else |
446 | hide(); | 549 | hide(); |
550 | } | ||
551 | |||
552 | void PlayListWidget::addSelected() { | ||
553 | // QMessageBox::message("Note","Bozo the clown thinks\nthere's something actually here"); | ||
554 | int tabPage=tabWidget->currentPageIndex(); | ||
555 | switch (tabPage) { | ||
556 | case 0: //playlist | ||
557 | break; | ||
558 | case 1: { //audio | ||
559 | addToSelection( audioView->selectedItem() ); | ||
560 | } | ||
561 | break; | ||
562 | case 2: { // video | ||
563 | addToSelection( videoView->selectedItem() ); | ||
564 | } | ||
565 | break; | ||
566 | }; | ||
567 | } | ||
568 | |||
569 | void PlayListWidget::removeSelected() { | ||
570 | d->selectedFiles->removeSelected( ); | ||
571 | } | ||
572 | |||
573 | |||
574 | void PlayListWidget::playIt( QListViewItem *it) { | ||
575 | d->setDocumentUsed = FALSE; | ||
576 | |||
577 | if(it) { | ||
578 | qDebug("playit"); | ||
579 | int tabPage=tabWidget->currentPageIndex(); | ||
580 | switch (tabPage) { | ||
581 | case 1: { | ||
582 | DocLnkSet files; | ||
583 | QListIterator<DocLnk> dit( files.children() ); | ||
584 | for ( ; dit.current(); ++dit ) { | ||
585 | if( dit.current()->name() == it->text(0)) { | ||
586 | setDocument( dit.current()->name()); | ||
587 | } | ||
588 | } | ||
589 | } | ||
590 | break; | ||
591 | case 2: { | ||
592 | DocLnkSet vFiles; | ||
593 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
594 | for ( ; dit.current(); ++dit ) { | ||
595 | qDebug(dit.current()->name()); | ||
596 | if( dit.current()->name() == it->text(0)) { | ||
597 | qDebug(it->text(0)); | ||
598 | setDocument( dit.current()->name()); | ||
599 | } | ||
600 | } | ||
601 | } | ||
602 | break; | ||
603 | }; | ||
604 | } | ||
605 | } | ||
606 | |||
607 | void PlayListWidget::addToSelection( QListViewItem *it) { | ||
608 | d->setDocumentUsed = FALSE; | ||
609 | |||
610 | if(it) { | ||
611 | qDebug("add to selection"); | ||
612 | int tabPage=tabWidget->currentPageIndex(); | ||
613 | switch (tabPage) { | ||
614 | case 1: { | ||
615 | QListIterator<DocLnk> dit( files.children() ); | ||
616 | for ( ; dit.current(); ++dit ) { | ||
617 | if( dit.current()->name() == it->text(0)) { | ||
618 | d->selectedFiles->addToSelection( **dit ); | ||
619 | } | ||
620 | } | ||
621 | } | ||
622 | break; | ||
623 | case 2: { | ||
624 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
625 | for ( ; dit.current(); ++dit ) { | ||
626 | qDebug(dit.current()->name()); | ||
627 | if( dit.current()->name() == it->text(0)) { | ||
628 | d->selectedFiles->addToSelection( **dit ); | ||
629 | } | ||
630 | } | ||
631 | } | ||
632 | break; | ||
633 | case 0: | ||
634 | break; | ||
635 | }; | ||
636 | tabWidget->setCurrentPage(0); | ||
637 | // mediaPlayerState->setPlaying( TRUE ); | ||
638 | } | ||
639 | } | ||
640 | |||
641 | void PlayListWidget::tabChanged(QWidget *widg) { | ||
642 | |||
643 | int tabPage=tabWidget->currentPageIndex(); | ||
644 | switch (tabPage) { | ||
645 | case 0: | ||
646 | { | ||
647 | d->tbRemoveFromList->setEnabled(TRUE); | ||
648 | d->tbAddToList->setEnabled(FALSE); | ||
649 | } | ||
650 | break; | ||
651 | case 1: | ||
652 | { | ||
653 | d->tbRemoveFromList->setEnabled(FALSE); | ||
654 | d->tbAddToList->setEnabled(TRUE); | ||
655 | } | ||
656 | break; | ||
657 | case 2: | ||
658 | { | ||
659 | d->tbRemoveFromList->setEnabled(FALSE); | ||
660 | d->tbAddToList->setEnabled(TRUE); | ||
661 | } | ||
662 | break; | ||
663 | }; | ||
664 | } | ||
665 | |||
666 | void PlayListWidget::cancelMenuTimer() { | ||
667 | if( menuTimer->isActive() ) | ||
668 | menuTimer->stop(); | ||
669 | } | ||
670 | |||
671 | void PlayListWidget::showFileMenu() { | ||
672 | |||
673 | } | ||
674 | |||
675 | void PlayListWidget::contentsMousePressEvent( QMouseEvent * e ) | ||
676 | { | ||
677 | // QListView::contentsMousePressEvent( e ); | ||
678 | menuTimer->start( 750, TRUE ); | ||
679 | } | ||
680 | |||
681 | |||
682 | void PlayListWidget::contentsMouseReleaseEvent( QMouseEvent * e ) | ||
683 | { | ||
684 | // QListView::contentsMouseReleaseEvent( e ); | ||
685 | menuTimer->stop(); | ||
447 | } | 686 | } |
687 | // void PlayListWidget::setFullScreen() { | ||
688 | // mediaPlayerState->toggleFullscreen( ); | ||
689 | // } | ||
448 | 690 | ||
691 | // void PlayListWidget::setScaled() { | ||
692 | // mediaPlayerState->toggleScaled(); | ||
693 | // } | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 6976641..3a52dd5 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -23,25 +23,39 @@ | |||
23 | 23 | ||
24 | #include <qmainwindow.h> | 24 | #include <qmainwindow.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qtabwidget.h> | ||
27 | #include <qtimer.h> | ||
26 | 28 | ||
27 | 29 | ||
28 | class PlayListWidgetPrivate; | 30 | class PlayListWidgetPrivate; |
29 | class Config; | 31 | class Config; |
30 | 32 | class QListViewItem; | |
33 | class QListView; | ||
34 | class QPoint; | ||
35 | class QAction; | ||
36 | class QLabel; | ||
31 | 37 | ||
32 | class PlayListWidget : public QMainWindow { | 38 | class PlayListWidget : public QMainWindow { |
33 | Q_OBJECT | 39 | Q_OBJECT |
34 | public: | 40 | public: |
35 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 41 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
36 | ~PlayListWidget(); | 42 | ~PlayListWidget(); |
37 | 43 | QTabWidget * tabWidget; | |
44 | QAction *fullScreenButton, *scaleButton; | ||
45 | DocLnkSet files; | ||
46 | DocLnkSet vFiles; | ||
47 | QListView *audioView, *videoView, *playlistView; | ||
48 | QLabel *libString; | ||
38 | // retrieve the current playlist entry (media file link) | 49 | // retrieve the current playlist entry (media file link) |
39 | const DocLnk *current(); | 50 | const DocLnk *current(); |
40 | void useSelectedDocument(); | 51 | void useSelectedDocument(); |
52 | QTimer * menuTimer; | ||
41 | 53 | ||
42 | public slots: | 54 | public slots: |
43 | void setDocument( const QString& fileref ); | 55 | void setDocument( const QString& fileref ); |
44 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 56 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
57 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | ||
58 | void addToSelection( QListViewItem*, const QPoint&,int ); // Add a media file to the playlist | ||
45 | void setActiveWindow(); // need to handle this to show the right view | 59 | void setActiveWindow(); // need to handle this to show the right view |
46 | void setPlaylist( bool ); // Show/Hide the playlist | 60 | void setPlaylist( bool ); // Show/Hide the playlist |
47 | void setView( char ); | 61 | void setView( char ); |
@@ -51,16 +65,31 @@ public slots: | |||
51 | void addAllVideoToList(); | 65 | void addAllVideoToList(); |
52 | void saveList(); // Save the playlist | 66 | void saveList(); // Save the playlist |
53 | void loadList(); // Load a playlist | 67 | void loadList(); // Load a playlist |
68 | void playIt( QListViewItem *); | ||
54 | bool first(); | 69 | bool first(); |
55 | bool last(); | 70 | bool last(); |
56 | bool next(); | 71 | bool next(); |
57 | bool prev(); | 72 | bool prev(); |
73 | void addSelected(); | ||
74 | void removeSelected(); | ||
75 | void tabChanged(QWidget*); | ||
76 | /* void setFullScreen(); */ | ||
77 | /* void setScaled(); */ | ||
78 | protected: | ||
79 | void contentsMousePressEvent( QMouseEvent * e ); | ||
80 | void contentsMouseReleaseEvent( QMouseEvent * e ); | ||
58 | 81 | ||
59 | private: | 82 | private: |
60 | void initializeStates(); | 83 | void initializeStates(); |
61 | void readConfig( Config& cfg ); | 84 | void readConfig( Config& cfg ); |
62 | void writeConfig( Config& cfg ) const; | 85 | void writeConfig( Config& cfg ) const; |
63 | PlayListWidgetPrivate *d; // Private implementation data | 86 | PlayListWidgetPrivate *d; // Private implementation data |
87 | |||
88 | protected slots: | ||
89 | void cancelMenuTimer(); | ||
90 | void showFileMenu(); | ||
91 | |||
92 | |||
64 | }; | 93 | }; |
65 | 94 | ||
66 | 95 | ||
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index f3974a0..1f128a4 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -18,13 +18,13 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include "mediaplayerplugininterface.h" | ||
21 | #include <qwidget.h> | 22 | #include <qwidget.h> |
22 | #include <qpainter.h> | 23 | #include <qpainter.h> |
23 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
24 | #include <qslider.h> | 25 | #include <qslider.h> |
25 | #include <qdrawutil.h> | 26 | #include <qdrawutil.h> |
26 | #include "videowidget.h" | 27 | #include "videowidget.h" |
27 | #include "mediaplayerplugininterface.h" | ||
28 | #include "mediaplayerstate.h" | 28 | #include "mediaplayerstate.h" |
29 | 29 | ||
30 | 30 | ||
@@ -66,7 +66,7 @@ static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | |||
66 | 66 | ||
67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
68 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 68 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
69 | setCaption( tr("MediaPlayer") ); | 69 | setCaption( tr("OpiePlayer") ); |
70 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 70 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
71 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) ); | 71 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) ); |
72 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) ); | 72 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) ); |
@@ -80,8 +80,8 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | |||
80 | slider->setFocusPolicy( QWidget::NoFocus ); | 80 | slider->setFocusPolicy( QWidget::NoFocus ); |
81 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 81 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
82 | 82 | ||
83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
85 | 85 | ||
86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
@@ -101,7 +101,7 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | |||
101 | 101 | ||
102 | VideoWidget::~VideoWidget() { | 102 | VideoWidget::~VideoWidget() { |
103 | for ( int i = 0; i < 3; i++ ) | 103 | for ( int i = 0; i < 3; i++ ) |
104 | delete pixmaps[i]; | 104 | delete pixmaps[i]; |
105 | delete currentFrame; | 105 | delete currentFrame; |
106 | } | 106 | } |
107 | 107 | ||
@@ -117,7 +117,7 @@ void VideoWidget::sliderPressed() { | |||
117 | void VideoWidget::sliderReleased() { | 117 | void VideoWidget::sliderReleased() { |
118 | videoSliderBeingMoved = FALSE; | 118 | videoSliderBeingMoved = FALSE; |
119 | if ( slider->width() == 0 ) | 119 | if ( slider->width() == 0 ) |
120 | return; | 120 | return; |
121 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 121 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
122 | mediaPlayerState->setPosition( val ); | 122 | mediaPlayerState->setPosition( val ); |
123 | } | 123 | } |
@@ -135,12 +135,12 @@ void VideoWidget::setLength( long max ) { | |||
135 | 135 | ||
136 | void VideoWidget::setView( char view ) { | 136 | void VideoWidget::setView( char view ) { |
137 | if ( view == 'v' ) { | 137 | if ( view == 'v' ) { |
138 | makeVisible(); | 138 | makeVisible(); |
139 | } else { | 139 | } else { |
140 | // Effectively blank the view next time we show it so it looks nicer | 140 | // Effectively blank the view next time we show it so it looks nicer |
141 | scaledWidth = 0; | 141 | scaledWidth = 0; |
142 | scaledHeight = 0; | 142 | scaledHeight = 0; |
143 | hide(); | 143 | hide(); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
@@ -148,21 +148,21 @@ void VideoWidget::setView( char view ) { | |||
148 | void VideoWidget::updateSlider( long i, long max ) { | 148 | void VideoWidget::updateSlider( long i, long max ) { |
149 | // Will flicker too much if we don't do this | 149 | // Will flicker too much if we don't do this |
150 | if ( max == 0 ) | 150 | if ( max == 0 ) |
151 | return; | 151 | return; |
152 | int width = slider->width(); | 152 | int width = slider->width(); |
153 | int val = int((double)i * width / max); | 153 | int val = int((double)i * width / max); |
154 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 154 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
155 | if ( slider->value() != val ) | 155 | if ( slider->value() != val ) |
156 | slider->setValue( val ); | 156 | slider->setValue( val ); |
157 | if ( slider->maxValue() != width ) | 157 | if ( slider->maxValue() != width ) |
158 | slider->setMaxValue( width ); | 158 | slider->setMaxValue( width ); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | void VideoWidget::setToggleButton( int i, bool down ) { | 163 | void VideoWidget::setToggleButton( int i, bool down ) { |
164 | if ( down != videoButtons[i].isDown ) | 164 | if ( down != videoButtons[i].isDown ) |
165 | toggleButton( i ); | 165 | toggleButton( i ); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
@@ -184,36 +184,36 @@ void VideoWidget::paintButton( QPainter *p, int i ) { | |||
184 | 184 | ||
185 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 185 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
186 | for ( int i = 0; i < numButtons; i++ ) { | 186 | for ( int i = 0; i < numButtons; i++ ) { |
187 | int x = videoButtons[i].xPos; | 187 | int x = videoButtons[i].xPos; |
188 | int y = videoButtons[i].yPos; | 188 | int y = videoButtons[i].yPos; |
189 | if ( event->state() == QMouseEvent::LeftButton ) { | 189 | if ( event->state() == QMouseEvent::LeftButton ) { |
190 | // The test to see if the mouse click is inside the circular button or not | 190 | // The test to see if the mouse click is inside the circular button or not |
191 | // (compared with the radius squared to avoid a square-root of our distance) | 191 | // (compared with the radius squared to avoid a square-root of our distance) |
192 | int radius = 16; | 192 | int radius = 16; |
193 | QPoint center = QPoint( x + radius, y + radius ); | 193 | QPoint center = QPoint( x + radius, y + radius ); |
194 | QPoint dXY = center - event->pos(); | 194 | QPoint dXY = center - event->pos(); |
195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
196 | bool isOnButton = dist <= (radius * radius); | 196 | bool isOnButton = dist <= (radius * radius); |
197 | if ( isOnButton != videoButtons[i].isHeld ) { | 197 | if ( isOnButton != videoButtons[i].isHeld ) { |
198 | videoButtons[i].isHeld = isOnButton; | 198 | videoButtons[i].isHeld = isOnButton; |
199 | toggleButton(i); | 199 | toggleButton(i); |
200 | } | 200 | } |
201 | } else { | 201 | } else { |
202 | if ( videoButtons[i].isHeld ) { | 202 | if ( videoButtons[i].isHeld ) { |
203 | videoButtons[i].isHeld = FALSE; | 203 | videoButtons[i].isHeld = FALSE; |
204 | if ( !videoButtons[i].isToggle ) | 204 | if ( !videoButtons[i].isToggle ) |
205 | setToggleButton( i, FALSE ); | 205 | setToggleButton( i, FALSE ); |
206 | switch (i) { | 206 | switch (i) { |
207 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 207 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
208 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 208 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
209 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 209 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
210 | case VideoNext: mediaPlayerState->setNext(); return; | 210 | case VideoNext: mediaPlayerState->setNext(); return; |
211 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 211 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
212 | case VideoPlayList: mediaPlayerState->setList(); return; | 212 | case VideoPlayList: mediaPlayerState->setList(); return; |
213 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 213 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
@@ -225,25 +225,25 @@ void VideoWidget::mousePressEvent( QMouseEvent *event ) { | |||
225 | 225 | ||
226 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 226 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
227 | if ( mediaPlayerState->fullscreen() ) { | 227 | if ( mediaPlayerState->fullscreen() ) { |
228 | mediaPlayerState->setFullscreen( FALSE ); | 228 | mediaPlayerState->setFullscreen( FALSE ); |
229 | makeVisible(); | 229 | makeVisible(); |
230 | } else { | 230 | } else { |
231 | mouseMoveEvent( event ); | 231 | mouseMoveEvent( event ); |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | void VideoWidget::makeVisible() { | 236 | void VideoWidget::makeVisible() { |
237 | if ( mediaPlayerState->fullscreen() ) { | 237 | if ( mediaPlayerState->fullscreen() ) { |
238 | setBackgroundMode( QWidget::NoBackground ); | 238 | setBackgroundMode( QWidget::NoBackground ); |
239 | showFullScreen(); | 239 | showFullScreen(); |
240 | resize( qApp->desktop()->size() ); | 240 | resize( qApp->desktop()->size() ); |
241 | slider->hide(); | 241 | slider->hide(); |
242 | } else { | 242 | } else { |
243 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 243 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
244 | showNormal(); | 244 | showNormal(); |
245 | showMaximized(); | 245 | showMaximized(); |
246 | slider->show(); | 246 | slider->show(); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
@@ -252,29 +252,29 @@ void VideoWidget::paintEvent( QPaintEvent * ) { | |||
252 | QPainter p( this ); | 252 | QPainter p( this ); |
253 | 253 | ||
254 | if ( mediaPlayerState->fullscreen() ) { | 254 | if ( mediaPlayerState->fullscreen() ) { |
255 | // Clear the background | 255 | // Clear the background |
256 | p.setBrush( QBrush( Qt::black ) ); | 256 | p.setBrush( QBrush( Qt::black ) ); |
257 | p.drawRect( rect() ); | 257 | p.drawRect( rect() ); |
258 | 258 | ||
259 | // Draw the current frame | 259 | // Draw the current frame |
260 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen | 260 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen |
261 | } else { | 261 | } else { |
262 | // draw border | 262 | // draw border |
263 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); | 263 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); |
264 | 264 | ||
265 | // Clear the movie screen first | 265 | // Clear the movie screen first |
266 | p.setBrush( QBrush( Qt::black ) ); | 266 | p.setBrush( QBrush( Qt::black ) ); |
267 | p.drawRect( 9, 20, 220, 160 ); | 267 | p.drawRect( 9, 20, 220, 160 ); |
268 | 268 | ||
269 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) | 269 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) |
270 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 270 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
271 | 271 | ||
272 | // draw the buttons | 272 | // draw the buttons |
273 | for ( int i = 0; i < numButtons; i++ ) | 273 | for ( int i = 0; i < numButtons; i++ ) |
274 | paintButton( &p, i ); | 274 | paintButton( &p, i ); |
275 | 275 | ||
276 | // draw the slider | 276 | // draw the slider |
277 | slider->repaint( TRUE ); | 277 | slider->repaint( TRUE ); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
@@ -299,121 +299,121 @@ bool VideoWidget::playVideo() { | |||
299 | 299 | ||
300 | if ( mediaPlayerState->fullscreen() ) { | 300 | if ( mediaPlayerState->fullscreen() ) { |
301 | #ifdef USE_DIRECT_PAINTER | 301 | #ifdef USE_DIRECT_PAINTER |
302 | QDirectPainter p(this); | 302 | QDirectPainter p(this); |
303 | 303 | ||
304 | if ( ( qt_screen->transformOrientation() == 3 ) && | 304 | if ( ( qt_screen->transformOrientation() == 3 ) && |
305 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { | 305 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { |
306 | 306 | ||
307 | w = 320; | 307 | w = 320; |
308 | h = 240; | 308 | h = 240; |
309 | 309 | ||
310 | if ( mediaPlayerState->scaled() ) { | 310 | if ( mediaPlayerState->scaled() ) { |
311 | // maintain aspect ratio | 311 | // maintain aspect ratio |
312 | if ( w * sh > sw * h ) | 312 | if ( w * sh > sw * h ) |
313 | w = sw * h / sh; | 313 | w = sw * h / sh; |
314 | else | 314 | else |
315 | h = sh * w / sw; | 315 | h = sh * w / sw; |
316 | } else { | 316 | } else { |
317 | w = sw; | 317 | w = sw; |
318 | h = sh; | 318 | h = sh; |
319 | } | 319 | } |
320 | 320 | ||
321 | w--; // we can't allow libmpeg to overwrite. | 321 | w--; // we can't allow libmpeg to overwrite. |
322 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); | 322 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); |
323 | 323 | ||
324 | int ox = roff.x() - height() + 2 + (height() - w) / 2; | 324 | int ox = roff.x() - height() + 2 + (height() - w) / 2; |
325 | int oy = roff.y() + (width() - h) / 2; | 325 | int oy = roff.y() + (width() - h) / 2; |
326 | int sx = 0, sy = 0; | 326 | int sx = 0, sy = 0; |
327 | 327 | ||
328 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; | 328 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; |
329 | fp += dd * ox / 8; | 329 | fp += dd * ox / 8; |
330 | uchar **jt = new uchar*[h]; | 330 | uchar **jt = new uchar*[h]; |
331 | for ( int i = h; i; i-- ) { | 331 | for ( int i = h; i; i-- ) { |
332 | jt[h - i] = fp; | 332 | jt[h - i] = fp; |
333 | fp += p.lineStep(); | 333 | fp += p.lineStep(); |
334 | } | 334 | } |
335 | 335 | ||
336 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; | 336 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; |
337 | 337 | ||
338 | delete [] jt; | 338 | delete [] jt; |
339 | } else { | 339 | } else { |
340 | #endif | 340 | #endif |
341 | QPainter p(this); | 341 | QPainter p(this); |
342 | 342 | ||
343 | w = 320; | 343 | w = 320; |
344 | h = 240; | 344 | h = 240; |
345 | 345 | ||
346 | if ( mediaPlayerState->scaled() ) { | 346 | if ( mediaPlayerState->scaled() ) { |
347 | // maintain aspect ratio | 347 | // maintain aspect ratio |
348 | if ( w * sh > sw * h ) | 348 | if ( w * sh > sw * h ) |
349 | w = sw * h / sh; | 349 | w = sw * h / sh; |
350 | else | 350 | else |
351 | h = sh * w / sw; | 351 | h = sh * w / sw; |
352 | } else { | 352 | } else { |
353 | w = sw; | 353 | w = sw; |
354 | h = sh; | 354 | h = sh; |
355 | } | 355 | } |
356 | 356 | ||
357 | int bytes = ( dd == 16 ) ? 2 : 4; | 357 | int bytes = ( dd == 16 ) ? 2 : 4; |
358 | QImage tempFrame( w, h, bytes << 3 ); | 358 | QImage tempFrame( w, h, bytes << 3 ); |
359 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), | 359 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), |
360 | 0, 0, sw, sh, w, h, format, 0) == 0; | 360 | 0, 0, sw, sh, w, h, format, 0) == 0; |
361 | if ( result && mediaPlayerState->fullscreen() ) { | 361 | if ( result && mediaPlayerState->fullscreen() ) { |
362 | 362 | ||
363 | int rw = h, rh = w; | 363 | int rw = h, rh = w; |
364 | QImage rotatedFrame( rw, rh, bytes << 3 ); | 364 | QImage rotatedFrame( rw, rh, bytes << 3 ); |
365 | 365 | ||
366 | ushort* in = (ushort*)tempFrame.bits(); | 366 | ushort* in = (ushort*)tempFrame.bits(); |
367 | ushort* out = (ushort*)rotatedFrame.bits(); | 367 | ushort* out = (ushort*)rotatedFrame.bits(); |
368 | int spl = rotatedFrame.bytesPerLine() / bytes; | 368 | int spl = rotatedFrame.bytesPerLine() / bytes; |
369 | for (int x=0; x<h; x++) { | 369 | for (int x=0; x<h; x++) { |
370 | if ( bytes == 2 ) { | 370 | if ( bytes == 2 ) { |
371 | ushort* lout = out++ + (w - 1)*spl; | 371 | ushort* lout = out++ + (w - 1)*spl; |
372 | for (int y=0; y<w; y++) { | 372 | for (int y=0; y<w; y++) { |
373 | *lout=*in++; | 373 | *lout=*in++; |
374 | lout-=spl; | 374 | lout-=spl; |
375 | } | 375 | } |
376 | } else { | 376 | } else { |
377 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; | 377 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; |
378 | for (int y=0; y<w; y++) { | 378 | for (int y=0; y<w; y++) { |
379 | *lout=*((ulong*)in)++; | 379 | *lout=*((ulong*)in)++; |
380 | lout-=spl; | 380 | lout-=spl; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); | 385 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); |
386 | } | 386 | } |
387 | #ifdef USE_DIRECT_PAINTER | 387 | #ifdef USE_DIRECT_PAINTER |
388 | } | 388 | } |
389 | #endif | 389 | #endif |
390 | } else { | 390 | } else { |
391 | 391 | ||
392 | w = 220; | 392 | w = 220; |
393 | h = 160; | 393 | h = 160; |
394 | 394 | ||
395 | // maintain aspect ratio | 395 | // maintain aspect ratio |
396 | if ( w * sh > sw * h ) | 396 | if ( w * sh > sw * h ) |
397 | w = sw * h / sh; | 397 | w = sw * h / sh; |
398 | else | 398 | else |
399 | h = sh * w / sw; | 399 | h = sh * w / sw; |
400 | 400 | ||
401 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; | 401 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; |
402 | 402 | ||
403 | QPainter p( this ); | 403 | QPainter p( this ); |
404 | 404 | ||
405 | // Image changed size, therefore need to blank the possibly unpainted regions first | 405 | // Image changed size, therefore need to blank the possibly unpainted regions first |
406 | if ( scaledWidth != w || scaledHeight != h ) { | 406 | if ( scaledWidth != w || scaledHeight != h ) { |
407 | p.setBrush( QBrush( Qt::black ) ); | 407 | p.setBrush( QBrush( Qt::black ) ); |
408 | p.drawRect( 9, 20, 220, 160 ); | 408 | p.drawRect( 9, 20, 220, 160 ); |
409 | } | 409 | } |
410 | 410 | ||
411 | scaledWidth = w; | 411 | scaledWidth = w; |
412 | scaledHeight = h; | 412 | scaledHeight = h; |
413 | 413 | ||
414 | if ( result ) { | 414 | if ( result ) { |
415 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 415 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
416 | } | 416 | } |
417 | 417 | ||
418 | } | 418 | } |
419 | 419 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/Makefile.in b/core/multimedia/opieplayer/wavplugin/Makefile.in index bcbe7f2..a46b925 100644 --- a/core/multimedia/opieplayer/wavplugin/Makefile.in +++ b/core/multimedia/opieplayer/wavplugin/Makefile.in | |||
@@ -100,10 +100,12 @@ REQUIRES= | |||
100 | ####### Compile | 100 | ####### Compile |
101 | 101 | ||
102 | wavplugin.o: wavplugin.cpp \ | 102 | wavplugin.o: wavplugin.cpp \ |
103 | wavplugin.h | 103 | wavplugin.h \ |
104 | ../mediaplayerplugininterface.h | ||
104 | 105 | ||
105 | wavpluginimpl.o: wavpluginimpl.cpp \ | 106 | wavpluginimpl.o: wavpluginimpl.cpp \ |
106 | wavplugin.h \ | 107 | wavplugin.h \ |
108 | ../mediaplayerplugininterface.h \ | ||
107 | wavpluginimpl.h | 109 | wavpluginimpl.h |
108 | 110 | ||
109 | 111 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp index a6bd974..7f63b3b 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp | |||
@@ -17,6 +17,8 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
20 | #include <stdio.h> | 22 | #include <stdio.h> |
21 | #include <stdarg.h> | 23 | #include <stdarg.h> |
22 | #include <stdlib.h> | 24 | #include <stdlib.h> |
@@ -26,7 +28,7 @@ | |||
26 | #include "wavplugin.h" | 28 | #include "wavplugin.h" |
27 | 29 | ||
28 | 30 | ||
29 | //#define debugMsg(a) qDebug(a) | 31 | //#define debugMsg(a) qDebug(a) |
30 | #define debugMsg(a) | 32 | #define debugMsg(a) |
31 | 33 | ||
32 | 34 | ||
@@ -47,7 +49,7 @@ struct ChunkData { | |||
47 | }; | 49 | }; |
48 | 50 | ||
49 | 51 | ||
50 | const int sound_buffer_size = 4096; | 52 | const int sound_buffer_size = 512; // 4096; // you got to be kidding right? |
51 | 53 | ||
52 | 54 | ||
53 | class WavPluginData { | 55 | class WavPluginData { |
@@ -63,130 +65,130 @@ public: | |||
63 | int samples; | 65 | int samples; |
64 | 66 | ||
65 | WavPluginData() { | 67 | WavPluginData() { |
66 | max = out = sound_buffer_size; | 68 | max = out = sound_buffer_size; |
67 | wavedata_remaining = 0; | 69 | wavedata_remaining = 0; |
68 | samples_due = 0; | 70 | samples_due = 0; |
69 | samples = -1; | 71 | samples = -1; |
70 | } | 72 | } |
71 | 73 | ||
72 | // expands out samples to the frequency of 44kHz | 74 | // expands out samples to the frequency of 44kHz |
73 | bool add( short *output, long count, long& done, bool stereo ) | 75 | bool add( short *output, long count, long& done, bool stereo ) |
74 | { | 76 | { |
75 | done = 0; | 77 | done = 0; |
78 | qApp->processEvents(); | ||
76 | 79 | ||
77 | if ( input == 0 ) { | 80 | if ( input == 0 ) { |
78 | qDebug("no input"); | 81 | qDebug("no input"); |
79 | return FALSE; | 82 | return FALSE; |
80 | } | 83 | } |
81 | 84 | ||
82 | while ( count ) { | 85 | while ( count ) { |
83 | int l,r; | 86 | int l,r; |
84 | if ( getSample(l, r) == FALSE ) { | 87 | if ( getSample(l, r) == FALSE ) { |
85 | qDebug("didn't get sample"); | 88 | qDebug("didn't get sample"); |
86 | return FALSE; | 89 | return FALSE; |
87 | } | 90 | } |
88 | samples_due += 44100; | 91 | samples_due += chunkdata.samplesPerSec; |
89 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { | 92 | while ( count && (samples_due > chunkdata.samplesPerSec) ) { |
90 | *output++ = l; | 93 | *output++ = l; |
91 | if ( stereo ) | 94 | if ( stereo ) |
92 | *output++ = r; | 95 | *output++ = r; |
93 | samples_due -= chunkdata.samplesPerSec; | 96 | samples_due -= chunkdata.samplesPerSec; |
94 | count--; | 97 | count--; |
95 | done++; | 98 | done++; |
96 | } | 99 | } |
97 | } | 100 | } |
98 | |||
99 | return TRUE; | 101 | return TRUE; |
100 | } | 102 | } |
101 | 103 | ||
102 | bool initialise() { | 104 | bool initialise() { |
103 | if ( input == 0 ) | 105 | if ( input == 0 ) |
104 | return FALSE; | 106 | return FALSE; |
105 | 107 | ||
106 | wavedata_remaining = -1; | 108 | wavedata_remaining = -1; |
107 | 109 | ||
108 | while ( wavedata_remaining == -1 ) { | 110 | while ( wavedata_remaining == -1 ) { |
109 | // Keep reading chunks... | 111 | // Keep reading chunks... |
110 | const int n = sizeof(chunk) - sizeof(chunk.data); | 112 | const int n = sizeof(chunk) - sizeof(chunk.data); |
111 | int t = input->readBlock( (char*)&chunk, n ); | 113 | int t = input->readBlock( (char*)&chunk, n ); |
112 | if ( t != n ) { | 114 | if ( t != n ) { |
113 | if ( t == -1 ) | 115 | if ( t == -1 ) |
114 | return FALSE; | 116 | return FALSE; |
115 | return TRUE; | 117 | return TRUE; |
116 | } | 118 | } |
117 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { | 119 | if ( qstrncmp(chunk.id,"data",4) == 0 ) { |
118 | samples = wavedata_remaining = chunk.size; | 120 | samples = wavedata_remaining = chunk.size; |
119 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { | 121 | } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) { |
120 | char d[4]; | 122 | char d[4]; |
121 | if ( input->readBlock(d,4) != 4 ) { | 123 | if ( input->readBlock(d,4) != 4 ) { |
122 | return FALSE; | 124 | return FALSE; |
123 | } | 125 | } |
124 | if ( qstrncmp(d,"WAVE",4) != 0 ) { | 126 | if ( qstrncmp(d,"WAVE",4) != 0 ) { |
125 | // skip | 127 | // skip |
126 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { | 128 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size-4) ) { |
127 | return FALSE; | 129 | return FALSE; |
128 | } | 130 | } |
129 | } | 131 | } |
130 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { | 132 | } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) { |
131 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { | 133 | if ( input->readBlock((char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) { |
132 | return FALSE; | 134 | return FALSE; |
133 | } | 135 | } |
134 | #define WAVE_FORMAT_PCM 1 | 136 | #define WAVE_FORMAT_PCM 1 |
135 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { | 137 | if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) { |
136 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); | 138 | qDebug("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag); |
137 | return FALSE; | 139 | return FALSE; |
138 | } | 140 | } |
139 | } else { | 141 | } else { |
140 | // ignored chunk | 142 | // ignored chunk |
141 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { | 143 | if ( chunk.size > 1000000000 || !input->at(input->at()+chunk.size) ) { |
142 | return FALSE; | 144 | return FALSE; |
143 | } | 145 | } |
144 | } | 146 | } |
145 | } // while | 147 | } // while |
146 | 148 | qDebug("bits %d", chunkdata.wBitsPerSample); | |
147 | return TRUE; | 149 | return TRUE; |
148 | } | 150 | } |
149 | 151 | ||
150 | 152 | ||
151 | // gets a sample from the file | 153 | // gets a sample from the file |
152 | bool getSample(int& l, int& r) | 154 | bool getSample(int& l, int& r) |
153 | { | 155 | { |
154 | l = r = 0; | 156 | l = r = 0; |
155 | 157 | ||
156 | if ( input == 0 ) | 158 | if ( input == 0 ) |
157 | return FALSE; | 159 | return FALSE; |
158 | 160 | ||
159 | if ( (wavedata_remaining < 0) || !max ) | 161 | if ( (wavedata_remaining < 0) || !max ) |
160 | return FALSE; | 162 | return FALSE; |
161 | 163 | ||
162 | if ( out >= max ) { | 164 | if ( out >= max ) { |
163 | max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) ); | 165 | max = input->readBlock( (char*)data, (uint)QMIN(sound_buffer_size,wavedata_remaining) ); |
164 | 166 | ||
165 | wavedata_remaining -= max; | 167 | wavedata_remaining -= max; |
166 | 168 | ||
167 | out = 0; | 169 | out = 0; |
168 | if ( max <= 0 ) { | 170 | if ( max <= 0 ) { |
169 | max = 0; | 171 | max = 0; |
170 | return TRUE; | 172 | return TRUE; |
171 | } | 173 | } |
172 | } | 174 | } |
173 | if ( chunkdata.wBitsPerSample == 8 ) { | 175 | if ( chunkdata.wBitsPerSample == 8 ) { |
174 | l = (data[out++] - 128) * 128; | 176 | l = (data[out++] - 128) * 128; |
175 | } else { | 177 | } else { |
176 | l = ((short*)data)[out/2]; | 178 | l = ((short*)data)[out/2]; |
177 | out += 2; | 179 | out += 2; |
178 | } | 180 | } |
179 | if ( chunkdata.channels == 1 ) { | 181 | if ( chunkdata.channels == 1 ) { |
180 | r = l; | 182 | r = l; |
181 | } else { | 183 | } else { |
182 | if ( chunkdata.wBitsPerSample == 8 ) { | 184 | if ( chunkdata.wBitsPerSample == 8 ) { |
183 | r = (data[out++] - 128) * 128; | 185 | r = (data[out++] - 128) * 128; |
184 | } else { | 186 | } else { |
185 | r = ((short*)data)[out/2]; | 187 | r = ((short*)data)[out/2]; |
186 | out += 2; | 188 | out += 2; |
187 | } | 189 | } |
188 | } | 190 | } |
189 | return TRUE; | 191 | return TRUE; |
190 | } // getSample | 192 | } // getSample |
191 | 193 | ||
192 | }; | 194 | }; |
@@ -205,18 +207,18 @@ WavPlugin::~WavPlugin() { | |||
205 | 207 | ||
206 | 208 | ||
207 | bool WavPlugin::isFileSupported( const QString& path ) { | 209 | bool WavPlugin::isFileSupported( const QString& path ) { |
208 | debugMsg( "WavPlugin::isFileSupported" ); | 210 | // qDebug( "WavPlugin::isFileSupported" ); |
209 | 211 | ||
210 | char *ext = strrchr( path.latin1(), '.' ); | 212 | char *ext = strrchr( path.latin1(), '.' ); |
211 | 213 | ||
212 | // Test file extension | 214 | // Test file extension |
213 | if ( ext ) { | 215 | if ( ext ) { |
214 | if ( strncasecmp(ext, ".raw", 4) == 0 ) | 216 | if ( strncasecmp(ext, ".raw", 4) == 0 ) |
215 | return TRUE; | 217 | return TRUE; |
216 | if ( strncasecmp(ext, ".wav", 4) == 0 ) | 218 | if ( strncasecmp(ext, ".wav", 4) == 0 ) |
217 | return TRUE; | 219 | return TRUE; |
218 | if ( strncasecmp(ext, ".wave", 4) == 0 ) | 220 | if ( strncasecmp(ext, ".wave", 4) == 0 ) |
219 | return TRUE; | 221 | return TRUE; |
220 | } | 222 | } |
221 | 223 | ||
222 | return FALSE; | 224 | return FALSE; |
@@ -224,7 +226,7 @@ bool WavPlugin::isFileSupported( const QString& path ) { | |||
224 | 226 | ||
225 | 227 | ||
226 | bool WavPlugin::open( const QString& path ) { | 228 | bool WavPlugin::open( const QString& path ) { |
227 | debugMsg( "WavPlugin::open" ); | 229 | // qDebug( "WavPlugin::open" ); |
228 | 230 | ||
229 | d->max = d->out = sound_buffer_size; | 231 | d->max = d->out = sound_buffer_size; |
230 | d->wavedata_remaining = 0; | 232 | d->wavedata_remaining = 0; |
@@ -232,10 +234,10 @@ bool WavPlugin::open( const QString& path ) { | |||
232 | 234 | ||
233 | d->input = new QFile( path ); | 235 | d->input = new QFile( path ); |
234 | if ( d->input->open(IO_ReadOnly) == FALSE ) { | 236 | if ( d->input->open(IO_ReadOnly) == FALSE ) { |
235 | qDebug("couldn't open file"); | 237 | qDebug("couldn't open file"); |
236 | delete d->input; | 238 | delete d->input; |
237 | d->input = 0; | 239 | d->input = 0; |
238 | return FALSE; | 240 | return FALSE; |
239 | } | 241 | } |
240 | 242 | ||
241 | d->initialise(); | 243 | d->initialise(); |
@@ -245,7 +247,7 @@ bool WavPlugin::open( const QString& path ) { | |||
245 | 247 | ||
246 | 248 | ||
247 | bool WavPlugin::close() { | 249 | bool WavPlugin::close() { |
248 | debugMsg( "WavPlugin::close" ); | 250 | // qDebug( "WavPlugin::close" ); |
249 | 251 | ||
250 | d->input->close(); | 252 | d->input->close(); |
251 | delete d->input; | 253 | delete d->input; |
@@ -255,44 +257,44 @@ bool WavPlugin::close() { | |||
255 | 257 | ||
256 | 258 | ||
257 | bool WavPlugin::isOpen() { | 259 | bool WavPlugin::isOpen() { |
258 | debugMsg( "WavPlugin::isOpen" ); | 260 | // qDebug( "WavPlugin::isOpen" ); |
259 | return ( d->input != 0 ); | 261 | return ( d->input != 0 ); |
260 | } | 262 | } |
261 | 263 | ||
262 | 264 | ||
263 | int WavPlugin::audioStreams() { | 265 | int WavPlugin::audioStreams() { |
264 | debugMsg( "WavPlugin::audioStreams" ); | 266 | // qDebug( "WavPlugin::audioStreams" ); |
265 | return 1; | 267 | return 1; |
266 | } | 268 | } |
267 | 269 | ||
268 | 270 | ||
269 | int WavPlugin::audioChannels( int ) { | 271 | int WavPlugin::audioChannels( int ) { |
270 | debugMsg( "WavPlugin::audioChannels" ); | 272 | // qDebug( "WavPlugin::audioChannels" ); |
271 | return 2; // ### Always scale audio to stereo samples | 273 | return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples |
272 | } | 274 | } |
273 | 275 | ||
274 | 276 | ||
275 | int WavPlugin::audioFrequency( int ) { | 277 | int WavPlugin::audioFrequency( int ) { |
276 | debugMsg( "WavPlugin::audioFrequency" ); | 278 | // qDebug( "WavPlugin::audioFrequency %d", d->chunkdata.samplesPerSec ); |
277 | return 44100; // ### Always scale to frequency of 44100 | 279 | return d->chunkdata.samplesPerSec; //44100; // ### Always scale to frequency of 44100 |
278 | } | 280 | } |
279 | 281 | ||
280 | 282 | ||
281 | int WavPlugin::audioSamples( int ) { | 283 | int WavPlugin::audioSamples( int ) { |
282 | debugMsg( "WavPlugin::audioSamples" ); | 284 | // qDebug( "WavPlugin::audioSamples" ); |
283 | return d->samples * 2 / d->chunkdata.channels; // ### Scaled samples will be made stereo, | 285 | return d->samples / d->chunkdata.channels/2; // ### Scaled samples will be made stereo, |
284 | // Therefore if source is mono we will double the number of samples | 286 | // Therefore if source is mono we will double the number of samples |
285 | } | 287 | } |
286 | 288 | ||
287 | 289 | ||
288 | bool WavPlugin::audioSetSample( long, int ) { | 290 | bool WavPlugin::audioSetSample( long, int ) { |
289 | debugMsg( "WavPlugin::audioSetSample" ); | 291 | // qDebug( "WavPlugin::audioSetSample" ); |
290 | return FALSE; | 292 | return FALSE; |
291 | } | 293 | } |
292 | 294 | ||
293 | 295 | ||
294 | long WavPlugin::audioGetSample( int ) { | 296 | long WavPlugin::audioGetSample( int ) { |
295 | debugMsg( "WavPlugin::audioGetSample" ); | 297 | // qDebug( "WavPlugin::audioGetSample" ); |
296 | return 0; | 298 | return 0; |
297 | } | 299 | } |
298 | 300 | ||
@@ -322,13 +324,18 @@ bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& sampl | |||
322 | */ | 324 | */ |
323 | 325 | ||
324 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { | 326 | bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { |
325 | debugMsg( "WavPlugin::audioReadSamples" ); | 327 | // qDebug( "WavPlugin::audioReadSamples" ); |
326 | return d->add( output, samples, samplesMade, channels != 1 ); | 328 | return d->add( output, samples, samplesMade, channels != 1 ); |
327 | } | 329 | } |
328 | 330 | ||
329 | double WavPlugin::getTime() { | 331 | double WavPlugin::getTime() { |
330 | debugMsg( "WavPlugin::getTime" ); | 332 | // qDebug( "WavPlugin::getTime" ); |
331 | return 0.0; | 333 | return 0.0; |
332 | } | 334 | } |
333 | 335 | ||
336 | int WavPlugin::audioBitsPerSample( int ) { | ||
337 | // qDebug( "WavPlugin::audioFormat %d", d->chunkdata.wBitsPerSample ); | ||
338 | return d->chunkdata.wBitsPerSample; // | ||
339 | } | ||
340 | |||
334 | 341 | ||
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.h b/core/multimedia/opieplayer/wavplugin/wavplugin.h index 64635ca..6afd67e 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.h +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.h | |||
@@ -17,13 +17,18 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // L.J.Potter added changes Fri 02-15-2002 | ||
21 | |||
20 | #ifndef WAV_PLUGIN_H | 22 | #ifndef WAV_PLUGIN_H |
21 | #define WAV_PLUGIN_H | 23 | #define WAV_PLUGIN_H |
22 | 24 | ||
23 | 25 | ||
24 | #include <qstring.h> | 26 | #include <qstring.h> |
25 | #include <qapplication.h> | 27 | #include <qapplication.h> |
26 | #include "mediaplayerplugininterface.h" | 28 | #include "../mediaplayerplugininterface.h" |
29 | |||
30 | |||
31 | // #define OLD_MEDIAPLAYER_API | ||
27 | 32 | ||
28 | 33 | ||
29 | class WavPluginData; | 34 | class WavPluginData; |
@@ -43,21 +48,24 @@ public: | |||
43 | bool open( const QString& ); | 48 | bool open( const QString& ); |
44 | bool close(); | 49 | bool close(); |
45 | bool isOpen(); | 50 | bool isOpen(); |
46 | //const QString &fileInfo() { return strInfo = qApp->translate( "MediaPlayer", "No Information Available", "media plugin text" ); } | 51 | const QString &fileInfo() { return strInfo = ""; } |
47 | const QString &fileInfo() { return strInfo = QString(""); } | ||
48 | 52 | ||
49 | // If decoder doesn't support audio then return 0 here | 53 | // If decoder doesn't support audio then return 0 here |
50 | int audioStreams(); | 54 | int audioStreams(); |
51 | int audioChannels( int stream ); | 55 | int audioChannels( int stream ); |
52 | int audioFrequency( int stream ); | 56 | int audioFrequency( int stream ); |
57 | int audioBitsPerSample( int stream ); | ||
53 | int audioSamples( int stream ); | 58 | int audioSamples( int stream ); |
54 | bool audioSetSample( long sample, int stream ); | 59 | bool audioSetSample( long sample, int stream ); |
55 | long audioGetSample( int stream ); | 60 | long audioGetSample( int stream ); |
56 | //bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); | 61 | #ifdef OLD_MEDIAPLAYER_API |
57 | //bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | 62 | bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ); |
63 | bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ); | ||
64 | bool audioReadSamples( short *output, int channel, long samples, int stream ); | ||
65 | bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
66 | #else | ||
58 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); | 67 | bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ); |
59 | //bool audioReadSamples( short *output, int channel, long samples, int stream ); | 68 | #endif |
60 | //bool audioReReadSamples( short *output, int channel, long samples, int stream ); | ||
61 | 69 | ||
62 | // If decoder doesn't support video then return 0 here | 70 | // If decoder doesn't support video then return 0 here |
63 | int videoStreams() { return 0; } | 71 | int videoStreams() { return 0; } |
@@ -87,6 +95,8 @@ public: | |||
87 | bool supportsStereo() { return TRUE; } | 95 | bool supportsStereo() { return TRUE; } |
88 | bool supportsScaling() { return FALSE; } | 96 | bool supportsScaling() { return FALSE; } |
89 | 97 | ||
98 | long getPlayTime() { return -1; } | ||
99 | |||
90 | private: | 100 | private: |
91 | WavPluginData *d; | 101 | WavPluginData *d; |
92 | QString strInfo; | 102 | QString strInfo; |