QMediaPlayer playback rate



  • I read: http://doc.qt.io/qt-5/qtmultimedia-multimediawidgets-player-example.html

    In files: playercontrols.cpp and playercontrols.h
    Qt define:
    void PlayerControls::setPlaybackRate(float rate) to set playback rate.
    I want to confirm: rate parameter is corresponding:
    qreal PlayerControls::playbackRate() const
    Values return from: qreal PlayerControls::playbackRate() const will be set for current playback rate.
    Mean:
    PlayerControls::setPlaybackRate(qreal PlayerControls::playbackRate())

    Is this correct ? If not, could you please explain in advance for set playback rate.

    Thank so much.


  • administrators

    Hi @Hung-Tran
    Yes, when you change the playback rate in the controls, this signal/slot pair happens:

     connect(rateBox, SIGNAL(activated(int)), SLOT(updateRate()));
    

    and that emits another signal:

    void PlayerControls::updateRate()
    {
        emit changeRate(playbackRate());
    }
    

    And that goes to player.cpp here:

    connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal)));
    

    And that changes the playback rate.

    It is all done with signals and slots. I hope that helps.



  • @tekojo WoW. I miss

    connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal)));
    

    so I have misunderstand. Thank so much. I got this Idea


Log in to reply
 

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