From 85c0afb0b3837e23908c0b9caf5ad56618749ee4 Mon Sep 17 00:00:00 2001 From: baydam Date: Thu, 8 Aug 2019 14:25:45 +0000 Subject: [PATCH] Temporary fix black screen at the end of the playback --- src/core/VideoImplQtMultiMedia.cpp | 17 +++++++++++------ src/core/VideoSurface.cpp | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/core/VideoImplQtMultiMedia.cpp b/src/core/VideoImplQtMultiMedia.cpp index 94f29b0..a1c3d70 100644 --- a/src/core/VideoImplQtMultiMedia.cpp +++ b/src/core/VideoImplQtMultiMedia.cpp @@ -302,16 +302,21 @@ void VideoImplQtMultiMedia::watchEndOfMedia(qint64 position) { if (_mediaPlayer->isVideoAvailable() && _rate > 0) { // If rate higher than 0 if (_mediaPlayer->state() != QMediaPlayer::PausedState) { // Check playback state - qreal frameRate = _videoSurface->surfaceFormat().frameRate(); // Current video frame rate - qint64 frameCount = _mediaPlayer->duration() / 1000 * qint64(frameRate); // Total number of frames in the video - qint64 currentFrame = position / 1000 * qint64(frameRate); // Current frame position - if (currentFrame == frameCount) { - _mediaPlayer->setPosition(0); + qreal frameRate; +#ifdef Q_OS_WIN32 + frameRate = _mediaPlayer->metaData("VideoFrameRate").toDouble(); // Current video frame rate +#else + frameRate = _videoSurface->surfaceFormat().frameRate(); // Current video frame rate +#endif + qint64 frameCount = _mediaPlayer->duration() * qint64(frameRate) / 1000; // Total number of frames in the video + qint64 currentFrame = position * qint64(frameRate) / 1000; // Current frame position + if (currentFrame == frameCount) { + _mediaPlayer->setPosition(1); + _mediaPlayer->play(); } } } - } diff --git a/src/core/VideoSurface.cpp b/src/core/VideoSurface.cpp index f3ca4bd..3cbc956 100644 --- a/src/core/VideoSurface.cpp +++ b/src/core/VideoSurface.cpp @@ -59,12 +59,12 @@ QList VideoSurface::supportedPixelFormats( { if (handleType == QAbstractVideoBuffer::NoHandle) { return QList() + << QVideoFrame::Format_ARGB32 + << QVideoFrame::Format_ARGB32_Premultiplied << QVideoFrame::Format_RGB32 << QVideoFrame::Format_RGB24 << QVideoFrame::Format_RGB565 << QVideoFrame::Format_RGB555 - << QVideoFrame::Format_ARGB32 - << QVideoFrame::Format_ARGB32_Premultiplied << QVideoFrame::Format_BGR32 << QVideoFrame::Format_BGR24 << QVideoFrame::Format_BGR565