Important: Please read the Qt Code of Conduct -

QMediaPlayer end of media behaviour

  • Hello

    Is there a way to configure a QMediaPlayer so that when the end of a video file is reached, it pauses at the end, instead of jumping back to the start?

    Currently I am connecting to the mediaStatusChanged() event and setting the position back to one frame less than the duration when the status is QMediaPlayer.EndOfMedia.

    However the problem with that is that other events are happening in the meantime- positionChanged() is triggered with a position 0 which causes other events in my program to fire when they shouldn't. Also, the user is being shown the first frame of the video while the position gets re-set to the end.

    Is there a neater way to persuade a QMediaPlayer object to pause on the last frame, rather than loop back? Like Quicktime Player, Adobe Premiere, and other media players do?

    I'm currently on Qt 5.14.2 but could change version if it helped.


  • @donquibeats
    Never used QMediaPlayer, but did you already get your information/idea/read ?

  • Thanks for the link, and I hadn't seen that, but unfortunately those users are essentially doing the same workarounds as I've tried in PyQt5, and the results are less than perfect.

    My application needs frame accuracy, so stopping video 100ms or more before the end is unfortunately not accurate enough.

    As user timday says on that StackOverflow page: "An option to the MediaPlayer or VideoOutput element types to freeze on the last frame would indeed be much simpler."

  • Lifetime Qt Champion


    The "issue" with tools like Adobe Premiere is that they are professional tools with their own rendering pipeline not necessarily using platform generic multimedia APIs. You might be able to achieve what you want on some of the platforms but would have to fiddle with the lower levels of the platform plugins to access the platform specific objects.

    You may want to consider using VLC, it could provided greater flexibility for your use case. It also has binding for Qt.

Log in to reply