QMediaPlayer Documentation is wrong, or am I ?



  • 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 ?


  • Lifetime Qt Champion

    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.



  • @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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.