Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QMediaPlayer Documentation is wrong, or am I ?

    General and Desktop
    2
    3
    730
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      ghidx0 last edited by

      I was hoping that someone here could check my thinking. As far as I can tell, the Docs for QMediaPlayer appear to have a typo at the first example under details

      player = new QMediaPlayer;
      connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
      player->setMedia(QUrl::fromLocalFile("/Users/me/Music/coolsong.mp3")); # <- Here's the error
      player->setVolume(50);
      player->play();
      

      player->setMedia appears to have the following signature: void setMedia(const QMediaContent &media, QIODevice *stream = Q_NULLPTR) while QUrl::fromLocalFile returns a QUrl

      I'm new to Qt, so, I don't want to run off half-cocked and report an issue. I'll do so, but am I seeing this right ?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        Nothing to do with Qt.

        See the second constructor of QMediaContent. It takes a QUrl so basically what happens is that you have a QMediaContent automatically created from the QUrl.

        See converting constructor for more information.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        G 1 Reply Last reply Reply Quote 1
        • G
          ghidx0 @SGaist last edited by

          @SGaist Thanks, that clears that up for me. I didn't ask about it, to keep the question concise, but now I see how this complicates translating the example into the PyQt5 bindings, which is what I'm working through. So this explains why a c++ application could successfully mimic that example, but a PyQt5 binding application could not. Excellent answer, thanks again for the help.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post