Asynchronous play() for QMediaPlayer
-
Nevermind, I figured it out...
So it seems that
setSource
reasonably expects you to actually have stopped the media beforehand. Doing so and adding a small wait works like a charm and indeed plays it asynchronously!Relevant example.
m_player->stop(); QThread::msleep(100); m_player->setSource(url); m_player->play();
-
Hi,
Which version of Qt are you using ?
On which platform ?
What kind of source are you connecting ? -
@SGaist said in Asynchronous play() for QMediaPlayer:
Isn't this thread a duplicate of this one ?
So that was kind of a different issue. That issue was trying to figure out why high-latency streams are causing long hangs. Since I've figured out why (it synchronously waits for the stream), I'm now asking separately if it's possible to do it all async.
Unfortunately it's really hard for me to replicate in a stable, repeatable environment. However I will try my best...
This was most recently seen on Qt 6.6.0 on Windows. I have yet to be able to test 6.7.0 or Linux, because replicating high-latency streams at home is a tall task. The high-latency streams come from a specialized FRC environment where there are 4Mbps bandwidth limits on everything, and everything's done through the slow mjpeg format.
-
I am wondering whether you should go one level below and maybe first test what you can do with GStreamer directly. You will have a finer control.
-
Nevermind, I figured it out...
So it seems that
setSource
reasonably expects you to actually have stopped the media beforehand. Doing so and adding a small wait works like a charm and indeed plays it asynchronously!Relevant example.
m_player->stop(); QThread::msleep(100); m_player->setSource(url); m_player->play();
-