From e2e8186e1e17bd91a65f33eebc66d93599daa649 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Kundr=C3=A1t?= Date: Mon, 6 Oct 2008 03:21:56 +0200 Subject: [PATCH] experimental: try to skip file that fails to play --- src/core/PlayerWindow.cpp | 19 +++++++++++++++++++ src/core/PlayerWindow.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/core/PlayerWindow.cpp b/src/core/PlayerWindow.cpp index 1a70dd6..cec7a3c 100644 --- a/src/core/PlayerWindow.cpp +++ b/src/core/PlayerWindow.cpp @@ -112,6 +112,7 @@ namespace Jerboa void PlayerWindow::playlistRowsInserted(const QModelIndex& parent, int start, int end) { + mFirstErrorIndex = QModelIndex(); if ( mMediaObject->state() != Phonon::PlayingState ) { mPlaylistModel->setCurrentItem(mPlaylistModel->index(start, 0)); @@ -456,6 +457,24 @@ namespace Jerboa mPlaylistView->scrollTo(mPlaylistModel->currentItem(), QAbstractItemView::PositionAtTop); if ( td.isValid() ) emit playbackStarted(td, mMediaObject->totalTime()); + mFirstErrorIndex = QModelIndex(); + break; + case Phonon::ErrorState: + if (mFirstErrorIndex == QModelIndex()) + { + mFirstErrorIndex = mPlaylistModel->currentItem(); + nextTriggered(); + updateControls(); + } + else if (mFirstErrorIndex == mPlaylistModel->currentItem()) + { + QMessageBox::warning(this, tr("Playback Failed"), tr("Unable to play any media files")); + } + else + { + nextTriggered(); + updateControls(); + } break; default: // nop nop nop diff --git a/src/core/PlayerWindow.h b/src/core/PlayerWindow.h index 6146be2..61aeca4 100644 --- a/src/core/PlayerWindow.h +++ b/src/core/PlayerWindow.h @@ -21,6 +21,7 @@ #include "Types.h" #include +#include #include #include #include @@ -135,6 +136,7 @@ namespace Jerboa Phonon::AudioOutput* mAudioOutput; Phonon::MediaObject* mMediaObject; TagResolver* mCollectionLoader; + QModelIndex mFirstErrorIndex; // UI stuff Phonon::SeekSlider *mSeekSlider; -- 2.11.4.GIT