Video item: don't resize when video has finished or been stopped

+ clean-up in a few places
preferencesAboutTextFull
Craig Watson 9 years ago
parent 09c0649792
commit 14700278c3
  1. 4
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 21
      src/domain/UBGraphicsMediaItem.cpp
  3. 10
      src/domain/UBGraphicsMediaItemDelegate.cpp
  4. 6
      src/domain/UBGraphicsScene.cpp

@ -677,10 +677,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
mScene->addItem(videoItem); mScene->addItem(videoItem);
videoItem->show(); 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 else if (mXmlReader.name() == "text")//This is for backward compatibility with proto text field prior to version 4.3

@ -500,22 +500,21 @@ void UBGraphicsVideoItem::setSize(int width, int height)
void UBGraphicsVideoItem::videoSizeChanged(QSizeF newSize) void UBGraphicsVideoItem::videoSizeChanged(QSizeF newSize)
{ {
/* Depending on the platform, video size information becomes available /* Depending on the platform/video backend, video size information becomes
* at different times (either when the file is loaded, or when playback * available at different times (either when the file is loaded, or when
* begins), so this slot is needed to resize the video item as soon as * playback begins), so this slot is needed to resize the video item as
* the information is available. * 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 // We don't want the video item to resize when the video is stopped or finished;
// Windows is a little confused about when a video ends // and in those cases, the new size is reported as (0, 0).
shouldResize = (mMediaObject->mediaStatus() != QMediaPlayer::BufferedMedia);
#endif
if (shouldResize) if (newSize != QSizeF(0,0))
this->setSize(newSize.width(), newSize.height()); this->setSize(newSize.width(), newSize.height());
else // Make sure the toolbar doesn't disappear
Delegate()->showToolBar();
} }

@ -231,9 +231,19 @@ void UBGraphicsMediaItemDelegate::mediaStatusChanged(QMediaPlayer::MediaStatus s
// Possible statuses are: UnknownMediaStatus, NoMedia, LoadingMedia, LoadedMedia, // Possible statuses are: UnknownMediaStatus, NoMedia, LoadingMedia, LoadedMedia,
// StalledMedia, BufferingMedia, BufferedMedia, EndOfMedia, InvalidMedia // StalledMedia, BufferingMedia, BufferedMedia, EndOfMedia, InvalidMedia
//qDebug() << "Media status changed to " << status << "; state: " << delegated()->playerState();
if (status == QMediaPlayer::LoadedMedia) if (status == QMediaPlayer::LoadedMedia)
mMediaControl->totalTimeChanged(delegated()->mediaDuration()); 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 // in most cases, the only necessary action is to update the play/pause state
updatePlayPauseState(); updatePlayPauseState();
} }

@ -1368,13 +1368,9 @@ UBGraphicsMediaItem* UBGraphicsScene::addMedia(const QUrl& pMediaFileUrl, bool s
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
} }
if (shouldPlayAsap)
mediaItem->play(); mediaItem->play();
if (!shouldPlayAsap) {
mediaItem->pause();
mediaItem->setMediaPos(0);
}
setDocumentUpdated(); setDocumentUpdated();
return mediaItem; return mediaItem;

Loading…
Cancel
Save