Important: Please read the Qt Code of Conduct -

QMediaPlayer playback rate

  • I read:

    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.
    PlayerControls::setPlaybackRate(qreal PlayerControls::playbackRate())

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

    Thank so much.

  • 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