author | zecke <zecke> | 2004-09-24 15:15:51 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-24 15:15:51 (UTC) |
commit | 4c53e68c3ac96baaaf39cc049c89d8ccf022ff59 (patch) (unidiff) | |
tree | 8273ae338f0d611c28438a4f8a6a6fc8329e90e8 /noncore/multimedia/opieplayer2 | |
parent | a214128c01e38ffd50edc4ed5b5c72593796eab2 (diff) | |
download | opie-4c53e68c3ac96baaaf39cc049c89d8ccf022ff59.zip opie-4c53e68c3ac96baaaf39cc049c89d8ccf022ff59.tar.gz opie-4c53e68c3ac96baaaf39cc049c89d8ccf022ff59.tar.bz2 |
Handling of Errors is a bit problematic with the current design.
We can start playing from multiple contexts. This are the PlayList context
and single file context. Now the problem is that
MediapPlayerState::setPlaying emits a signal. If started from the
the PlayList setPlaying(false) would trigger an infite loop together
with the Play ToggleButton, in single file context setPlaying(false)
is the right choiche.
The intermediate solution is to show an Error MessageBox and to raise
the Audio Widget and leave it to the user to close it or go to the next
file.
Diffstat (limited to 'noncore/multimedia/opieplayer2') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 48 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 4 |
3 files changed, 30 insertions, 23 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index d73f0cd..37b998f 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -45,24 +45,25 @@ using namespace Opie::Core; | |||
45 | using namespace Opie::Ui; | 45 | using namespace Opie::Ui; |
46 | 46 | ||
47 | /* QT */ | 47 | /* QT */ |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qtoolbar.h> | 49 | #include <qtoolbar.h> |
50 | 50 | ||
51 | /* STD */ | 51 | /* STD */ |
52 | #include <assert.h> | 52 | #include <assert.h> |
53 | 53 | ||
54 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) | 54 | PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) |
55 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) | 55 | : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) |
56 | { | 56 | { |
57 | Global::statusMessage( tr( "Loading of Skin started" ) ); | ||
57 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); | 58 | mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); |
58 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); | 59 | m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); |
59 | 60 | ||
60 | 61 | ||
61 | 62 | ||
62 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 63 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
63 | "opieplayer2/add_to_playlist", | 64 | "opieplayer2/add_to_playlist", |
64 | this , SLOT(addSelected() ) ); | 65 | this , SLOT(addSelected() ) ); |
65 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 66 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
66 | "opieplayer2/remove_from_playlist", | 67 | "opieplayer2/remove_from_playlist", |
67 | this , SLOT(removeSelected() ) ); | 68 | this , SLOT(removeSelected() ) ); |
68 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 69 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index e1816c8..c47a773 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -35,39 +35,31 @@ | |||
35 | #include "xinevideowidget.h" | 35 | #include "xinevideowidget.h" |
36 | 36 | ||
37 | /* OPIE */ | 37 | /* OPIE */ |
38 | #include <opie2/odebug.h> | 38 | #include <opie2/odebug.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
41 | using namespace Opie::Core; | 41 | using namespace Opie::Core; |
42 | 42 | ||
43 | /* QT */ | 43 | /* QT */ |
44 | #include <qtimer.h> | 44 | #include <qtimer.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | 46 | ||
47 | XineControl::XineControl( XineVideoWidget *xineWidget, | ||
48 | MediaPlayerState &_mediaPlayerState, | ||
49 | QObject *parent, const char *name ) | ||
50 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) | ||
51 | { | ||
52 | libXine = new XINE::Lib( XINE::Lib::InitializeImmediately, xineWidget ); | ||
53 | |||
54 | init(); | ||
55 | } | ||
56 | |||
57 | XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, | 47 | XineControl::XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, |
58 | MediaPlayerState &_mediaPlayerState, | 48 | MediaPlayerState &_mediaPlayerState, |
59 | QObject *parent, const char *name ) | 49 | QObject *parent, const char *name ) |
60 | : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) | 50 | : QObject( parent, name ), libXine( xine ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) |
61 | { | 51 | { |
52 | m_wasError = false; | ||
53 | |||
62 | xine->ensureInitialized(); | 54 | xine->ensureInitialized(); |
63 | 55 | ||
64 | xine->setWidget( xineWidget ); | 56 | xine->setWidget( xineWidget ); |
65 | 57 | ||
66 | init(); | 58 | init(); |
67 | } | 59 | } |
68 | 60 | ||
69 | void XineControl::init() | 61 | void XineControl::init() |
70 | { | 62 | { |
71 | connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 63 | connect( &mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
72 | connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); | 64 | connect( this, SIGNAL( positionChanged(long) ), &mediaPlayerState, SLOT( updatePosition(long) ) ); |
73 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); | 65 | connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( stop(bool) ) ); |
@@ -87,32 +79,35 @@ XineControl::~XineControl() { | |||
87 | // Re-enable the suspend mode | 79 | // Re-enable the suspend mode |
88 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 80 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
89 | } | 81 | } |
90 | #endif | 82 | #endif |
91 | delete libXine; | 83 | delete libXine; |
92 | } | 84 | } |
93 | 85 | ||
94 | void XineControl::play( const QString& fileName ) { | 86 | void XineControl::play( const QString& fileName ) { |
95 | 87 | ||
96 | hasVideoChannel = FALSE; | 88 | hasVideoChannel = FALSE; |
97 | hasAudioChannel = FALSE; | 89 | hasAudioChannel = FALSE; |
98 | m_fileName = fileName; | 90 | m_fileName = fileName; |
91 | m_wasError = false; | ||
99 | 92 | ||
100 | odebug << "<<FILENAME: " + fileName + ">>>>" << oendl; | ||
101 | 93 | ||
94 | /* | ||
95 | * If Playing Fails we will fire up an MessgaeBox | ||
96 | * but present the AudioWidget so the User can | ||
97 | * either Quit and change the Playlist or Continue | ||
98 | */ | ||
102 | if ( !libXine->play( fileName, 0, 0 ) ) { | 99 | if ( !libXine->play( fileName, 0, 0 ) ) { |
103 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); | 100 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); |
104 | // toggle stop so the the play button is reset | 101 | m_wasError = true; |
105 | mediaPlayerState.setPlaying( false ); | ||
106 | return; | ||
107 | } | 102 | } |
108 | mediaPlayerState.setPlaying( true ); | 103 | mediaPlayerState.setPlaying( true ); |
109 | 104 | ||
110 | MediaPlayerState::DisplayType displayType; | 105 | MediaPlayerState::DisplayType displayType; |
111 | if ( !libXine->hasVideo() ) { | 106 | if ( !libXine->hasVideo() ) { |
112 | displayType = MediaPlayerState::Audio; | 107 | displayType = MediaPlayerState::Audio; |
113 | libXine->setShowVideo( false ); | 108 | libXine->setShowVideo( false ); |
114 | hasAudioChannel = TRUE; | 109 | hasAudioChannel = TRUE; |
115 | } else { | 110 | } else { |
116 | displayType = MediaPlayerState::Video; | 111 | displayType = MediaPlayerState::Video; |
117 | libXine->setShowVideo( true ); | 112 | libXine->setShowVideo( true ); |
118 | hasVideoChannel = TRUE; | 113 | hasVideoChannel = TRUE; |
@@ -205,24 +200,37 @@ long XineControl::position() { | |||
205 | * Set videoplayback to fullscreen | 200 | * Set videoplayback to fullscreen |
206 | * @param isSet | 201 | * @param isSet |
207 | */ | 202 | */ |
208 | void XineControl::setFullscreen( bool isSet ) { | 203 | void XineControl::setFullscreen( bool isSet ) { |
209 | libXine->showVideoFullScreen( isSet ); | 204 | libXine->showVideoFullScreen( isSet ); |
210 | } | 205 | } |
211 | 206 | ||
212 | 207 | ||
213 | QString XineControl::getMetaInfo() { | 208 | QString XineControl::getMetaInfo() { |
214 | 209 | ||
215 | QString returnString; | 210 | QString returnString; |
216 | 211 | ||
212 | /* | ||
213 | * If there was an error let us | ||
214 | * change the Meta Info to contain the Error Message | ||
215 | */ | ||
216 | if ( m_wasError ) { | ||
217 | returnString = tr("Error on file '%1' with reason: ", | ||
218 | "Error when playing a file" ).arg( m_fileName ); | ||
219 | returnString += getErrorCode(); | ||
220 | returnString.replace( QRegExp("<qt>", false), "" ); | ||
221 | returnString.replace( QRegExp("</qt>", false), "" ); | ||
222 | return returnString; | ||
223 | } | ||
224 | |||
217 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { | 225 | if ( !libXine->metaInfo( 0 ).isEmpty() ) { |
218 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); | 226 | returnString += tr( " Title: " + libXine->metaInfo( 0 ) ); |
219 | } | 227 | } |
220 | 228 | ||
221 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { | 229 | if ( !libXine->metaInfo( 1 ).isEmpty() ) { |
222 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); | 230 | returnString += tr( " Comment: " + libXine->metaInfo( 1 ) ); |
223 | } | 231 | } |
224 | 232 | ||
225 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { | 233 | if ( !libXine->metaInfo( 2 ).isEmpty() ) { |
226 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); | 234 | returnString += tr( " Artist: " + libXine->metaInfo( 2 ) ); |
227 | } | 235 | } |
228 | 236 | ||
@@ -238,35 +246,35 @@ QString XineControl::getMetaInfo() { | |||
238 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); | 246 | returnString += tr( " Year: " + libXine->metaInfo( 5 ) ); |
239 | } | 247 | } |
240 | return returnString; | 248 | return returnString; |
241 | } | 249 | } |
242 | 250 | ||
243 | QString XineControl::getErrorCode() { | 251 | QString XineControl::getErrorCode() { |
244 | 252 | ||
245 | int errorCode = libXine->error(); | 253 | int errorCode = libXine->error(); |
246 | 254 | ||
247 | odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl; | 255 | odebug << QString("ERRORCODE: %1 ").arg(errorCode) << oendl; |
248 | 256 | ||
249 | if ( errorCode == 1 ) { | 257 | if ( errorCode == 1 ) { |
250 | return tr( "No input plugin found for this media type" ); | 258 | return tr( "<qt>No input plugin found for this media type</qt>" ); |
251 | } else if ( errorCode == 2 ) { | 259 | } else if ( errorCode == 2 ) { |
252 | return tr( "No demux plugin found for this media type" ); | 260 | return tr( "<qt>No demux plugin found for this media type</qt>" ); |
253 | } else if ( errorCode == 3 ) { | 261 | } else if ( errorCode == 3 ) { |
254 | return tr( "Demuxing failed for this media type" ); | 262 | return tr( "<qt>Demuxing failed for this media type</qt>" ); |
255 | } else if ( errorCode == 4 ) { | 263 | } else if ( errorCode == 4 ) { |
256 | return tr( "Malformed MRL" ); | 264 | return tr( "<qt>Malformed MRL</qt>" ); |
257 | } else if ( errorCode == 5 ) { | 265 | } else if ( errorCode == 5 ) { |
258 | return tr( "Input failed" ); | 266 | return tr( "<qt>Input failed</qt>" ); |
259 | } else { | 267 | } else { |
260 | return tr( "Some other error" ); | 268 | return tr( "<qt>Some other error</qt>" ); |
261 | } | 269 | } |
262 | } | 270 | } |
263 | 271 | ||
264 | /** | 272 | /** |
265 | * Seek to a position in the track | 273 | * Seek to a position in the track |
266 | * @param second the second to jump to | 274 | * @param second the second to jump to |
267 | */ | 275 | */ |
268 | void XineControl::seekTo( long second ) { | 276 | void XineControl::seekTo( long second ) { |
269 | libXine->seekTo( (int)second ); | 277 | libXine->seekTo( (int)second ); |
270 | } | 278 | } |
271 | 279 | ||
272 | void XineControl::videoResized ( const QSize &s ) { | 280 | void XineControl::videoResized ( const QSize &s ) { |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 3f44f2e..848bd05 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -32,27 +32,24 @@ | |||
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 | 38 | ||
39 | #include "mediaplayerstate.h" | 39 | #include "mediaplayerstate.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( XineVideoWidget *xineWidget, | ||
45 | MediaPlayerState &_mediaPlayerState, | ||
46 | QObject *parent = 0, const char *name =0 ); | ||
47 | // note that this constructor takes over ownership of the passed | 44 | // note that this constructor takes over ownership of the passed |
48 | // XINE::Lib object. | 45 | // XINE::Lib object. |
49 | XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, | 46 | XineControl( XINE::Lib *xine, XineVideoWidget *xineWidget, |
50 | MediaPlayerState &_mediaPlayerState, | 47 | MediaPlayerState &_mediaPlayerState, |
51 | QObject *parent = 0, const char *name =0 ); | 48 | QObject *parent = 0, const char *name =0 ); |
52 | ~XineControl(); | 49 | ~XineControl(); |
53 | 50 | ||
54 | bool hasVideo() const { return hasVideoChannel; } | 51 | bool hasVideo() const { return hasVideoChannel; } |
55 | bool hasAudio() const { return hasAudioChannel; } | 52 | bool hasAudio() const { return hasAudioChannel; } |
56 | 53 | ||
57 | public slots: | 54 | public slots: |
58 | void play( const QString& fileName ); | 55 | void play( const QString& fileName ); |
@@ -108,19 +105,20 @@ private: | |||
108 | void init(); | 105 | void init(); |
109 | 106 | ||
110 | XINE::Lib *libXine; | 107 | XINE::Lib *libXine; |
111 | long m_currentTime; | 108 | long m_currentTime; |
112 | long m_position; | 109 | long m_position; |
113 | int m_length; | 110 | int m_length; |
114 | QString m_fileName; | 111 | QString m_fileName; |
115 | bool disabledSuspendScreenSaver : 1; | 112 | bool disabledSuspendScreenSaver : 1; |
116 | bool hasVideoChannel : 1; | 113 | bool hasVideoChannel : 1; |
117 | bool hasAudioChannel : 1; | 114 | bool hasAudioChannel : 1; |
118 | MediaPlayerState &mediaPlayerState; | 115 | MediaPlayerState &mediaPlayerState; |
119 | XineVideoWidget *xineVideoWidget; | 116 | XineVideoWidget *xineVideoWidget; |
117 | bool m_wasError : 1; // used for chaeting on the metainfo | ||
120 | 118 | ||
121 | signals: | 119 | signals: |
122 | void positionChanged( long ); | 120 | void positionChanged( long ); |
123 | }; | 121 | }; |
124 | 122 | ||
125 | 123 | ||
126 | #endif | 124 | #endif |