Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Video onSourceChanged
Qt 6.12 LTS is out! See what's new in the release blog

QML Video onSourceChanged

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 814 Views 1 Watching
  • 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.
  • NihilishN Offline
    NihilishN Offline
    Nihilish
    wrote on last edited by Nihilish
    #1

    Hi,

    I'm running a Video component as a view's background. I have 4 different video files for 4 different device types/screen aspect ratios. Tablet_Landscape, Tablet_Portrait, Phone_Landscape and Phone_Portrait.

    I'm creating a binding on the orientation to switch between the Landscape and Portrait videos for the source but I noticed that when changing the orientation the video just disappears. I do get an onSourceChanged event but the new video is not actually loaded. I've looked through the documentation and there's nothing about this. Is there something I should call to load the new source onSourceChanged and start playback or is that simply a limitation of the Video component? There's a workaround with Loaders or possibly Playlists, but I'd rather just use a Source binding as it's just more elegant.

    My code:

    Video {
            id: requirementsScreenId
    
            anchors.fill: root
    
            source: {
                if (isPhone())
                {
                    if (orientation === "landscape")
                        return "qrc:/Images/Phone_Landscape.mp4"
                    else
                        return "qrc:/Images/Phone_Portrait.mp4"
                }
                else
                {
                    if (orientation === "landscape")
                        return "qrc:/Images/Tablet_Landscape.mp4"
                    else
                        return "qrc:/Images/Tablet_Portrait.mp4"
                }
            }
    
            autoPlay: true
            loops: MediaPlayer.Infinite
            muted: true
            fillMode: VideoOutput.PreserveAspectCrop
    }
    
    fcarneyF 1 Reply Last reply
    0
    • NihilishN Nihilish

      Hi,

      I'm running a Video component as a view's background. I have 4 different video files for 4 different device types/screen aspect ratios. Tablet_Landscape, Tablet_Portrait, Phone_Landscape and Phone_Portrait.

      I'm creating a binding on the orientation to switch between the Landscape and Portrait videos for the source but I noticed that when changing the orientation the video just disappears. I do get an onSourceChanged event but the new video is not actually loaded. I've looked through the documentation and there's nothing about this. Is there something I should call to load the new source onSourceChanged and start playback or is that simply a limitation of the Video component? There's a workaround with Loaders or possibly Playlists, but I'd rather just use a Source binding as it's just more elegant.

      My code:

      Video {
              id: requirementsScreenId
      
              anchors.fill: root
      
              source: {
                  if (isPhone())
                  {
                      if (orientation === "landscape")
                          return "qrc:/Images/Phone_Landscape.mp4"
                      else
                          return "qrc:/Images/Phone_Portrait.mp4"
                  }
                  else
                  {
                      if (orientation === "landscape")
                          return "qrc:/Images/Tablet_Landscape.mp4"
                      else
                          return "qrc:/Images/Tablet_Portrait.mp4"
                  }
              }
      
              autoPlay: true
              loops: MediaPlayer.Infinite
              muted: true
              fillMode: VideoOutput.PreserveAspectCrop
      }
      
      fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by fcarney
      #2

      @Nihilish check the status of the Video Item:
      https://doc.qt.io/qt-5/qml-qtmultimedia-video.html#status-prop

      I think your paths are wrong. We only ever quality our paths with qrc in our C++ code. Not in our qml code. So you most likely have an error.

      Edit: I did my grep wrong. We are qualifying some paths in QML with qrc. Now I am confused why we have a mix.

      C++ is a perfectly valid school of magic.

      NihilishN 1 Reply Last reply
      0
      • fcarneyF fcarney

        @Nihilish check the status of the Video Item:
        https://doc.qt.io/qt-5/qml-qtmultimedia-video.html#status-prop

        I think your paths are wrong. We only ever quality our paths with qrc in our C++ code. Not in our qml code. So you most likely have an error.

        Edit: I did my grep wrong. We are qualifying some paths in QML with qrc. Now I am confused why we have a mix.

        NihilishN Offline
        NihilishN Offline
        Nihilish
        wrote on last edited by
        #3

        @fcarney I just checked. When the video is working (before the orientation change) the status is "Buffered" and after the orientation change the status seems to be stuck in "Loading"

        1 Reply Last reply
        0
        • NihilishN Offline
          NihilishN Offline
          Nihilish
          wrote on last edited by
          #4

          When the source changes I'm also getting a I GPUAUX : [AUX]~GPUAUXContext:71: destory: 0xcf240f68 debug message

          1 Reply Last reply
          0
          • NihilishN Offline
            NihilishN Offline
            Nihilish
            wrote on last edited by Nihilish
            #5

            This is on Android by the way, I'll check to see if it happens on iOS too

            EDIT: Yeah, just on Android. It definitely sounds like an Android bug.

            1 Reply Last reply
            1

            • Login

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