Can't Hear the sound when using QMediaPlayer
-
Hey , first of all I'm sorry for asking this even though there're solution out there , but I can't understand the solution , I built Qt statically like months ago and when I tried to use QMediaPlayer I can't hear any sound , it gives me this note:
@defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer" @
@
bool MainWindow::PlaySong(const QString& filePath)
{
if(filePath.isEmpty())
return false;qDebug()<<"path to song is "<<filePath; QMediaPlayer* player = new QMediaPlayer; player->setMedia(QUrl("mpthreetest.mp3")); player->play(); return true;
}
@the file path wasn't working so I copied the same exact mp3 file to the project folder to check but still it isn't working.
I'm using Windows 8 64bit.
if the only solution is to build the whole library again , please direct me to audio libraries that can play any sound extension.
-
Well I downloaded the last version of Qt but still the same problem.
-
Hi,
Are you sure you built the QtMultimedia backend properly and that you are linking to it ?
Also note that you have there a memory leak there since every time your call PlaySong you create a new QMediaPlayer.
-
[quote author="SGaist" date="1415318159"]Hi,
Are you sure you built the QtMultimedia backend properly and that you are linking to it ?
Also note that you have there a memory leak there since every time your call PlaySong you create a new QMediaPlayer.
[/quote]
Hey, when I built Qt statically about 5-8 months ago I followed a post and it worked , but I think there was a library that I had to build myself I think it's QNetwork ? i'm not really sure , but as I said I downloaded the last version which is 5.3.2 and it still doesn't work.
about the linking part I'm not sure if I understand you , but I did this in the pro file:
@QT += multimedia@
About the memory leak I'm not really planning on doing this but I just had to test it "I'll be using the pointer to mediaplayer as a memeber variable in my class so I can link it to signals and slots" , also I thought when you give a parent to a class that uses subclasses of QObject then it would automatically take care of the deletion process for you.
-
You don't give any parent to player so nothing will be done. If you set a parent, indeed it will be deleted at the end of its parent life. However it generally means at the end of the application.
I have some memories about the need for the QtMultimedia plugins to be dynamic however, I don't' know if it still applies.
-
[quote author="SGaist" date="1415406195"]You don't give any parent to player so nothing will be done. If you set a parent, indeed it will be deleted at the end of its parent life. However it generally means at the end of the application.
I have some memories about the need for the QtMultimedia plugins to be dynamic however, I don't' know if it still applies.[/quote]
Well , I downloaded The newest version of Qt but it still doesn't work , is there an alternative ?
My idea is simple , I'll make a simple playlist that plays audio only and when he clicks on a song it automatically plays like any audio player out there , where there's a progress bar , pausing , stopping , starting and repeating among other simple things like speeding the audio and stuff.
-
Did you check that you don't have any error with QMediaPlayer ?
-
[quote author="SGaist" date="1415487310"]Did you check that you don't have any error with QMediaPlayer ?[/quote]
How can I check that ? All I did is write that code in my post and when I call that function it gives me the same thing in the application output it says no service found for mediaplayer.
-
Can you try with a dynamic build of Qt ?
-
[quote author="SGaist" date="1415575656"]Can you try with a dynamic build of Qt ?[/quote]
Well, isn't the downloadable version of Qt is dynamic ? I downloaded the newest but opened my old project to test it , should I start a new project or what ?
-
Which version you where using wasn't clear.
Anyway, run your application with QT_DEBUG_PLUGINS=1 That should help find the misbehaving part