-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 30 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 1 |
2 files changed, 31 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 8b9413f..84ef3f3 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,166 +1,196 @@ | |||
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 | ..}^=.= = ; 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 | 34 | ||
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qpe/qcopenvelope_qws.h> | ||
37 | #include <qpe/qpeapplication.h> | ||
36 | #include "xinecontrol.h" | 38 | #include "xinecontrol.h" |
37 | #include "mediaplayerstate.h" | 39 | #include "mediaplayerstate.h" |
38 | #include "videowidget.h" | 40 | #include "videowidget.h" |
39 | 41 | ||
40 | extern MediaPlayerState *mediaPlayerState; | 42 | extern MediaPlayerState *mediaPlayerState; |
41 | extern VideoWidget *videoUI; | 43 | extern VideoWidget *videoUI; |
42 | XineControl::XineControl( QObject *parent, const char *name ) | 44 | XineControl::XineControl( QObject *parent, const char *name ) |
43 | : QObject( parent, name ) { | 45 | : QObject( parent, name ) { |
44 | libXine = new XINE::Lib(videoUI->vidWidget() ); | 46 | libXine = new XINE::Lib(videoUI->vidWidget() ); |
45 | 47 | ||
46 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); | 48 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); |
47 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 49 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
48 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); | 50 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); |
49 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 51 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
50 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 52 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
51 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 53 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
52 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 54 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
55 | |||
56 | disabledSuspendScreenSaver = FALSE; | ||
53 | } | 57 | } |
54 | 58 | ||
55 | XineControl::~XineControl() { | 59 | XineControl::~XineControl() { |
60 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
61 | if ( disabledSuspendScreenSaver ) { | ||
62 | disabledSuspendScreenSaver = FALSE; | ||
63 | // Re-enable the suspend mode | ||
64 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | ||
65 | } | ||
66 | #endif | ||
56 | delete libXine; | 67 | delete libXine; |
57 | } | 68 | } |
58 | 69 | ||
59 | void XineControl::play( const QString& fileName ) { | 70 | void XineControl::play( const QString& fileName ) { |
60 | m_fileName = fileName; | 71 | m_fileName = fileName; |
61 | libXine->play( fileName ); | 72 | libXine->play( fileName ); |
62 | mediaPlayerState->setPlaying( true ); | 73 | mediaPlayerState->setPlaying( true ); |
63 | // default to audio view until we know how to handle video | 74 | // default to audio view until we know how to handle video |
64 | // MediaDetect mdetect; | 75 | // MediaDetect mdetect; |
65 | char whichGui = mdetect.videoOrAudio( fileName ); | 76 | char whichGui = mdetect.videoOrAudio( fileName ); |
66 | if (whichGui == 'f') { | 77 | if (whichGui == 'f') { |
67 | qDebug("Nicht erkannter Dateityp"); | 78 | qDebug("Nicht erkannter Dateityp"); |
68 | return; | 79 | return; |
69 | } | 80 | } |
70 | 81 | ||
71 | if (whichGui == 'a') { | 82 | if (whichGui == 'a') { |
72 | libXine->setShowVideo( false ); | 83 | libXine->setShowVideo( false ); |
73 | } else { | 84 | } else { |
74 | libXine->setShowVideo( true ); | 85 | libXine->setShowVideo( true ); |
75 | } | 86 | } |
76 | 87 | ||
77 | // determine if slider is shown | 88 | // determine if slider is shown |
78 | // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); | 89 | // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); |
79 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); | 90 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); |
80 | // which gui (video / audio) | 91 | // which gui (video / audio) |
81 | mediaPlayerState->setView( whichGui ); | 92 | mediaPlayerState->setView( whichGui ); |
93 | |||
94 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
95 | if ( !disabledSuspendScreenSaver ) { | ||
96 | disabledSuspendScreenSaver = TRUE; | ||
97 | // Stop the screen from blanking and power saving state | ||
98 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | ||
99 | << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | ||
100 | } | ||
101 | #endif | ||
102 | |||
82 | length(); | 103 | length(); |
83 | position(); | 104 | position(); |
84 | } | 105 | } |
85 | 106 | ||
86 | void XineControl::nextMedia() { | 107 | void XineControl::nextMedia() { |
87 | mediaPlayerState->setNext(); | 108 | mediaPlayerState->setNext(); |
88 | } | 109 | } |
89 | 110 | ||
90 | void XineControl::stop( bool isSet ) { | 111 | void XineControl::stop( bool isSet ) { |
91 | if ( !isSet) { | 112 | if ( !isSet) { |
92 | libXine->stop( ); | 113 | libXine->stop( ); |
93 | mediaPlayerState->setList(); | 114 | mediaPlayerState->setList(); |
94 | //mediaPlayerState->setPlaying( false ); | 115 | //mediaPlayerState->setPlaying( false ); |
116 | |||
117 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
118 | if ( disabledSuspendScreenSaver ) { | ||
119 | disabledSuspendScreenSaver = FALSE; | ||
120 | // Re-enable the suspend mode | ||
121 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | ||
122 | } | ||
123 | #endif | ||
124 | |||
95 | } else { | 125 | } else { |
96 | // play again | 126 | // play again |
97 | } | 127 | } |
98 | } | 128 | } |
99 | 129 | ||
100 | /** | 130 | /** |
101 | * Pause playback | 131 | * Pause playback |
102 | * @isSet | 132 | * @isSet |
103 | */ | 133 | */ |
104 | void XineControl::pause( bool isSet) { | 134 | void XineControl::pause( bool isSet) { |
105 | if (isSet) { | 135 | if (isSet) { |
106 | libXine->pause(); | 136 | libXine->pause(); |
107 | } else { | 137 | } else { |
108 | libXine->play( m_fileName, 0, m_currentTime); | 138 | libXine->play( m_fileName, 0, m_currentTime); |
109 | } | 139 | } |
110 | } | 140 | } |
111 | 141 | ||
112 | 142 | ||
113 | /** | 143 | /** |
114 | * get current time in playback | 144 | * get current time in playback |
115 | */ | 145 | */ |
116 | long XineControl::currentTime() { | 146 | long XineControl::currentTime() { |
117 | // todo: jede sekunde überprüfen | 147 | // todo: jede sekunde überprüfen |
118 | m_currentTime = libXine->currentTime(); | 148 | m_currentTime = libXine->currentTime(); |
119 | return m_currentTime; | 149 | return m_currentTime; |
120 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 150 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
121 | } | 151 | } |
122 | 152 | ||
123 | /** | 153 | /** |
124 | * Set the length of the media file | 154 | * Set the length of the media file |
125 | */ | 155 | */ |
126 | void XineControl::length() { | 156 | void XineControl::length() { |
127 | m_length = libXine->length(); | 157 | m_length = libXine->length(); |
128 | mediaPlayerState->setLength( m_length ); | 158 | mediaPlayerState->setLength( m_length ); |
129 | } | 159 | } |
130 | 160 | ||
131 | 161 | ||
132 | /** | 162 | /** |
133 | * Reports the position the xine backend is at right now | 163 | * Reports the position the xine backend is at right now |
134 | * @return long the postion in seconds | 164 | * @return long the postion in seconds |
135 | */ | 165 | */ |
136 | long XineControl::position() { | 166 | long XineControl::position() { |
137 | m_position = ( currentTime() ); | 167 | m_position = ( currentTime() ); |
138 | mediaPlayerState->updatePosition( m_position ); | 168 | mediaPlayerState->updatePosition( m_position ); |
139 | long emitPos = (long)m_position; | 169 | long emitPos = (long)m_position; |
140 | emit positionChanged( emitPos ); | 170 | emit positionChanged( emitPos ); |
141 | if(mediaPlayerState->isPlaying) | 171 | if(mediaPlayerState->isPlaying) |
142 | // needs to be stopped the media is stopped | 172 | // needs to be stopped the media is stopped |
143 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 173 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
144 | // qDebug("POSITION : %d", m_position); | 174 | // qDebug("POSITION : %d", m_position); |
145 | return m_position; | 175 | return m_position; |
146 | } | 176 | } |
147 | 177 | ||
148 | /** | 178 | /** |
149 | * Set videoplayback to fullscreen | 179 | * Set videoplayback to fullscreen |
150 | * @param isSet | 180 | * @param isSet |
151 | */ | 181 | */ |
152 | void XineControl::setFullscreen( bool isSet ) { | 182 | void XineControl::setFullscreen( bool isSet ) { |
153 | libXine->showVideoFullScreen( isSet); | 183 | libXine->showVideoFullScreen( isSet); |
154 | } | 184 | } |
155 | 185 | ||
156 | /** | 186 | /** |
157 | * Seek to a position in the track | 187 | * Seek to a position in the track |
158 | * @param second the second to jump to | 188 | * @param second the second to jump to |
159 | */ | 189 | */ |
160 | void XineControl::seekTo( long second ) { | 190 | void XineControl::seekTo( long second ) { |
161 | libXine->play( m_fileName , 0, (int)second ); | 191 | libXine->play( m_fileName , 0, (int)second ); |
162 | } | 192 | } |
163 | 193 | ||
164 | void XineControl::videoResized ( const QSize &s ) { | 194 | void XineControl::videoResized ( const QSize &s ) { |
165 | libXine-> resize ( s ); | 195 | libXine-> resize ( s ); |
166 | } | 196 | } |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 712e298..9ad221e 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -1,73 +1,74 @@ | |||
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 | ..}^=.= = ; 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 XINECONTROL_H | 34 | #ifndef XINECONTROL_H |
35 | #define XINECONTROL_H | 35 | #define XINECONTROL_H |
36 | 36 | ||
37 | #include "lib.h" | 37 | #include "lib.h" |
38 | #include "mediadetect.h" | 38 | #include "mediadetect.h" |
39 | #include <qobject.h> | 39 | #include <qobject.h> |
40 | 40 | ||
41 | class XineControl : public QObject { | 41 | class XineControl : public QObject { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | public: | 43 | public: |
44 | XineControl( QObject *parent = 0, const char *name =0 ); | 44 | XineControl( QObject *parent = 0, const char *name =0 ); |
45 | ~XineControl(); | 45 | ~XineControl(); |
46 | int m_length; | 46 | int m_length; |
47 | 47 | ||
48 | public slots: | 48 | public slots: |
49 | void play( const QString& fileName ); | 49 | void play( const QString& fileName ); |
50 | void stop( bool ); | 50 | void stop( bool ); |
51 | void pause( bool ); | 51 | void pause( bool ); |
52 | void setFullscreen( bool ); | 52 | void setFullscreen( bool ); |
53 | long currentTime(); | 53 | long currentTime(); |
54 | void seekTo( long ); | 54 | void seekTo( long ); |
55 | // get length of media file and set it | 55 | // get length of media file and set it |
56 | void length(); | 56 | void length(); |
57 | long position(); | 57 | long position(); |
58 | void nextMedia(); | 58 | void nextMedia(); |
59 | void videoResized ( const QSize &s ); | 59 | void videoResized ( const QSize &s ); |
60 | 60 | ||
61 | private: | 61 | private: |
62 | XINE::Lib *libXine; | 62 | XINE::Lib *libXine; |
63 | MediaDetect mdetect; | 63 | MediaDetect mdetect; |
64 | long m_currentTime; | 64 | long m_currentTime; |
65 | long m_position; | 65 | long m_position; |
66 | QString m_fileName; | 66 | QString m_fileName; |
67 | bool disabledSuspendScreenSaver; | ||
67 | signals: | 68 | signals: |
68 | void positionChanged( long ); | 69 | void positionChanged( long ); |
69 | 70 | ||
70 | }; | 71 | }; |
71 | 72 | ||
72 | 73 | ||
73 | #endif | 74 | #endif |