#ifdef APP_SNAPSHOT
, snapshotSettings(0)
#endif
+ , pauseTime(0)
{ }
void MediaView::initialize() {
#ifdef APP_PHONON
void MediaView::stateChanged(Phonon::State newState, Phonon::State /*oldState*/) {
- if (newState == Phonon::PlayingState)
+ if (pauseTime > 0 && (newState == Phonon::PlayingState || newState == Phonon::BufferingState)) {
+ mediaObject->seek(pauseTime);
+ pauseTime = 0;
+ }
+ if (newState == Phonon::PlayingState) {
videoAreaWidget->showVideo();
- else if (newState == Phonon::ErrorState) {
+ } else if (newState == Phonon::ErrorState) {
qWarning() << "Phonon error:" << mediaObject->errorString() << mediaObject->errorType();
if (mediaObject->errorType() == Phonon::FatalError)
handleError(mediaObject->errorString());
switch( mediaObject->state() ) {
case Phonon::PlayingState:
mediaObject->pause();
+ pauseTimer.start();
break;
default:
- mediaObject->play();
+ if (pauseTimer.hasExpired(60000)) {
+ pauseTimer.invalidate();
+ connect(playlistModel->activeVideo(), SIGNAL(gotStreamUrl(QUrl)), SLOT(resumeWithNewStreamUrl(QUrl)));
+ playlistModel->activeVideo()->loadStreamUrl();
+ } else mediaObject->play();
break;
}
#endif
downloadItem->start();
}
+void MediaView::resumeWithNewStreamUrl(const QUrl &streamUrl) {
+ pauseTime = mediaObject->currentTime();
+ mediaObject->setCurrentSource(streamUrl);
+ mediaObject->play();
+
+ Video *video = static_cast<Video *>(sender());
+ if (!video) {
+ qDebug() << "Cannot get sender in" << __PRETTY_FUNCTION__;
+ return;
+ }
+ video->disconnect(this);
+}
+
void MediaView::maybeAdjustWindowSize() {
QSettings settings;
if (settings.value("adjustWindowSize", true).toBool())
void sliderMoved(int value);
qint64 offsetToTime(qint64 offset);
void startDownloading();
+ void resumeWithNewStreamUrl(const QUrl &streamUrl);
private:
MediaView(QWidget *parent = 0);
#ifdef APP_SNAPSHOT
SnapshotSettings *snapshotSettings;
#endif
+
+ QElapsedTimer pauseTimer;
+ qint64 pauseTime;
};
#endif // __MEDIAVIEW_H__