Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMediaPlayer end of media behaviour
Forum Update on Monday, May 27th 2025

QMediaPlayer end of media behaviour

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 590 Views
  • 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.
  • D Offline
    D Offline
    donquibeats
    wrote on last edited by
    #1

    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.

    Thanks

    JonBJ 1 Reply Last reply
    0
    • D donquibeats

      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.

      Thanks

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @donquibeats
      Never used QMediaPlayer, but did you already get your information/idea/read https://stackoverflow.com/questions/21138824/how-to-pause-video-on-last-frame-in-qml ?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        donquibeats
        wrote on last edited by
        #3

        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."

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          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.

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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved