diff options
author | Lars Knoll <lars.knoll@qt.io> | 2021-07-28 09:55:48 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2021-07-30 09:54:16 +0200 |
commit | 82367bd22c3d6c793bf05d91b641a3356f687d5b (patch) | |
tree | 1f9a51406d197ad3f3d16a9b95c870b565bb8ce5 /tests | |
parent | a0deb18c401971b58d2581e9431c6d976d926063 (diff) |
Fix media player position handling after seeking on gstreamer
After calling setPosition() while being paused, gst_element_query_position()
can return false while the pipeline is still prerolling the new
position. So simply return the last position in that case instead
of 0.
Also moved some methods that are only used on the pipeline from
QGstElement to QGstPipeline so that we can cache the position there
without having to add data to every element.
Fixes: QTBUG-95251
Change-Id: Ice56975fcf7d519f0dd54db75103b97b025cd085
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp index acc5138d7..dcbaf5626 100644 --- a/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp +++ b/tests/auto/integration/qmediaplayerbackend/tst_qmediaplayerbackend.cpp @@ -79,6 +79,7 @@ private slots: void playFromBuffer(); void audioVideoAvailable(); void isSeekable(); + void positionAfterSeek(); private: QUrl selectVideoFile(const QStringList& mediaCandidates); @@ -1122,6 +1123,29 @@ void tst_QMediaPlayerBackend::isSeekable() QTRY_VERIFY(player.isSeekable()); } +void tst_QMediaPlayerBackend::positionAfterSeek() +{ + if (localVideoFile.isEmpty()) + QSKIP("No supported video file"); + + TestVideoSink surface(false); + QMediaPlayer player; + player.setVideoOutput(&surface); + QVERIFY(!player.isSeekable()); + player.setSource(localVideoFile); + player.pause(); + player.setPosition(500); + QTRY_VERIFY(player.position() == 500); + player.setPosition(700); + QVERIFY(player.position() != 0); + QTRY_VERIFY(player.position() == 700); + player.play(); + QTRY_VERIFY(player.position() > 700); + player.setPosition(200); + QVERIFY(player.position() != 0); + QTRY_VERIFY(player.position() < 700); +} + QTEST_MAIN(tst_QMediaPlayerBackend) #include "tst_qmediaplayerbackend.moc" |