QMediaPlayer won't play music anymore
-
Hello, I've been writing an audio player using QT for a while, when suddenly QMediaPlayer stopped to play any kind of music files.
I believe, it could be an update, that ruined my project. Current version of qt i'm using is 5.7.0-1. QtCreator version is 4.0.2-1.
Project is compiled via qmake withQT += core gui multimedia
I'm trying to push, for example, following button:
void MainWindow::on_pushButton_clicked() { playlist->clear(); playlist->addMedia(QUrl::fromLocalFile("/home/pchyolki/Music/vk/hiphop/d8bd63191367.mp3")); plr->play(); }
Where plr is an object of QMediaPlayer class and playlist is QMediaPlaylist.
Nothing happens.
My text labels, used to get track's duration and current position in seconds show 0:00 / 0:00.All I get in app's output is a following warning:
QObject::startTimer: Timers can only be used with threads started with QThread
but I'm not using any timers anywhere.
I haven't seen this warning before player stopped working correctly.
Perhaps there are some internal timers in QMediaPlayer class or smth.
Anyway, the main feature of my project is now broken and I have no idea what happened though.
Maybe here I could get some help?
Thanks in advance! -
@pchyolki
are you sure the multimedia backend plugins are loaded correctly?
And if yes you have the correct filters/codecs installed? -
@raven-worx Thanks for a reply!
qt5-multimedia package is installed in my system. It was updated with bunch of other qt5-related packages.
All the gstreamer modules are installed as well.
I see no error output, when run qtcreator from terminal and then run my qt application from it...
No errors anywhere.
Is there's a way to check if modules are loaded when app starts?
And can you tell me anything about this timers warning? -
Try to run your application with QT_DEBUG_PLUGINS=1, see http://doc.qt.io/qt-5/debug.html
Maybe you have gstreamer 0.10, as far as I know Qt now requires 1.0 (but I'm not sure). -
@pchyolki said:
Is there's a way to check if modules are loaded when app starts?
errors won't be generated for most plugins. You can use QT_DEBUG_PLUGINS (set to a non-zero value) env variable and if the corresponding plugin is loaded - in the console.
Also you can check the QMediaPlayer's error()/errorString() methods. Maybe those give some hints.And can you tell me anything about this timers warning?
No not really. This can be triggered from anywhere in your code. Easiest would be to set a breakpoint in the Qt sources at the position this message is written.
-
@raven-worx Enabling debug gave me a lot of output, but not a single error.
Timer warning message is not attached to any string in the code, it just appears at once after I run my project.@jsulm I'm using gstreamer0.10 for sure and there is no gstreamer 1.0 available in my distro's repos (arch linux).
Do you think I need to build my own gstreamer from sources?
Thanks! -
@pchyolki said:
Enabling debug gave me a lot of output, but not a single error.
it's not supposed to give an error. In the output you can check if the multimedia plugin is loaded or not. Look out for plugins loaded from the "mediaservice" folder.
Timer warning message is not attached to any string in the code, it just appears at once after I run my project.
as the message already says, i would take a look into QObject::startTimer()
@jsulm said:
Maybe you have gstreamer 0.10, as far as I know Qt now requires 1.0 (but I'm not sure).
The QtMultimedia requirements explicitly state that gstreamer 0.10 is supported.
-
@raven-worx
There are many libraries loaded, upon them presents the following one:loaded library "/usr/lib/qt/plugins/mediaservice/libgstmediaplayer.so"
I've found out that I currently have two versions of gstreamer installed.
Some apps in my system requires package named gstreamer0.10 (version 0.10.36-4) and plugins named like gstreamer0.10-{base,good,bad,ugly}, but some requires just gstreamer (version 1.8.2-1) and plugins named like gst-plugins-{base,good,bad,ugly}package qt5-multimedia depends on:
Depends On : qt5-base gst-plugins-base-libs libpulse openal
I've never had problems with that before.
I've tried to completely remove one version regardless on depends and then start qtcreator - no success.
Removing another version didn't solve the problem either, I've just started to run into different errors on qtcreator's startup and while app was running.
Now I'm where it all started, still unable to play any sound.
Can someone reproduce my issue with QT version 5.7, gstreamer and qtcreator?PS: As I've already said, I have no timers in any .cpp or .h files.
No QObject::startTimer() at all!
That's why this message confuses me so much. -
@pchyolki said:
PS: As I've already said, I have no timers in any .cpp or .h files.
No QObject::startTimer() at all!
That's why this message confuses me so much.of course it doesn't mean that you explicitly call this method.
You should set a breakpoint on the warning in this method and when it gets hit you check the stack-trace to see where it comes from. -
@raven-worx please, teach me, how to set a breakpoint on method, when I don't know what method is it!
Here's a screenshot of qtcreator's main window.
Thanks.