Temporary fix black screen at the end of the playback

This commit is contained in:
baydam
2019-08-08 14:25:45 +00:00
parent 5a893f3427
commit 85c0afb0b3
2 changed files with 13 additions and 8 deletions
+11 -6
View File
@@ -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();
}
}
}
}
+2 -2
View File
@@ -59,12 +59,12 @@ QList<QVideoFrame::PixelFormat> VideoSurface::supportedPixelFormats(
{
if (handleType == QAbstractVideoBuffer::NoHandle) {
return QList<QVideoFrame::PixelFormat>()
<< 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