Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 2 Support (Qt 5) › MediaPlayer can't play audio file

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #21693

    sAMA SAMA

    I’m trying to build a music player and have this button to play a sound:

    AppButton{
                    width: 150
                    height: 50
                    text: "Click Me!";
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenter: parent.verticalCenter
    
                    MediaPlayer {
                        id: playMusic
                        source: "E:/Breaeze/SampleAudio_0.mp3" //audio file location
                    }
                    MouseArea {
                        id: playArea
                        anchors.fill: parent
                        onPressed:  { playMusic.play() }
                    }
                }

    My audio can’t be played when I use a directory on my local PC and gives me this error:

    DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80070002 ()

    But when I use this URL instead :

    https://sample-videos.com/audio/mp3/crowd-cheering.mp3

    it works why?

    #21708

    Alex
    Felgo Team

    Hi,

    what operating system are you using? I just tried your example on Windows 10 and it works for me.

    Note that for local files, you should also add

    file:///

    as prefix, like “file:///E:/Breaeze/SampleAudio_0.mp3”.

    Please also make sure that your path is correct. If you start typing with “file:///” Qt Creator will also allow you to navigate to your file while typing.

    You can also Google for e.g. “Qt DirectShowPlayerService::doSetUrlSource: Unresolved error” to find more help.

    Cheers,
    Alex

    #24085

    Ivan

    Try to use this path: qrc:/Audio/MouseOver.mp3

    If you will use C++ then use this code to load mp3 from resources:

    m_mediaPlayer.setMedia(QUrl(“qrc:/Audio/MouseOver.mp3”));

    (do no forget do delete fromLocalFile)

Viewing 3 posts - 1 through 3 (of 3 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded