summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-09 20:11:31 (UTC)
committer harlekin <harlekin>2002-08-09 20:11:31 (UTC)
commit46eb53b1fd042d2591933a7d89a0e65b79140f16 (patch) (unidiff)
treec5304881a9597b98f05adb04216b8042ca0d78b6
parentd8e5c405aa6bf33b8b1d59443926876e8f056e5b (diff)
downloadopie-46eb53b1fd042d2591933a7d89a0e65b79140f16.zip
opie-46eb53b1fd042d2591933a7d89a0e65b79140f16.tar.gz
opie-46eb53b1fd042d2591933a7d89a0e65b79140f16.tar.bz2
autoadvance to next media when current is finished (playlist)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp9
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.h4
2 files changed, 9 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index eba837e..8b9413f 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,161 +1,166 @@
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 "xinecontrol.h" 36#include "xinecontrol.h"
37#include "mediaplayerstate.h" 37#include "mediaplayerstate.h"
38#include "videowidget.h" 38#include "videowidget.h"
39 39
40extern MediaPlayerState *mediaPlayerState; 40extern MediaPlayerState *mediaPlayerState;
41extern VideoWidget *videoUI; 41extern VideoWidget *videoUI;
42XineControl::XineControl( QObject *parent, const char *name ) 42XineControl::XineControl( QObject *parent, const char *name )
43 : QObject( parent, name ) { 43 : QObject( parent, name ) {
44 libXine = new XINE::Lib(videoUI->vidWidget() ); 44 libXine = new XINE::Lib(videoUI->vidWidget() );
45 45
46 connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); 46 connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & )));
47 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); 47 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) );
48 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); 48 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) );
49 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 49 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
50 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 50 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
51 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 51 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
52 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
52} 53}
53 54
54XineControl::~XineControl() { 55XineControl::~XineControl() {
55 delete libXine; 56 delete libXine;
56} 57}
57 58
58void XineControl::play( const QString& fileName ) { 59void XineControl::play( const QString& fileName ) {
59 m_fileName = fileName; 60 m_fileName = fileName;
60 libXine->play( fileName ); 61 libXine->play( fileName );
61 mediaPlayerState->setPlaying( true ); 62 mediaPlayerState->setPlaying( true );
62 // default to audio view until we know how to handle video 63 // default to audio view until we know how to handle video
63 // MediaDetect mdetect; 64 // MediaDetect mdetect;
64 char whichGui = mdetect.videoOrAudio( fileName ); 65 char whichGui = mdetect.videoOrAudio( fileName );
65 if (whichGui == 'f') { 66 if (whichGui == 'f') {
66 qDebug("Nicht erkannter Dateityp"); 67 qDebug("Nicht erkannter Dateityp");
67 return; 68 return;
68 } 69 }
69 70
70 if (whichGui == 'a') { 71 if (whichGui == 'a') {
71 libXine->setShowVideo( false ); 72 libXine->setShowVideo( false );
72 } else { 73 } else {
73 libXine->setShowVideo( true ); 74 libXine->setShowVideo( true );
74 } 75 }
75 76
76 // determine if slider is shown 77 // determine if slider is shown
77 // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); 78 // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) );
78 mediaPlayerState->setIsStreaming( libXine->isSeekable() ); 79 mediaPlayerState->setIsStreaming( !libXine->isSeekable() );
79 // which gui (video / audio) 80 // which gui (video / audio)
80 mediaPlayerState->setView( whichGui ); 81 mediaPlayerState->setView( whichGui );
81 length(); 82 length();
82 position(); 83 position();
83} 84}
84 85
86void XineControl::nextMedia() {
87 mediaPlayerState->setNext();
88}
89
85void XineControl::stop( bool isSet ) { 90void XineControl::stop( bool isSet ) {
86 if ( !isSet) { 91 if ( !isSet) {
87 libXine->stop(); 92 libXine->stop( );
88 mediaPlayerState->setList(); 93 mediaPlayerState->setList();
89 //mediaPlayerState->setPlaying( false ); 94 //mediaPlayerState->setPlaying( false );
90 } else { 95 } else {
91 // play again 96 // play again
92 } 97 }
93} 98}
94 99
95/** 100/**
96 * Pause playback 101 * Pause playback
97 * @isSet 102 * @isSet
98 */ 103 */
99void XineControl::pause( bool isSet) { 104void XineControl::pause( bool isSet) {
100 if (isSet) { 105 if (isSet) {
101 libXine->pause(); 106 libXine->pause();
102 } else { 107 } else {
103 libXine->play( m_fileName, 0, m_currentTime); 108 libXine->play( m_fileName, 0, m_currentTime);
104 } 109 }
105} 110}
106 111
107 112
108/** 113/**
109 * get current time in playback 114 * get current time in playback
110 */ 115 */
111long XineControl::currentTime() { 116long XineControl::currentTime() {
112 // todo: jede sekunde überprüfen 117 // todo: jede sekunde überprüfen
113 m_currentTime = libXine->currentTime(); 118 m_currentTime = libXine->currentTime();
114 return m_currentTime; 119 return m_currentTime;
115 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 120 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
116} 121}
117 122
118/** 123/**
119 * Set the length of the media file 124 * Set the length of the media file
120 */ 125 */
121void XineControl::length() { 126void XineControl::length() {
122 m_length = libXine->length(); 127 m_length = libXine->length();
123 mediaPlayerState->setLength( m_length ); 128 mediaPlayerState->setLength( m_length );
124} 129}
125 130
126 131
127/** 132/**
128 * Reports the position the xine backend is at right now 133 * Reports the position the xine backend is at right now
129 * @return long the postion in seconds 134 * @return long the postion in seconds
130 */ 135 */
131long XineControl::position() { 136long XineControl::position() {
132 m_position = ( currentTime() ); 137 m_position = ( currentTime() );
133 mediaPlayerState->updatePosition( m_position ); 138 mediaPlayerState->updatePosition( m_position );
134 long emitPos = (long)m_position; 139 long emitPos = (long)m_position;
135 emit positionChanged( emitPos ); 140 emit positionChanged( emitPos );
136 if(mediaPlayerState->isPlaying) 141 if(mediaPlayerState->isPlaying)
137 // needs to be stopped the media is stopped 142 // needs to be stopped the media is stopped
138 QTimer::singleShot( 1000, this, SLOT( position() ) ); 143 QTimer::singleShot( 1000, this, SLOT( position() ) );
139// qDebug("POSITION : %d", m_position); 144// qDebug("POSITION : %d", m_position);
140 return m_position; 145 return m_position;
141} 146}
142 147
143/** 148/**
144 * Set videoplayback to fullscreen 149 * Set videoplayback to fullscreen
145 * @param isSet 150 * @param isSet
146 */ 151 */
147void XineControl::setFullscreen( bool isSet ) { 152void XineControl::setFullscreen( bool isSet ) {
148 libXine->showVideoFullScreen( isSet); 153 libXine->showVideoFullScreen( isSet);
149} 154}
150 155
151/** 156/**
152 * Seek to a position in the track 157 * Seek to a position in the track
153 * @param second the second to jump to 158 * @param second the second to jump to
154 */ 159 */
155void XineControl::seekTo( long second ) { 160void XineControl::seekTo( long second ) {
156 libXine->play( m_fileName , 0, (int)second ); 161 libXine->play( m_fileName , 0, (int)second );
157} 162}
158 163
159void XineControl::videoResized ( const QSize &s ) { 164void XineControl::videoResized ( const QSize &s ) {
160 libXine-> resize ( s ); 165 libXine-> resize ( s );
161} 166}
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h
index c7aefd4..712e298 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.h
+++ b/noncore/multimedia/opieplayer2/xinecontrol.h
@@ -1,73 +1,73 @@
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
41class XineControl : public QObject { 41class XineControl : public QObject {
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
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
48public slots: 48public 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 58 void nextMedia();
59 void videoResized ( const QSize &s ); 59 void videoResized ( const QSize &s );
60 60
61private: 61private:
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;
67signals: 67signals:
68 void positionChanged( long ); 68 void positionChanged( long );
69 69
70}; 70};
71 71
72 72
73#endif 73#endif