diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index c28da1c6..8dc1ef08 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -677,10 +677,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() mScene->addItem(videoItem); videoItem->show(); - - //force start to load the video and display the first frame - videoItem->play(); - videoItem->pause(); } } else if (mXmlReader.name() == "text")//This is for backward compatibility with proto text field prior to version 4.3 diff --git a/src/domain/UBGraphicsMediaItem.cpp b/src/domain/UBGraphicsMediaItem.cpp index 4836886a..0ad9e810 100644 --- a/src/domain/UBGraphicsMediaItem.cpp +++ b/src/domain/UBGraphicsMediaItem.cpp @@ -500,22 +500,21 @@ void UBGraphicsVideoItem::setSize(int width, int height) void UBGraphicsVideoItem::videoSizeChanged(QSizeF newSize) { - /* Depending on the platform, video size information becomes available - * at different times (either when the file is loaded, or when playback - * begins), so this slot is needed to resize the video item as soon as - * the information is available. + /* Depending on the platform/video backend, video size information becomes + * available at different times (either when the file is loaded, or when + * playback begins), so this slot is needed to resize the video item as + * soon as the information is available. */ - // Don't resize the video item when playback has finished - bool shouldResize = (mMediaObject->mediaStatus() != QMediaPlayer::EndOfMedia); - #ifdef Q_OS_WIN - // Windows is a little confused about when a video ends - shouldResize = (mMediaObject->mediaStatus() != QMediaPlayer::BufferedMedia); - #endif + // We don't want the video item to resize when the video is stopped or finished; + // and in those cases, the new size is reported as (0, 0). - if (shouldResize) + if (newSize != QSizeF(0,0)) this->setSize(newSize.width(), newSize.height()); + + else // Make sure the toolbar doesn't disappear + Delegate()->showToolBar(); } diff --git a/src/domain/UBGraphicsMediaItemDelegate.cpp b/src/domain/UBGraphicsMediaItemDelegate.cpp index 7a6061d5..78072128 100644 --- a/src/domain/UBGraphicsMediaItemDelegate.cpp +++ b/src/domain/UBGraphicsMediaItemDelegate.cpp @@ -231,9 +231,19 @@ void UBGraphicsMediaItemDelegate::mediaStatusChanged(QMediaPlayer::MediaStatus s // Possible statuses are: UnknownMediaStatus, NoMedia, LoadingMedia, LoadedMedia, // StalledMedia, BufferingMedia, BufferedMedia, EndOfMedia, InvalidMedia + //qDebug() << "Media status changed to " << status << "; state: " << delegated()->playerState(); + if (status == QMediaPlayer::LoadedMedia) mMediaControl->totalTimeChanged(delegated()->mediaDuration()); + // At the beginning of the video, play/pause to load and display the first frame + if ((status == QMediaPlayer::LoadedMedia || status == QMediaPlayer::BufferedMedia) + && delegated()->mediaPosition() == delegated()->initialPos()) { + delegated()->play(); + delegated()->pause(); + } + + // in most cases, the only necessary action is to update the play/pause state updatePlayPauseState(); } diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 5d86a2d0..deefd024 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -1368,12 +1368,8 @@ UBGraphicsMediaItem* UBGraphicsScene::addMedia(const QUrl& pMediaFileUrl, bool s UBApplication::undoStack->push(uc); } - mediaItem->play(); - - if (!shouldPlayAsap) { - mediaItem->pause(); - mediaItem->setMediaPos(0); - } + if (shouldPlayAsap) + mediaItem->play(); setDocumentUpdated();