author | simon <simon> | 2002-12-09 00:04:09 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 00:04:09 (UTC) |
commit | 88882051547c9c62f47fb83d87f1341ebccf99a7 (patch) (unidiff) | |
tree | 7c5dec3d715b37c5c80fa9c017d55b57cf76cb7b | |
parent | 373051a9f8e624e57bac83bb09af1840fef14b4c (diff) | |
download | opie-88882051547c9c62f47fb83d87f1341ebccf99a7.zip opie-88882051547c9c62f47fb83d87f1341ebccf99a7.tar.gz opie-88882051547c9c62f47fb83d87f1341ebccf99a7.tar.bz2 |
- use xine_set_param( ..., XINE_PARAM_SPEED, with XINE_SPEED_PAUSE and
XINE_SPEED_NORMAL to toggle between pause and playing state, instead of
attempting to re-start the stream at the last position
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 6 |
3 files changed, 4 insertions, 8 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 1b5fd51..9e818eb 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -1,300 +1,300 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 LJP <> | 5 | Copyright (c) 2002 LJP <> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <stdio.h> | 34 | #include <stdio.h> |
35 | #include <stdlib.h> | 35 | #include <stdlib.h> |
36 | #include <qimage.h> | 36 | #include <qimage.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | 41 | ||
42 | #include <qgfx_qws.h> | 42 | #include <qgfx_qws.h> |
43 | #include <qdirectpainter_qws.h> | 43 | #include <qdirectpainter_qws.h> |
44 | 44 | ||
45 | #include <assert.h> | 45 | #include <assert.h> |
46 | 46 | ||
47 | #include "xinevideowidget.h" | 47 | #include "xinevideowidget.h" |
48 | #include "frame.h" | 48 | #include "frame.h" |
49 | #include "lib.h" | 49 | #include "lib.h" |
50 | 50 | ||
51 | 51 | ||
52 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, | 52 | typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, |
53 | int width, int height,int bytes ); | 53 | int width, int height,int bytes ); |
54 | 54 | ||
55 | extern "C" { | 55 | extern "C" { |
56 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); | 56 | xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); |
57 | int null_is_showing_video( const xine_vo_driver_t* self ); | 57 | int null_is_showing_video( const xine_vo_driver_t* self ); |
58 | void null_set_show_video( const xine_vo_driver_t* self, int show ); | 58 | void null_set_show_video( const xine_vo_driver_t* self, int show ); |
59 | int null_is_fullscreen( const xine_vo_driver_t* self ); | 59 | int null_is_fullscreen( const xine_vo_driver_t* self ); |
60 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); | 60 | void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); |
61 | int null_is_scaling( const xine_vo_driver_t* self ); | 61 | int null_is_scaling( const xine_vo_driver_t* self ); |
62 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); | 62 | void null_set_scaling( const xine_vo_driver_t* self, int scale ); |
63 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); | 63 | void null_set_gui_width( const xine_vo_driver_t* self, int width ); |
64 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); | 64 | void null_set_gui_height( const xine_vo_driver_t* self, int height ); |
65 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); | 65 | void null_set_mode( const xine_vo_driver_t* self, int depth, int rgb ); |
66 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); | 66 | void null_set_videoGamma( const xine_vo_driver_t* self , int value ); |
67 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); | 67 | void null_display_handler( const xine_vo_driver_t* self, display_xine_frame_t t, void* user_data ); |
68 | } | 68 | } |
69 | 69 | ||
70 | using namespace XINE; | 70 | using namespace XINE; |
71 | 71 | ||
72 | Lib::Lib( XineVideoWidget* widget ) { | 72 | Lib::Lib( XineVideoWidget* widget ) { |
73 | m_video = false; | 73 | m_video = false; |
74 | m_wid = widget; | 74 | m_wid = widget; |
75 | printf("Lib"); | 75 | printf("Lib"); |
76 | QCString str( getenv("HOME") ); | 76 | QCString str( getenv("HOME") ); |
77 | str += "/Settings/opiexine.cf"; | 77 | str += "/Settings/opiexine.cf"; |
78 | // get the configuration | 78 | // get the configuration |
79 | 79 | ||
80 | // not really OO, should be an extra class, later | 80 | // not really OO, should be an extra class, later |
81 | if ( !QFile(str).exists() ) { | 81 | if ( !QFile(str).exists() ) { |
82 | QFile f(str); | 82 | QFile f(str); |
83 | f.open(IO_WriteOnly); | 83 | f.open(IO_WriteOnly); |
84 | QTextStream ts( &f ); | 84 | QTextStream ts( &f ); |
85 | ts << "misc.memcpy_method:glibc\n"; | 85 | ts << "misc.memcpy_method:glibc\n"; |
86 | f.close(); | 86 | f.close(); |
87 | } | 87 | } |
88 | 88 | ||
89 | m_xine = xine_new( ); | 89 | m_xine = xine_new( ); |
90 | 90 | ||
91 | xine_config_load( m_xine, str.data() ); | 91 | xine_config_load( m_xine, str.data() ); |
92 | 92 | ||
93 | xine_init( m_xine ); | 93 | xine_init( m_xine ); |
94 | 94 | ||
95 | // allocate oss for sound | 95 | // allocate oss for sound |
96 | // and fb for framebuffer | 96 | // and fb for framebuffer |
97 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); | 97 | m_audioOutput = xine_open_audio_driver( m_xine, "oss", NULL ); |
98 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); | 98 | m_videoOutput = ::init_video_out_plugin( m_xine, NULL, xine_display_frame, this ); |
99 | 99 | ||
100 | 100 | ||
101 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); | 101 | //xine_open_video_driver( m_xine, NULL, XINE_VISUAL_TYPE_FB, NULL); |
102 | 102 | ||
103 | 103 | ||
104 | // null_display_handler( m_videoOutput, xine_display_frame, this ); | 104 | // null_display_handler( m_videoOutput, xine_display_frame, this ); |
105 | 105 | ||
106 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); | 106 | m_stream = xine_stream_new (m_xine, m_audioOutput, m_videoOutput ); |
107 | 107 | ||
108 | if (m_wid != 0 ) { | 108 | if (m_wid != 0 ) { |
109 | printf( "!0\n" ); | 109 | printf( "!0\n" ); |
110 | resize ( m_wid-> size ( ) ); | 110 | resize ( m_wid-> size ( ) ); |
111 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 111 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
112 | 112 | ||
113 | m_wid->repaint(); | 113 | m_wid->repaint(); |
114 | } | 114 | } |
115 | 115 | ||
116 | m_queue = xine_event_new_queue (m_stream); | 116 | m_queue = xine_event_new_queue (m_stream); |
117 | 117 | ||
118 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); | 118 | xine_event_create_listener_thread (m_queue, xine_event_handler, this); |
119 | } | 119 | } |
120 | 120 | ||
121 | Lib::~Lib() { | 121 | Lib::~Lib() { |
122 | // free( m_config ); | 122 | // free( m_config ); |
123 | 123 | ||
124 | xine_close( m_stream ); | 124 | xine_close( m_stream ); |
125 | 125 | ||
126 | xine_event_dispose_queue( m_queue ); | 126 | xine_event_dispose_queue( m_queue ); |
127 | 127 | ||
128 | xine_dispose( m_stream ); | 128 | xine_dispose( m_stream ); |
129 | 129 | ||
130 | xine_exit( m_xine ); | 130 | xine_exit( m_xine ); |
131 | /* FIXME either free or delete but valgrind bitches against both */ | 131 | /* FIXME either free or delete but valgrind bitches against both */ |
132 | //free( m_videoOutput ); | 132 | //free( m_videoOutput ); |
133 | //delete m_audioOutput; | 133 | //delete m_audioOutput; |
134 | } | 134 | } |
135 | 135 | ||
136 | void Lib::resize ( const QSize &s ) { | 136 | void Lib::resize ( const QSize &s ) { |
137 | if ( s. width ( ) && s. height ( ) ) { | 137 | if ( s. width ( ) && s. height ( ) ) { |
138 | ::null_set_gui_width( m_videoOutput, s. width() ); | 138 | ::null_set_gui_width( m_videoOutput, s. width() ); |
139 | ::null_set_gui_height( m_videoOutput, s. height() ); | 139 | ::null_set_gui_height( m_videoOutput, s. height() ); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
143 | int Lib::majorVersion() { | 143 | int Lib::majorVersion() { |
144 | int major, minor, sub; | 144 | int major, minor, sub; |
145 | xine_get_version ( &major, &minor, &sub ); | 145 | xine_get_version ( &major, &minor, &sub ); |
146 | return major; | 146 | return major; |
147 | } | 147 | } |
148 | 148 | ||
149 | int Lib::minorVersion() { | 149 | int Lib::minorVersion() { |
150 | int major, minor, sub; | 150 | int major, minor, sub; |
151 | xine_get_version ( &major, &minor, &sub ); | 151 | xine_get_version ( &major, &minor, &sub ); |
152 | return minor; | 152 | return minor; |
153 | } | 153 | } |
154 | 154 | ||
155 | int Lib::subVersion() { | 155 | int Lib::subVersion() { |
156 | int major, minor, sub; | 156 | int major, minor, sub; |
157 | xine_get_version ( &major, &minor, &sub ); | 157 | xine_get_version ( &major, &minor, &sub ); |
158 | return sub; | 158 | return sub; |
159 | } | 159 | } |
160 | 160 | ||
161 | int Lib::play( const QString& fileName, int startPos, int start_time ) { | 161 | int Lib::play( const QString& fileName, int startPos, int start_time ) { |
162 | QString str = fileName.stripWhiteSpace(); | 162 | QString str = fileName.stripWhiteSpace(); |
163 | if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { | 163 | if ( !xine_open( m_stream, QFile::encodeName(str.utf8() ).data() ) ) { |
164 | return 0; | 164 | return 0; |
165 | } | 165 | } |
166 | return xine_play( m_stream, startPos, start_time); | 166 | return xine_play( m_stream, startPos, start_time); |
167 | } | 167 | } |
168 | 168 | ||
169 | void Lib::stop() { | 169 | void Lib::stop() { |
170 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); | 170 | qDebug("<<<<<<<< STOP IN LIB TRIGGERED >>>>>>>"); |
171 | xine_stop( m_stream ); | 171 | xine_stop( m_stream ); |
172 | } | 172 | } |
173 | 173 | ||
174 | void Lib::pause() { | 174 | void Lib::pause( bool toggle ) { |
175 | xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); | 175 | xine_set_param( m_stream, XINE_PARAM_SPEED, toggle ? XINE_SPEED_PAUSE : XINE_SPEED_NORMAL ); |
176 | } | 176 | } |
177 | 177 | ||
178 | int Lib::speed() const { | 178 | int Lib::speed() const { |
179 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); | 179 | return xine_get_param ( m_stream, XINE_PARAM_SPEED ); |
180 | } | 180 | } |
181 | 181 | ||
182 | void Lib::setSpeed( int speed ) { | 182 | void Lib::setSpeed( int speed ) { |
183 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); | 183 | xine_set_param ( m_stream, XINE_PARAM_SPEED, speed ); |
184 | } | 184 | } |
185 | 185 | ||
186 | int Lib::status() const { | 186 | int Lib::status() const { |
187 | return xine_get_status( m_stream ); | 187 | return xine_get_status( m_stream ); |
188 | } | 188 | } |
189 | 189 | ||
190 | int Lib::currentPosition() const { | 190 | int Lib::currentPosition() const { |
191 | int pos, time, length; | 191 | int pos, time, length; |
192 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 192 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
193 | return pos; | 193 | return pos; |
194 | } | 194 | } |
195 | 195 | ||
196 | int Lib::currentTime() const { | 196 | int Lib::currentTime() const { |
197 | int pos, time, length; | 197 | int pos, time, length; |
198 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 198 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
199 | return time/1000; | 199 | return time/1000; |
200 | } | 200 | } |
201 | 201 | ||
202 | int Lib::length() const { | 202 | int Lib::length() const { |
203 | int pos, time, length; | 203 | int pos, time, length; |
204 | xine_get_pos_length( m_stream, &pos, &time, &length ); | 204 | xine_get_pos_length( m_stream, &pos, &time, &length ); |
205 | return length/1000; | 205 | return length/1000; |
206 | } | 206 | } |
207 | 207 | ||
208 | bool Lib::isSeekable() const { | 208 | bool Lib::isSeekable() const { |
209 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); | 209 | return xine_get_stream_info( m_stream, XINE_STREAM_INFO_SEEKABLE ); |
210 | } | 210 | } |
211 | 211 | ||
212 | void Lib::seekTo( int time ) { | 212 | void Lib::seekTo( int time ) { |
213 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( | 213 | //xine_trick_mode ( m_stream, XINE_TRICK_MODE_SEEK_TO_TIME, time ); NOT IMPLEMENTED YET IN XINE :_( |
214 | // since its now milliseconds we need *1000 | 214 | // since its now milliseconds we need *1000 |
215 | xine_play( m_stream, 0, time*1000 ); | 215 | xine_play( m_stream, 0, time*1000 ); |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | Frame Lib::currentFrame() const { | 219 | Frame Lib::currentFrame() const { |
220 | Frame frame; | 220 | Frame frame; |
221 | return frame; | 221 | return frame; |
222 | }; | 222 | }; |
223 | 223 | ||
224 | QString Lib::metaInfo( int number) const { | 224 | QString Lib::metaInfo( int number) const { |
225 | return xine_get_meta_info( m_stream, number ); | 225 | return xine_get_meta_info( m_stream, number ); |
226 | } | 226 | } |
227 | 227 | ||
228 | int Lib::error() const { | 228 | int Lib::error() const { |
229 | return xine_get_error( m_stream ); | 229 | return xine_get_error( m_stream ); |
230 | }; | 230 | }; |
231 | 231 | ||
232 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) | 232 | void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) |
233 | { | 233 | { |
234 | assert( sendType == ThreadUtil::Channel::OneWay ); | 234 | assert( sendType == ThreadUtil::Channel::OneWay ); |
235 | handleXineEvent( msg->type() ); | 235 | handleXineEvent( msg->type() ); |
236 | delete msg; | 236 | delete msg; |
237 | } | 237 | } |
238 | 238 | ||
239 | void Lib::handleXineEvent( const xine_event_t* t ) { | 239 | void Lib::handleXineEvent( const xine_event_t* t ) { |
240 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); | 240 | send( new ThreadUtil::ChannelMessage( t->type ), OneWay ); |
241 | } | 241 | } |
242 | 242 | ||
243 | void Lib::handleXineEvent( int type ) { | 243 | void Lib::handleXineEvent( int type ) { |
244 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { | 244 | if ( type == XINE_EVENT_UI_PLAYBACK_FINISHED ) { |
245 | emit stopped(); | 245 | emit stopped(); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | void Lib::setShowVideo( bool video ) { | 250 | void Lib::setShowVideo( bool video ) { |
251 | m_video = video; | 251 | m_video = video; |
252 | ::null_set_show_video( m_videoOutput, video ); | 252 | ::null_set_show_video( m_videoOutput, video ); |
253 | } | 253 | } |
254 | 254 | ||
255 | bool Lib::isShowingVideo() const { | 255 | bool Lib::isShowingVideo() const { |
256 | return ::null_is_showing_video( m_videoOutput ); | 256 | return ::null_is_showing_video( m_videoOutput ); |
257 | } | 257 | } |
258 | 258 | ||
259 | bool Lib::hasVideo() const { | 259 | bool Lib::hasVideo() const { |
260 | return xine_get_stream_info( m_stream, 18 ); | 260 | return xine_get_stream_info( m_stream, 18 ); |
261 | } | 261 | } |
262 | 262 | ||
263 | void Lib::showVideoFullScreen( bool fullScreen ) { | 263 | void Lib::showVideoFullScreen( bool fullScreen ) { |
264 | ::null_set_fullscreen( m_videoOutput, fullScreen ); | 264 | ::null_set_fullscreen( m_videoOutput, fullScreen ); |
265 | } | 265 | } |
266 | 266 | ||
267 | bool Lib::isVideoFullScreen() const { | 267 | bool Lib::isVideoFullScreen() const { |
268 | return ::null_is_fullscreen( m_videoOutput ); | 268 | return ::null_is_fullscreen( m_videoOutput ); |
269 | } | 269 | } |
270 | 270 | ||
271 | void Lib::setScaling( bool scale ) { | 271 | void Lib::setScaling( bool scale ) { |
272 | ::null_set_scaling( m_videoOutput, scale ); | 272 | ::null_set_scaling( m_videoOutput, scale ); |
273 | } | 273 | } |
274 | 274 | ||
275 | void Lib::setGamma( int value ) { | 275 | void Lib::setGamma( int value ) { |
276 | //qDebug( QString( "%1").arg(value) ); | 276 | //qDebug( QString( "%1").arg(value) ); |
277 | /* int gammaValue = ( 100 + value ); */ | 277 | /* int gammaValue = ( 100 + value ); */ |
278 | ::null_set_videoGamma( m_videoOutput, value ); | 278 | ::null_set_videoGamma( m_videoOutput, value ); |
279 | } | 279 | } |
280 | 280 | ||
281 | bool Lib::isScaling() const { | 281 | bool Lib::isScaling() const { |
282 | return ::null_is_scaling( m_videoOutput ); | 282 | return ::null_is_scaling( m_videoOutput ); |
283 | } | 283 | } |
284 | 284 | ||
285 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { | 285 | void Lib::xine_event_handler( void* user_data, const xine_event_t* t ) { |
286 | ( (Lib*)user_data)->handleXineEvent( t ); | 286 | ( (Lib*)user_data)->handleXineEvent( t ); |
287 | } | 287 | } |
288 | 288 | ||
289 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, | 289 | void Lib::xine_display_frame( void* user_data, uint8_t *frame, |
290 | int width, int height, int bytes ) { | 290 | int width, int height, int bytes ) { |
291 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); | 291 | ( (Lib*)user_data)->drawFrame( frame, width, height, bytes ); |
292 | } | 292 | } |
293 | 293 | ||
294 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | 294 | void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { |
295 | if ( !m_video ) { | 295 | if ( !m_video ) { |
296 | qWarning("not showing video now"); | 296 | qWarning("not showing video now"); |
297 | return; | 297 | return; |
298 | } | 298 | } |
299 | m_wid-> setVideoFrame ( frame, width, height, bytes ); | 299 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
300 | } | 300 | } |
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h index 3224cb9..37a4f9a 100644 --- a/noncore/multimedia/opieplayer2/lib.h +++ b/noncore/multimedia/opieplayer2/lib.h | |||
@@ -1,205 +1,205 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 LJP <> | 5 | Copyright (c) 2002 LJP <> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef ZECKEXINELIB_H | 34 | #ifndef ZECKEXINELIB_H |
35 | #define ZECKEXINELIB_H | 35 | #define ZECKEXINELIB_H |
36 | 36 | ||
37 | #include <qcstring.h> | 37 | #include <qcstring.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | 40 | ||
41 | #include <xine.h> | 41 | #include <xine.h> |
42 | //#include "xine.h" | 42 | //#include "xine.h" |
43 | 43 | ||
44 | #include "threadutil.h" | 44 | #include "threadutil.h" |
45 | 45 | ||
46 | class XineVideoWidget; | 46 | class XineVideoWidget; |
47 | 47 | ||
48 | namespace XINE { | 48 | namespace XINE { |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Lib wrapps the simple interface | 51 | * Lib wrapps the simple interface |
52 | * of libxine for easy every day use | 52 | * of libxine for easy every day use |
53 | * This will become a full C++ Wrapper | 53 | * This will become a full C++ Wrapper |
54 | * It supports playing, pausing, info, | 54 | * It supports playing, pausing, info, |
55 | * stooping, seeking. | 55 | * stooping, seeking. |
56 | */ | 56 | */ |
57 | class Frame; | 57 | class Frame; |
58 | class Lib : public ThreadUtil::Channel { | 58 | class Lib : public ThreadUtil::Channel { |
59 | Q_OBJECT | 59 | Q_OBJECT |
60 | public: | 60 | public: |
61 | Lib(XineVideoWidget* = 0); | 61 | Lib(XineVideoWidget* = 0); |
62 | ~Lib(); | 62 | ~Lib(); |
63 | static int majorVersion(); | 63 | static int majorVersion(); |
64 | static int minorVersion(); | 64 | static int minorVersion(); |
65 | static int subVersion(); | 65 | static int subVersion(); |
66 | 66 | ||
67 | 67 | ||
68 | void resize ( const QSize &s ); | 68 | void resize ( const QSize &s ); |
69 | 69 | ||
70 | int play( const QString& fileName, | 70 | int play( const QString& fileName, |
71 | int startPos = 0, | 71 | int startPos = 0, |
72 | int start_time = 0 ); | 72 | int start_time = 0 ); |
73 | void stop(); | 73 | void stop(); |
74 | void pause(); | 74 | void pause( bool toggle ); |
75 | 75 | ||
76 | int speed() const; | 76 | int speed() const; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Set the speed of the stream, if codec supports it | 79 | * Set the speed of the stream, if codec supports it |
80 | * XINE_SPEED_PAUSE 0 | 80 | * XINE_SPEED_PAUSE 0 |
81 | * XINE_SPEED_SLOW_4 1 | 81 | * XINE_SPEED_SLOW_4 1 |
82 | * XINE_SPEED_SLOW_2 2 | 82 | * XINE_SPEED_SLOW_2 2 |
83 | * XINE_SPEED_NORMAL 4 | 83 | * XINE_SPEED_NORMAL 4 |
84 | * XINE_SPEED_FAST_2 8 | 84 | * XINE_SPEED_FAST_2 8 |
85 | *XINE_SPEED_FAST_4 16 | 85 | *XINE_SPEED_FAST_4 16 |
86 | */ | 86 | */ |
87 | void setSpeed( int speed = XINE_SPEED_PAUSE ); | 87 | void setSpeed( int speed = XINE_SPEED_PAUSE ); |
88 | 88 | ||
89 | int status() const; | 89 | int status() const; |
90 | 90 | ||
91 | int currentPosition()const; | 91 | int currentPosition()const; |
92 | //in seconds | 92 | //in seconds |
93 | int currentTime()const; | 93 | int currentTime()const; |
94 | 94 | ||
95 | int length() const; | 95 | int length() const; |
96 | 96 | ||
97 | bool isSeekable()const; | 97 | bool isSeekable()const; |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * Whether or not to show video output | 100 | * Whether or not to show video output |
101 | */ | 101 | */ |
102 | void setShowVideo(bool video); | 102 | void setShowVideo(bool video); |
103 | 103 | ||
104 | /** | 104 | /** |
105 | * is we show video | 105 | * is we show video |
106 | */ | 106 | */ |
107 | bool isShowingVideo() const; | 107 | bool isShowingVideo() const; |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * | 110 | * |
111 | */ | 111 | */ |
112 | void showVideoFullScreen( bool fullScreen ); | 112 | void showVideoFullScreen( bool fullScreen ); |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * | 115 | * |
116 | */ | 116 | */ |
117 | bool isVideoFullScreen() const; | 117 | bool isVideoFullScreen() const; |
118 | 118 | ||
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Get the meta info (like author etc) from the stream | 121 | * Get the meta info (like author etc) from the stream |
122 | * XINE_META_INFO_TITLE 0 | 122 | * XINE_META_INFO_TITLE 0 |
123 | * XINE_META_INFO_COMMENT 1 | 123 | * XINE_META_INFO_COMMENT 1 |
124 | * XINE_META_INFO_ARTIST 2 | 124 | * XINE_META_INFO_ARTIST 2 |
125 | * XINE_META_INFO_GENRE 3 | 125 | * XINE_META_INFO_GENRE 3 |
126 | * XINE_META_INFO_ALBUM 4 | 126 | * XINE_META_INFO_ALBUM 4 |
127 | * XINE_META_INFO_YEAR 5 | 127 | * XINE_META_INFO_YEAR 5 |
128 | * XINE_META_INFO_VIDEOCODEC 6 | 128 | * XINE_META_INFO_VIDEOCODEC 6 |
129 | * XINE_META_INFO_AUDIOCODEC 7 | 129 | * XINE_META_INFO_AUDIOCODEC 7 |
130 | * XINE_META_INFO_SYSTEMLAYER 8 | 130 | * XINE_META_INFO_SYSTEMLAYER 8 |
131 | * XINE_META_INFO_INPUT_PLUGIN 9 | 131 | * XINE_META_INFO_INPUT_PLUGIN 9 |
132 | */ | 132 | */ |
133 | QString metaInfo( int number ) const; | 133 | QString metaInfo( int number ) const; |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * | 136 | * |
137 | */ | 137 | */ |
138 | bool isScaling() const; | 138 | bool isScaling() const; |
139 | 139 | ||
140 | /** | 140 | /** |
141 | * seek to a position | 141 | * seek to a position |
142 | */ | 142 | */ |
143 | void seekTo( int time ); | 143 | void seekTo( int time ); |
144 | 144 | ||
145 | /** | 145 | /** |
146 | * | 146 | * |
147 | * @return is media stream has video | 147 | * @return is media stream has video |
148 | */ | 148 | */ |
149 | bool hasVideo() const; | 149 | bool hasVideo() const; |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * | 152 | * |
153 | */ | 153 | */ |
154 | void setScaling( bool ); | 154 | void setScaling( bool ); |
155 | 155 | ||
156 | /** | 156 | /** |
157 | * Set the Gamma value for video output | 157 | * Set the Gamma value for video output |
158 | * @param int the value between -100 and 100, 0 is original | 158 | * @param int the value between -100 and 100, 0 is original |
159 | */ | 159 | */ |
160 | void setGamma( int ); | 160 | void setGamma( int ); |
161 | 161 | ||
162 | /** | 162 | /** |
163 | * test | 163 | * test |
164 | */ | 164 | */ |
165 | Frame currentFrame() const; | 165 | Frame currentFrame() const; |
166 | 166 | ||
167 | /** | 167 | /** |
168 | * Returns the error code | 168 | * Returns the error code |
169 | * XINE_ERROR_NONE 0 | 169 | * XINE_ERROR_NONE 0 |
170 | * XINE_ERROR_NO_INPUT_PLUGIN 1 | 170 | * XINE_ERROR_NO_INPUT_PLUGIN 1 |
171 | * XINE_ERROR_NO_DEMUXER_PLUGIN 2 | 171 | * XINE_ERROR_NO_DEMUXER_PLUGIN 2 |
172 | * XINE_ERROR_DEMUXER_FAILED 3 | 172 | * XINE_ERROR_DEMUXER_FAILED 3 |
173 | */ | 173 | */ |
174 | int error() const; | 174 | int error() const; |
175 | 175 | ||
176 | signals: | 176 | signals: |
177 | 177 | ||
178 | void stopped(); | 178 | void stopped(); |
179 | 179 | ||
180 | protected: | 180 | protected: |
181 | virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); | 181 | virtual void receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ); |
182 | 182 | ||
183 | private: | 183 | private: |
184 | int m_bytes_per_pixel; | 184 | int m_bytes_per_pixel; |
185 | bool m_video:1; | 185 | bool m_video:1; |
186 | XineVideoWidget *m_wid; | 186 | XineVideoWidget *m_wid; |
187 | xine_t *m_xine; | 187 | xine_t *m_xine; |
188 | xine_stream_t *m_stream; | 188 | xine_stream_t *m_stream; |
189 | xine_cfg_entry_t *m_config; | 189 | xine_cfg_entry_t *m_config; |
190 | xine_vo_driver_t *m_videoOutput; | 190 | xine_vo_driver_t *m_videoOutput; |
191 | xine_ao_driver_t* m_audioOutput; | 191 | xine_ao_driver_t* m_audioOutput; |
192 | xine_event_queue_t *m_queue; | 192 | xine_event_queue_t *m_queue; |
193 | 193 | ||
194 | void handleXineEvent( const xine_event_t* t ); | 194 | void handleXineEvent( const xine_event_t* t ); |
195 | void handleXineEvent( int type ); | 195 | void handleXineEvent( int type ); |
196 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); | 196 | void drawFrame( uint8_t* frame, int width, int height, int bytes ); |
197 | // C -> C++ bridge for the event system | 197 | // C -> C++ bridge for the event system |
198 | static void xine_event_handler( void* user_data, const xine_event_t* t); | 198 | static void xine_event_handler( void* user_data, const xine_event_t* t); |
199 | static void xine_display_frame( void* user_data, uint8_t* frame , | 199 | static void xine_display_frame( void* user_data, uint8_t* frame , |
200 | int width, int height, int bytes ); | 200 | int width, int height, int bytes ); |
201 | }; | 201 | }; |
202 | }; | 202 | }; |
203 | 203 | ||
204 | 204 | ||
205 | #endif | 205 | #endif |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 6f1cd9c..0e81fa2 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,259 +1,255 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | 34 | ||
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include "xinecontrol.h" | 39 | #include "xinecontrol.h" |
40 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
41 | 41 | ||
42 | XineControl::XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWidget, | 42 | XineControl::XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWidget, |
43 | MediaPlayerState &_mediaPlayerState, | 43 | MediaPlayerState &_mediaPlayerState, |
44 | QObject *parent, const char *name ) | 44 | QObject *parent, const char *name ) |
45 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ) | 45 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ) |
46 | { | 46 | { |
47 | 47 | ||
48 | libXine = new XINE::Lib( xineWidget ); | 48 | libXine = new XINE::Lib( xineWidget ); |
49 | 49 | ||
50 | connect ( videoContainerWidget, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); | 50 | connect ( videoContainerWidget, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); |
51 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); | 51 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); |
52 | connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); | 52 | connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); |
53 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 53 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
54 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 54 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
55 | connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 55 | connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
56 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); | 56 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); |
57 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 57 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
58 | 58 | ||
59 | disabledSuspendScreenSaver = FALSE; | 59 | disabledSuspendScreenSaver = FALSE; |
60 | } | 60 | } |
61 | 61 | ||
62 | XineControl::~XineControl() { | 62 | XineControl::~XineControl() { |
63 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 63 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
64 | if ( disabledSuspendScreenSaver ) { | 64 | if ( disabledSuspendScreenSaver ) { |
65 | disabledSuspendScreenSaver = FALSE; | 65 | disabledSuspendScreenSaver = FALSE; |
66 | // Re-enable the suspend mode | 66 | // Re-enable the suspend mode |
67 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 67 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
68 | } | 68 | } |
69 | #endif | 69 | #endif |
70 | delete libXine; | 70 | delete libXine; |
71 | } | 71 | } |
72 | 72 | ||
73 | void XineControl::play( const QString& fileName ) { | 73 | void XineControl::play( const QString& fileName ) { |
74 | hasVideoChannel = FALSE; | 74 | hasVideoChannel = FALSE; |
75 | hasAudioChannel = FALSE; | 75 | hasAudioChannel = FALSE; |
76 | m_fileName = fileName; | 76 | m_fileName = fileName; |
77 | 77 | ||
78 | qDebug("<<FILENAME: " + fileName + ">>>>"); | 78 | qDebug("<<FILENAME: " + fileName + ">>>>"); |
79 | 79 | ||
80 | if ( !libXine->play( fileName, 0, 0 ) ) { | 80 | if ( !libXine->play( fileName, 0, 0 ) ) { |
81 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); | 81 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); |
82 | // toggle stop so the the play button is reset | 82 | // toggle stop so the the play button is reset |
83 | mediaPlayerState.setPlaying( false ); | 83 | mediaPlayerState.setPlaying( false ); |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | mediaPlayerState.setPlaying( true ); | 86 | mediaPlayerState.setPlaying( true ); |
87 | 87 | ||
88 | MediaPlayerState::DisplayType displayType; | 88 | MediaPlayerState::DisplayType displayType; |
89 | // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); | 89 | // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); |
90 | if ( !libXine->hasVideo() ) { | 90 | if ( !libXine->hasVideo() ) { |
91 | displayType = MediaPlayerState::Audio; | 91 | displayType = MediaPlayerState::Audio; |
92 | qDebug("HAS AUDIO"); | 92 | qDebug("HAS AUDIO"); |
93 | libXine->setShowVideo( false ); | 93 | libXine->setShowVideo( false ); |
94 | hasAudioChannel = TRUE; | 94 | hasAudioChannel = TRUE; |
95 | } else { | 95 | } else { |
96 | displayType = MediaPlayerState::Video; | 96 | displayType = MediaPlayerState::Video; |
97 | qDebug("HAS VIDEO"); | 97 | qDebug("HAS VIDEO"); |
98 | libXine->setShowVideo( true ); | 98 | libXine->setShowVideo( true ); |
99 | hasVideoChannel = TRUE; | 99 | hasVideoChannel = TRUE; |
100 | } | 100 | } |
101 | // determine if slider is shown | 101 | // determine if slider is shown |
102 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); | 102 | mediaPlayerState.setIsSeekable( libXine->isSeekable() ); |
103 | 103 | ||
104 | // which gui (video / audio) | 104 | // which gui (video / audio) |
105 | mediaPlayerState.setDisplayType( displayType ); | 105 | mediaPlayerState.setDisplayType( displayType ); |
106 | 106 | ||
107 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 107 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
108 | if ( !disabledSuspendScreenSaver ) { | 108 | if ( !disabledSuspendScreenSaver ) { |
109 | disabledSuspendScreenSaver = TRUE; | 109 | disabledSuspendScreenSaver = TRUE; |
110 | // Stop the screen from blanking and power saving state | 110 | // Stop the screen from blanking and power saving state |
111 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) | 111 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) |
112 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 112 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
113 | } | 113 | } |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | length(); | 116 | length(); |
117 | position(); | 117 | position(); |
118 | } | 118 | } |
119 | 119 | ||
120 | void XineControl::nextMedia() { | 120 | void XineControl::nextMedia() { |
121 | mediaPlayerState.setNext(); | 121 | mediaPlayerState.setNext(); |
122 | } | 122 | } |
123 | 123 | ||
124 | void XineControl::setGamma( int value ) { | 124 | void XineControl::setGamma( int value ) { |
125 | libXine->setGamma( value ); | 125 | libXine->setGamma( value ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void XineControl::stop( bool isSet ) { | 128 | void XineControl::stop( bool isSet ) { |
129 | if ( !isSet ) { | 129 | if ( !isSet ) { |
130 | libXine->stop(); | 130 | libXine->stop(); |
131 | 131 | ||
132 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 132 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
133 | if ( disabledSuspendScreenSaver ) { | 133 | if ( disabledSuspendScreenSaver ) { |
134 | disabledSuspendScreenSaver = FALSE; | 134 | disabledSuspendScreenSaver = FALSE; |
135 | // Re-enable the suspend mode | 135 | // Re-enable the suspend mode |
136 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 136 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
137 | } | 137 | } |
138 | #endif | 138 | #endif |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | /** | 142 | /** |
143 | * Pause playback | 143 | * Pause playback |
144 | * @isSet | 144 | * @isSet |
145 | */ | 145 | */ |
146 | void XineControl::pause( bool isSet) { | 146 | void XineControl::pause( bool isSet) { |
147 | if ( isSet ) { | 147 | libXine->pause( isSet ); |
148 | libXine->pause(); | ||
149 | } else { | ||
150 | libXine->play( m_fileName, 0, m_currentTime ); | ||
151 | } | ||
152 | } | 148 | } |
153 | 149 | ||
154 | 150 | ||
155 | /** | 151 | /** |
156 | * get current time in playback | 152 | * get current time in playback |
157 | */ | 153 | */ |
158 | long XineControl::currentTime() { | 154 | long XineControl::currentTime() { |
159 | // todo: jede sekunde überprüfen | 155 | // todo: jede sekunde überprüfen |
160 | m_currentTime = libXine->currentTime(); | 156 | m_currentTime = libXine->currentTime(); |
161 | return m_currentTime; | 157 | return m_currentTime; |
162 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 158 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
163 | } | 159 | } |
164 | 160 | ||
165 | /** | 161 | /** |
166 | * Set the length of the media file | 162 | * Set the length of the media file |
167 | */ | 163 | */ |
168 | void XineControl::length() { | 164 | void XineControl::length() { |
169 | m_length = libXine->length(); | 165 | m_length = libXine->length(); |
170 | mediaPlayerState.setLength( m_length ); | 166 | mediaPlayerState.setLength( m_length ); |
171 | } | 167 | } |
172 | 168 | ||
173 | 169 | ||
174 | /** | 170 | /** |
175 | * Reports the position the xine backend is at right now | 171 | * Reports the position the xine backend is at right now |
176 | * @return long the postion in seconds | 172 | * @return long the postion in seconds |
177 | */ | 173 | */ |
178 | long XineControl::position() { | 174 | long XineControl::position() { |
179 | m_position = ( currentTime() ); | 175 | m_position = ( currentTime() ); |
180 | mediaPlayerState.updatePosition( m_position ); | 176 | mediaPlayerState.updatePosition( m_position ); |
181 | long emitPos = (long)m_position; | 177 | long emitPos = (long)m_position; |
182 | emit positionChanged( emitPos ); | 178 | emit positionChanged( emitPos ); |
183 | if( mediaPlayerState.isPlaying() ) { | 179 | if( mediaPlayerState.isPlaying() ) { |
184 | // needs to be stopped the media is stopped | 180 | // needs to be stopped the media is stopped |
185 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 181 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
186 | } | 182 | } |
187 | // qDebug("POSITION : %d", m_position); | 183 | // qDebug("POSITION : %d", m_position); |
188 | return m_position; | 184 | return m_position; |
189 | } | 185 | } |
190 | 186 | ||
191 | /** | 187 | /** |
192 | * Set videoplayback to fullscreen | 188 | * Set videoplayback to fullscreen |
193 | * @param isSet | 189 | * @param isSet |
194 | */ | 190 | */ |
195 | void XineControl::setFullscreen( bool isSet ) { | 191 | void XineControl::setFullscreen( bool isSet ) { |
196 | libXine->showVideoFullScreen( isSet ); | 192 | libXine->showVideoFullScreen( isSet ); |
197 | } | 193 | } |
198 | 194 | ||
199 | 195 | ||
200 | QString XineControl::getMetaInfo() { | 196 | QString XineControl::getMetaInfo() { |
201 | 197 | ||
202 | QString returnString; | 198 | QString returnString; |
203 | 199 | ||
204 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { | 200 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { |
205 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); | 201 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); |
206 | } | 202 | } |
207 | 203 | ||
208 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { | 204 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { |
209 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); | 205 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); |
210 | } | 206 | } |
211 | 207 | ||
212 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { | 208 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { |
213 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); | 209 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); |
214 | } | 210 | } |
215 | 211 | ||
216 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { | 212 | if ( !libXine->metaInfo( 3 ).isEmpty() ) { |
217 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); | 213 | returnString += tr( " Genre: " + libXine->metaInfo( 3 ) ); |
218 | } | 214 | } |
219 | 215 | ||
220 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { | 216 | if ( !libXine->metaInfo( 4 ).isEmpty() ) { |
221 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); | 217 | returnString += tr( " Album: " + libXine->metaInfo( 4 ) ); |
222 | } | 218 | } |
223 | 219 | ||
224 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { | 220 | if ( !libXine->metaInfo( 5 ).isEmpty() ) { |
225 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); | 221 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); |
226 | } | 222 | } |
227 | return returnString; | 223 | return returnString; |
228 | } | 224 | } |
229 | 225 | ||
230 | QString XineControl::getErrorCode() { | 226 | QString XineControl::getErrorCode() { |
231 | 227 | ||
232 | int errorCode = libXine->error(); | 228 | int errorCode = libXine->error(); |
233 | 229 | ||
234 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); | 230 | qDebug( QString("ERRORCODE: %1 ").arg(errorCode) ); |
235 | 231 | ||
236 | if ( errorCode == 1 ) { | 232 | if ( errorCode == 1 ) { |
237 | return tr( "No input plugin found for this media type" ); | 233 | return tr( "No input plugin found for this media type" ); |
238 | } else if ( errorCode == 2 ) { | 234 | } else if ( errorCode == 2 ) { |
239 | return tr( "No demux plugin found for this media type" ); | 235 | return tr( "No demux plugin found for this media type" ); |
240 | } else if ( errorCode == 3 ) { | 236 | } else if ( errorCode == 3 ) { |
241 | return tr( "Demuxing failed for this media type" ); | 237 | return tr( "Demuxing failed for this media type" ); |
242 | } else if ( errorCode == 4 ) { | 238 | } else if ( errorCode == 4 ) { |
243 | return tr( "Malformed MRL" ); | 239 | return tr( "Malformed MRL" ); |
244 | } else { | 240 | } else { |
245 | return tr( "Some other error" ); | 241 | return tr( "Some other error" ); |
246 | } | 242 | } |
247 | } | 243 | } |
248 | 244 | ||
249 | /** | 245 | /** |
250 | * Seek to a position in the track | 246 | * Seek to a position in the track |
251 | * @param second the second to jump to | 247 | * @param second the second to jump to |
252 | */ | 248 | */ |
253 | void XineControl::seekTo( long second ) { | 249 | void XineControl::seekTo( long second ) { |
254 | libXine->seekTo( (int)second ); | 250 | libXine->seekTo( (int)second ); |
255 | } | 251 | } |
256 | 252 | ||
257 | void XineControl::videoResized ( const QSize &s ) { | 253 | void XineControl::videoResized ( const QSize &s ) { |
258 | libXine->resize( s ); | 254 | libXine->resize( s ); |
259 | } | 255 | } |