summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/xinecontrol.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/xinecontrol.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp109
1 files changed, 78 insertions, 31 deletions
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index fabc9a5..c22822c 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -24,177 +24,224 @@
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 <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
37#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
38#include "xinecontrol.h" 39#include "xinecontrol.h"
39#include "mediaplayerstate.h" 40#include "mediaplayerstate.h"
40#include "videowidget.h" 41#include "videowidget.h"
41 42
42extern MediaPlayerState *mediaPlayerState; 43extern MediaPlayerState *mediaPlayerState;
43extern VideoWidget *videoUI; 44extern VideoWidget *videoUI;
44XineControl::XineControl( QObject *parent, const char *name ) 45XineControl::XineControl( QObject *parent, const char *name )
45 : QObject( parent, name ) { 46 : QObject( parent, name ) {
47
46 libXine = new XINE::Lib(videoUI->vidWidget() ); 48 libXine = new XINE::Lib(videoUI->vidWidget() );
47 49
48 connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); 50 connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) );
49 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); 51 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) );
50 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); 52 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) );
51 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 53 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
52 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 54 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
53 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 55 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
54 connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); 56 connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) );
55 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 57 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
56 58
57 disabledSuspendScreenSaver = FALSE; 59 disabledSuspendScreenSaver = FALSE;
58} 60}
59 61
60XineControl::~XineControl() { 62XineControl::~XineControl() {
61#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 63#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
62 if ( disabledSuspendScreenSaver ) { 64 if ( disabledSuspendScreenSaver ) {
63 disabledSuspendScreenSaver = FALSE; 65 disabledSuspendScreenSaver = FALSE;
64 // Re-enable the suspend mode 66 // Re-enable the suspend mode
65 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 67 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
66 } 68 }
67#endif 69#endif
68 delete libXine; 70 delete libXine;
69} 71}
70 72
71void XineControl::play( const QString& fileName ) { 73void XineControl::play( const QString& fileName ) {
72 hasVideoChannel=FALSE; 74 hasVideoChannel = FALSE;
73 hasAudioChannel=FALSE; 75 hasAudioChannel = FALSE;
74 m_fileName = fileName; 76 m_fileName = fileName;
75 77
76 //qDebug("<<FILENAME: " + fileName + ">>>>"); 78 //qDebug("<<FILENAME: " + fileName + ">>>>");
77 79
78 libXine->play( fileName ); 80 if ( !libXine->play( fileName ) ) {
79 mediaPlayerState->setPlaying( true ); 81 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
80 char whichGui = mdetect.videoOrAudio( fileName );
81 if (whichGui == 'f') {
82 qDebug("Nicht erkannter Dateityp");
83 return; 82 return;
84 } 83 }
85 if (whichGui == 'a') { 84 mediaPlayerState->setPlaying( true );
85
86 char whichGui;
87 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) );
88 if ( !libXine->hasVideo() ) {
89 whichGui = 'a';
90 qDebug("HAS AUDIO");
86 libXine->setShowVideo( false ); 91 libXine->setShowVideo( false );
87 hasAudioChannel=TRUE; 92 hasAudioChannel = TRUE;
88 } else { 93 } else {
94 whichGui = 'v';
95 qDebug("HAS VIDEO");
89 libXine->setShowVideo( true ); 96 libXine->setShowVideo( true );
90 hasVideoChannel=TRUE; 97 hasVideoChannel = TRUE;
91 } 98 }
92 // determine if slider is shown 99 // determine if slider is shown
93 mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); 100 mediaPlayerState->setIsStreaming( !libXine->isSeekable() );
94 // which gui (video / audio) 101 // which gui (video / audio)
95 mediaPlayerState->setView( whichGui ); 102 mediaPlayerState->setView( whichGui );
96 103
97
98#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 104#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
99 if ( !disabledSuspendScreenSaver ) { 105 if ( !disabledSuspendScreenSaver ) {
100 disabledSuspendScreenSaver = TRUE; 106 disabledSuspendScreenSaver = TRUE;
101 // Stop the screen from blanking and power saving state 107 // Stop the screen from blanking and power saving state
102 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) 108 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
103 << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 109 << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend );
104 } 110 }
105#endif 111#endif
106 112
107 length(); 113 length();
108 position(); 114 position();
109} 115}
110 116
111void XineControl::nextMedia() { 117void XineControl::nextMedia() {
112 mediaPlayerState->setNext(); 118 mediaPlayerState->setNext();
113} 119}
114 120
115void XineControl::setGamma( int value ) { 121void XineControl::setGamma( int value ) {
116 libXine->setGamma( value ); 122 libXine->setGamma( value );
117} 123}
118 124
119void XineControl::stop( bool isSet ) { 125void XineControl::stop( bool isSet ) {
120 if ( !isSet) { 126 if ( !isSet ) {
121 libXine->stop( ); 127 libXine->stop();
122 128
123#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 129#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
124 if ( disabledSuspendScreenSaver ) { 130 if ( disabledSuspendScreenSaver ) {
125 disabledSuspendScreenSaver = FALSE; 131 disabledSuspendScreenSaver = FALSE;
126 // Re-enable the suspend mode 132 // Re-enable the suspend mode
127 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 133 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
128 } 134 }
129#endif 135#endif
130
131 } 136 }
132} 137}
133 138
134/** 139/**
135 * Pause playback 140 * Pause playback
136 * @isSet 141 * @isSet
137 */ 142 */
138void XineControl::pause( bool isSet) { 143void XineControl::pause( bool isSet) {
139 if (isSet) { 144 if ( isSet ) {
140 libXine->pause(); 145 libXine->pause();
141 } else { 146 } else {
142 libXine->play( m_fileName, 0, m_currentTime); 147 libXine->play( m_fileName, 0, m_currentTime );
143 } 148 }
144} 149}
145 150
146 151
147/** 152/**
148 * get current time in playback 153 * get current time in playback
149 */ 154 */
150long XineControl::currentTime() { 155long XineControl::currentTime() {
151 // todo: jede sekunde überprüfen 156 // todo: jede sekunde überprüfen
152 m_currentTime = libXine->currentTime(); 157 m_currentTime = libXine->currentTime();
153 return m_currentTime; 158 return m_currentTime;
154 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 159 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
155} 160}
156 161
157/** 162/**
158 * Set the length of the media file 163 * Set the length of the media file
159 */ 164 */
160void XineControl::length() { 165void XineControl::length() {
161 m_length = libXine->length(); 166 m_length = libXine->length();
162 mediaPlayerState->setLength( m_length ); 167 mediaPlayerState->setLength( m_length );
163} 168}
164 169
165 170
166/** 171/**
167 * Reports the position the xine backend is at right now 172 * Reports the position the xine backend is at right now
168 * @return long the postion in seconds 173 * @return long the postion in seconds
169 */ 174 */
170long XineControl::position() { 175long XineControl::position() {
171 m_position = ( currentTime() ); 176 m_position = ( currentTime() );
172 mediaPlayerState->updatePosition( m_position ); 177 mediaPlayerState->updatePosition( m_position );
173 long emitPos = (long)m_position; 178 long emitPos = (long)m_position;
174 emit positionChanged( emitPos ); 179 emit positionChanged( emitPos );
175 if(mediaPlayerState->isPlaying) 180 if( mediaPlayerState->isPlaying ) {
176 // needs to be stopped the media is stopped 181 // needs to be stopped the media is stopped
177 QTimer::singleShot( 1000, this, SLOT( position() ) ); 182 QTimer::singleShot( 1000, this, SLOT( position() ) );
178// qDebug("POSITION : %d", m_position); 183 }
184 // qDebug("POSITION : %d", m_position);
179 return m_position; 185 return m_position;
180} 186}
181 187
182/** 188/**
183 * Set videoplayback to fullscreen 189 * Set videoplayback to fullscreen
184 * @param isSet 190 * @param isSet
185 */ 191 */
186void XineControl::setFullscreen( bool isSet ) { 192void XineControl::setFullscreen( bool isSet ) {
187 libXine->showVideoFullScreen( isSet); 193 libXine->showVideoFullScreen( isSet );
194}
195
196
197QString XineControl::getMetaInfo() {
198
199 QString returnString;
200
201 if ( !libXine->metaInfo( 0 ).isEmpty() ) {
202 returnString += tr( " Titel: " + libXine->metaInfo( 0 ) );
203 }
204
205 if ( !libXine->metaInfo( 1 ).isEmpty() ) {
206 returnString += tr( " Comment: " + libXine->metaInfo( 1 ) );
207 }
208
209 if ( !libXine->metaInfo( 2 ).isEmpty() ) {
210 returnString += tr( " Artist: " + libXine->metaInfo( 2 ) );
211 }
212
213 if ( !libXine->metaInfo( 3 ).isEmpty() ) {
214 returnString += tr( " Genre: " + libXine->metaInfo( 3 ) );
215 }
216
217 if ( !libXine->metaInfo( 4 ).isEmpty() ) {
218 returnString += tr( " Album: " + libXine->metaInfo( 4 ) );
219 }
220
221 if ( !libXine->metaInfo( 5 ).isEmpty() ) {
222 returnString += tr( " Year: " + libXine->metaInfo( 5 ) );
223 }
224 return returnString;
225}
226
227QString XineControl::getErrorCode() {
228 int errorCode = libXine->error();
229
230 if ( errorCode == 1 ) {
231 return tr( "No input plugin found for this media type" );
232 } else {
233 return tr( "Some other error" );
234 }
188} 235}
189 236
190/** 237/**
191 * Seek to a position in the track 238 * Seek to a position in the track
192 * @param second the second to jump to 239 * @param second the second to jump to
193 */ 240 */
194void XineControl::seekTo( long second ) { 241void XineControl::seekTo( long second ) {
195 libXine->play( m_fileName , 0, (int)second ); 242 libXine->seekTo( (int)second );
196} 243}
197 244
198void XineControl::videoResized ( const QSize &s ) { 245void XineControl::videoResized ( const QSize &s ) {
199 libXine-> resize ( s ); 246 libXine->resize( s );
200} 247}