summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 20:36:40 (UTC)
committer simon <simon>2002-12-02 20:36:40 (UTC)
commit0090a335a7162f4b0d34f78850ebf9a8bd544c01 (patch) (unidiff)
treeaedbe7cbf4f30bb72dd4ded98f128227694de4b9
parent6cd1494f86f2f60614c9b9a7b959666dec2500ee (diff)
downloadopie-0090a335a7162f4b0d34f78850ebf9a8bd544c01.zip
opie-0090a335a7162f4b0d34f78850ebf9a8bd544c01.tar.gz
opie-0090a335a7162f4b0d34f78850ebf9a8bd544c01.tar.bz2
- removed last traces of mediaPlayerState singleton. yay :)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp2
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp33
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.h5
4 files changed, 21 insertions, 21 deletions
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp
index fd47ea5..7d11ca0 100644
--- a/noncore/multimedia/opieplayer2/main.cpp
+++ b/noncore/multimedia/opieplayer2/main.cpp
@@ -1,34 +1,32 @@
1 1
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include "mediaplayerstate.h" 3#include "mediaplayerstate.h"
4#include "playlistwidget.h" 4#include "playlistwidget.h"
5#include "audiowidget.h" 5#include "audiowidget.h"
6#include "videowidget.h" 6#include "videowidget.h"
7#include "mediaplayer.h" 7#include "mediaplayer.h"
8 8
9MediaPlayerState *mediaPlayerState;
10PlayListWidget *playList; 9PlayListWidget *playList;
11AudioWidget *audioUI; 10AudioWidget *audioUI;
12VideoWidget *videoUI; 11VideoWidget *videoUI;
13 12
14int main(int argc, char **argv) { 13int main(int argc, char **argv) {
15 QPEApplication a(argc,argv); 14 QPEApplication a(argc,argv);
16 15
17 MediaPlayerState st( 0, "mediaPlayerState" ); 16 MediaPlayerState st( 0, "mediaPlayerState" );
18 mediaPlayerState = &st;
19 PlayListWidget pl( st, 0, "playList" ); 17 PlayListWidget pl( st, 0, "playList" );
20 playList = &pl; 18 playList = &pl;
21 pl.showMaximized(); 19 pl.showMaximized();
22 AudioWidget aw( st, 0, "audioUI" ); 20 AudioWidget aw( st, 0, "audioUI" );
23 audioUI = &aw; 21 audioUI = &aw;
24 VideoWidget vw( st, 0, "videoUI" ); 22 VideoWidget vw( st, 0, "videoUI" );
25 videoUI = &vw; 23 videoUI = &vw;
26 a.processEvents(); 24 a.processEvents();
27 MediaPlayer mp( st, 0, "mediaPlayer" ); 25 MediaPlayer mp( st, 0, "mediaPlayer" );
28 26
29 a.showMainDocumentWidget(&pl); 27 a.showMainDocumentWidget(&pl);
30 28
31 return a.exec(); 29 return a.exec();
32} 30}
33 31
34 32
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 424259b..eccb5d9 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -47,33 +47,33 @@ MediaPlayer::MediaPlayer( MediaPlayerState &_mediaPlayerState, QObject *parent,
47 47
48 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 48 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
49 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 49 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
50 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 50 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
51 51
52 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 52 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
53 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 53 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
54 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 54 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
55 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 55 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
56 56
57 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 57 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
58 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 58 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
59 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 59 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
60 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 60 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
61 61
62 volControl = new VolumeControl; 62 volControl = new VolumeControl;
63 xineControl = new XineControl(); 63 xineControl = new XineControl( mediaPlayerState );
64 Config cfg( "OpiePlayer" ); 64 Config cfg( "OpiePlayer" );
65 cfg.setGroup("PlayList"); 65 cfg.setGroup("PlayList");
66 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 66 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
67 playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 67 playList->setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
68} 68}
69 69
70MediaPlayer::~MediaPlayer() { 70MediaPlayer::~MediaPlayer() {
71 delete xineControl; 71 delete xineControl;
72 delete volControl; 72 delete volControl;
73} 73}
74 74
75void MediaPlayer::pauseCheck( bool b ) { 75void MediaPlayer::pauseCheck( bool b ) {
76 if ( b && !mediaPlayerState.isPlaying() ) { 76 if ( b && !mediaPlayerState.isPlaying() ) {
77 mediaPlayerState.setPaused( FALSE ); 77 mediaPlayerState.setPaused( FALSE );
78 } 78 }
79} 79}
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index e7d5a7b..071ef7c 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -27,111 +27,110 @@
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#include "videowidget.h" 41#include "videowidget.h"
42 42
43extern MediaPlayerState *mediaPlayerState;
44extern VideoWidget *videoUI; 43extern VideoWidget *videoUI;
45XineControl::XineControl( QObject *parent, const char *name ) 44XineControl::XineControl( MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
46 : QObject( parent, name ) { 45 : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ) {
47 46
48 libXine = new XINE::Lib( videoUI->vidWidget() ); 47 libXine = new XINE::Lib( videoUI->vidWidget() );
49 48
50 connect ( videoUI, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); 49 connect ( videoUI, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) );
51 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); 50 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) );
52 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); 51 connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) );
53 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 52 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
54 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 53 connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
55 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 54 connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
56 connect( mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); 55 connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) );
57 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); 56 connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) );
58 57
59 disabledSuspendScreenSaver = FALSE; 58 disabledSuspendScreenSaver = FALSE;
60} 59}
61 60
62XineControl::~XineControl() { 61XineControl::~XineControl() {
63#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 62#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
64 if ( disabledSuspendScreenSaver ) { 63 if ( disabledSuspendScreenSaver ) {
65 disabledSuspendScreenSaver = FALSE; 64 disabledSuspendScreenSaver = FALSE;
66 // Re-enable the suspend mode 65 // Re-enable the suspend mode
67 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 66 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
68 } 67 }
69#endif 68#endif
70 delete libXine; 69 delete libXine;
71} 70}
72 71
73void XineControl::play( const QString& fileName ) { 72void XineControl::play( const QString& fileName ) {
74 hasVideoChannel = FALSE; 73 hasVideoChannel = FALSE;
75 hasAudioChannel = FALSE; 74 hasAudioChannel = FALSE;
76 m_fileName = fileName; 75 m_fileName = fileName;
77 76
78 qDebug("<<FILENAME: " + fileName + ">>>>"); 77 qDebug("<<FILENAME: " + fileName + ">>>>");
79 78
80 if ( !libXine->play( fileName, 0, 0 ) ) { 79 if ( !libXine->play( fileName, 0, 0 ) ) {
81 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); 80 QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() );
82 // toggle stop so the the play button is reset 81 // toggle stop so the the play button is reset
83 mediaPlayerState->setPlaying( false ); 82 mediaPlayerState.setPlaying( false );
84 return; 83 return;
85 } 84 }
86 mediaPlayerState->setPlaying( true ); 85 mediaPlayerState.setPlaying( true );
87 86
88 MediaPlayerState::DisplayType displayType; 87 MediaPlayerState::DisplayType displayType;
89 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) ); 88 // qDebug( QString( "libXine->hasVideo() return : %1 ").arg( libXine->hasVideo() ) );
90 if ( !libXine->hasVideo() ) { 89 if ( !libXine->hasVideo() ) {
91 displayType = MediaPlayerState::Audio; 90 displayType = MediaPlayerState::Audio;
92 qDebug("HAS AUDIO"); 91 qDebug("HAS AUDIO");
93 libXine->setShowVideo( false ); 92 libXine->setShowVideo( false );
94 hasAudioChannel = TRUE; 93 hasAudioChannel = TRUE;
95 } else { 94 } else {
96 displayType = MediaPlayerState::Video; 95 displayType = MediaPlayerState::Video;
97 qDebug("HAS VIDEO"); 96 qDebug("HAS VIDEO");
98 libXine->setShowVideo( true ); 97 libXine->setShowVideo( true );
99 hasVideoChannel = TRUE; 98 hasVideoChannel = TRUE;
100 } 99 }
101 // determine if slider is shown 100 // determine if slider is shown
102 mediaPlayerState->setIsSeekable( libXine->isSeekable() ); 101 mediaPlayerState.setIsSeekable( libXine->isSeekable() );
103 102
104 // which gui (video / audio) 103 // which gui (video / audio)
105 mediaPlayerState->setDisplayType( displayType ); 104 mediaPlayerState.setDisplayType( displayType );
106 105
107#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 106#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
108 if ( !disabledSuspendScreenSaver ) { 107 if ( !disabledSuspendScreenSaver ) {
109 disabledSuspendScreenSaver = TRUE; 108 disabledSuspendScreenSaver = TRUE;
110 // Stop the screen from blanking and power saving state 109 // Stop the screen from blanking and power saving state
111 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) 110 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" )
112 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 111 << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend );
113 } 112 }
114#endif 113#endif
115 114
116 length(); 115 length();
117 position(); 116 position();
118} 117}
119 118
120void XineControl::nextMedia() { 119void XineControl::nextMedia() {
121 mediaPlayerState->setNext(); 120 mediaPlayerState.setNext();
122} 121}
123 122
124void XineControl::setGamma( int value ) { 123void XineControl::setGamma( int value ) {
125 libXine->setGamma( value ); 124 libXine->setGamma( value );
126} 125}
127 126
128void XineControl::stop( bool isSet ) { 127void XineControl::stop( bool isSet ) {
129 if ( !isSet ) { 128 if ( !isSet ) {
130 libXine->stop(); 129 libXine->stop();
131 130
132#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 131#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
133 if ( disabledSuspendScreenSaver ) { 132 if ( disabledSuspendScreenSaver ) {
134 disabledSuspendScreenSaver = FALSE; 133 disabledSuspendScreenSaver = FALSE;
135 // Re-enable the suspend mode 134 // Re-enable the suspend mode
136 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 135 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
137 } 136 }
@@ -154,46 +153,46 @@ void XineControl::pause( bool isSet) {
154 153
155/** 154/**
156 * get current time in playback 155 * get current time in playback
157 */ 156 */
158long XineControl::currentTime() { 157long XineControl::currentTime() {
159 // todo: jede sekunde überprüfen 158 // todo: jede sekunde überprüfen
160 m_currentTime = libXine->currentTime(); 159 m_currentTime = libXine->currentTime();
161 return m_currentTime; 160 return m_currentTime;
162 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 161 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
163} 162}
164 163
165/** 164/**
166 * Set the length of the media file 165 * Set the length of the media file
167 */ 166 */
168void XineControl::length() { 167void XineControl::length() {
169 m_length = libXine->length(); 168 m_length = libXine->length();
170 mediaPlayerState->setLength( m_length ); 169 mediaPlayerState.setLength( m_length );
171} 170}
172 171
173 172
174/** 173/**
175 * Reports the position the xine backend is at right now 174 * Reports the position the xine backend is at right now
176 * @return long the postion in seconds 175 * @return long the postion in seconds
177 */ 176 */
178long XineControl::position() { 177long XineControl::position() {
179 m_position = ( currentTime() ); 178 m_position = ( currentTime() );
180 mediaPlayerState->updatePosition( m_position ); 179 mediaPlayerState.updatePosition( m_position );
181 long emitPos = (long)m_position; 180 long emitPos = (long)m_position;
182 emit positionChanged( emitPos ); 181 emit positionChanged( emitPos );
183 if( mediaPlayerState->isPlaying() ) { 182 if( mediaPlayerState.isPlaying() ) {
184 // needs to be stopped the media is stopped 183 // needs to be stopped the media is stopped
185 QTimer::singleShot( 1000, this, SLOT( position() ) ); 184 QTimer::singleShot( 1000, this, SLOT( position() ) );
186 } 185 }
187 // qDebug("POSITION : %d", m_position); 186 // qDebug("POSITION : %d", m_position);
188 return m_position; 187 return m_position;
189} 188}
190 189
191/** 190/**
192 * Set videoplayback to fullscreen 191 * Set videoplayback to fullscreen
193 * @param isSet 192 * @param isSet
194 */ 193 */
195void XineControl::setFullscreen( bool isSet ) { 194void XineControl::setFullscreen( bool isSet ) {
196 libXine->showVideoFullScreen( isSet ); 195 libXine->showVideoFullScreen( isSet );
197} 196}
198 197
199 198
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h
index b1300a8..00486f2 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.h
+++ b/noncore/multimedia/opieplayer2/xinecontrol.h
@@ -24,36 +24,38 @@
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#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 <qobject.h> 38#include <qobject.h>
39 39
40#include "mediaplayerstate.h"
41
40class XineControl : public QObject { 42class XineControl : public QObject {
41 Q_OBJECT 43 Q_OBJECT
42public: 44public:
43 XineControl( QObject *parent = 0, const char *name =0 ); 45 XineControl( MediaPlayerState &_mediaPlayerState, QObject *parent = 0, const char *name =0 );
44 ~XineControl(); 46 ~XineControl();
45 47
46 bool hasVideo() const { return hasVideoChannel; } 48 bool hasVideo() const { return hasVideoChannel; }
47 bool hasAudio() const { return hasAudioChannel; } 49 bool hasAudio() const { return hasAudioChannel; }
48 50
49public slots: 51public slots:
50 void play( const QString& fileName ); 52 void play( const QString& fileName );
51 void stop( bool ); 53 void stop( bool );
52 54
53 /** 55 /**
54 * Pause the media stream 56 * Pause the media stream
55 * @param if pause or not 57 * @param if pause or not
56 */ 58 */
57 void pause( bool ); 59 void pause( bool );
58 60
59 /** 61 /**
@@ -93,24 +95,25 @@ public slots:
93 /** 95 /**
94 * Set the gamma value of the video output 96 * Set the gamma value of the video output
95 * @param int value between -100 and 100, 0 is original 97 * @param int value between -100 and 100, 0 is original
96 */ 98 */
97 void setGamma( int ); 99 void setGamma( int );
98 100
99 101
100private: 102private:
101 XINE::Lib *libXine; 103 XINE::Lib *libXine;
102 long m_currentTime; 104 long m_currentTime;
103 long m_position; 105 long m_position;
104 int m_length; 106 int m_length;
105 QString m_fileName; 107 QString m_fileName;
106 bool disabledSuspendScreenSaver : 1; 108 bool disabledSuspendScreenSaver : 1;
107 bool hasVideoChannel : 1; 109 bool hasVideoChannel : 1;
108 bool hasAudioChannel : 1; 110 bool hasAudioChannel : 1;
111 MediaPlayerState &mediaPlayerState;
109 112
110signals: 113signals:
111 void positionChanged( long ); 114 void positionChanged( long );
112 115
113}; 116};
114 117
115 118
116#endif 119#endif