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. 8
      src/domain/UBGraphicsScene.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

@ -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();
}

@ -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();
}

@ -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();

Loading…
Cancel
Save