Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Able to rotate a rectangle but not a video (solved)
QtWS25 Last Chance

Able to rotate a rectangle but not a video (solved)

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 5 Posters 1.5k 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.
  • H Offline
    H Offline
    houmingc
    wrote on last edited by
    #1

    I am able to rotate a rectangle but i am not able to rotate a video
    Below is my code. Can explain what is wrong with my code.
    @.....................................................................................................
    import QtQuick 2.2
    import QtQuick.Window 2.1

    Window {
    visible:true
    width:760
    height:700
    Item {
    width 300; height:300
    Rectangle{
    id: rect
    width:150;height:100;anchors.centerln:parent
    color:"red"
    smooth:true
    states:State{
    name:"rotated"
    PropertyChanges{target:rect; rotation:180}
    }
    transitions:Transition{
    RotationAnimation{duration:3000; direction:RotationAnimation.Numerical}
    }
    }
    MouseArea {anchors.fill:parent; onClicked: rect.state="rotated"}
    }
    }

    Below is the code i use to rotate video

    import QtQuick 2.2
    import QtQuick.Window 2.2
    import QtMultimedia 5.0

    Window {
    visible:true
    width:760
    height:700

      Item {
         width:300; height:300
          MediaPlayer{
           id:player_1
           source:"file:///xxx.mp4"
           autoPlay:true
           autoLoad:true
           muted:false
       }
       VideoOutput{
        id:voutput_1
        source:player_1
        fillMode:VideoOutput.PreserveAspectFit
        x:0
        y:0
        height: parent.height
        width:parent.width/2
     }
        states:State{
                   name: "rotated"
                   PropertyChanges{ target:player_1;rotation:180)
                  }
             transitions:Transition{
                    RotationAnimation{duration:3000; direction:RotationAnimation.Numerical}
                    }
          }  MouseArea {anchors.fill:parent; onClicked:player_1.state="rotated"}
    

    }

    @

    P 1 Reply Last reply
    0
    • M Offline
      M Offline
      mcm_qt
      wrote on last edited by
      #2

      Rect and Item will behave different as I know. Try a video item in a Rect with anchor.fillparent(), and then rotate the Rect?

      1 Reply Last reply
      0
      • GianlucaG Offline
        GianlucaG Offline
        Gianluca
        wrote on last edited by
        #3

        Your are rotating the wrong Item.

        player_1 is a MediaPlayer, a non visual item that just decode the video and audio from a source.
        While, voutput_1 is a real visual item that render the decoded frames and audio into the screen.
        So, you should rotate the voutput_1, while in your code your are trying to rotate the player_1

        P.S.: Pay attention, on some platform the VideoOutput has strong limitation (on iOS for example)

        1 Reply Last reply
        0
        • timdayT Offline
          timdayT Offline
          timday
          wrote on last edited by
          #4

          Interesting; are limitations on VideoOutput on iOS documented anywhere? (Anywhere friendly to people bringing Qt apps to iOS who don't know a whole lot about iOS and just expect stuff that works in Qt on desktop platforms to work on iOS too that is). Or just a matter of prodding it and seeing what works?

          1 Reply Last reply
          0
          • GianlucaG Offline
            GianlucaG Offline
            Gianluca
            wrote on last edited by
            #5

            The limitation is written into the documentation ... but they don't explicit tell on which platform:
            [quote]
            The VideoOutput item works with backends that support either QVideoRendererControl or QVideoWindowControl. If the backend only supports QVideoWindowControl, the video is rendered onto an overlay window that is layered on top of the QtQuick window. Due to the nature of the video overlays, certain features are not available for these kind of backends:

            Some transformations like rotations
            Having other QtQuick items on top of the VideoOutput item
            Most backends however do support QVideoRendererControl and therefore don't have the limitations listed above.[/quote]

            Actually, it seems that only iOS had this limitation.

            1 Reply Last reply
            0
            • timdayT Offline
              timdayT Offline
              timday
              wrote on last edited by
              #6

              Ah thanks that's good to know; I was toying with taking my app down a route where I wanted to do clever stuff with texture mapping video, using it as shader sources etc. Some of the behaviour I was seeing with ordinary VideoOutput on iOS was already making me think it was probably an overlay rather than anything more integrated though.

              1 Reply Last reply
              0
              • H houmingc

                I am able to rotate a rectangle but i am not able to rotate a video
                Below is my code. Can explain what is wrong with my code.
                @.....................................................................................................
                import QtQuick 2.2
                import QtQuick.Window 2.1

                Window {
                visible:true
                width:760
                height:700
                Item {
                width 300; height:300
                Rectangle{
                id: rect
                width:150;height:100;anchors.centerln:parent
                color:"red"
                smooth:true
                states:State{
                name:"rotated"
                PropertyChanges{target:rect; rotation:180}
                }
                transitions:Transition{
                RotationAnimation{duration:3000; direction:RotationAnimation.Numerical}
                }
                }
                MouseArea {anchors.fill:parent; onClicked: rect.state="rotated"}
                }
                }

                Below is the code i use to rotate video

                import QtQuick 2.2
                import QtQuick.Window 2.2
                import QtMultimedia 5.0

                Window {
                visible:true
                width:760
                height:700

                  Item {
                     width:300; height:300
                      MediaPlayer{
                       id:player_1
                       source:"file:///xxx.mp4"
                       autoPlay:true
                       autoLoad:true
                       muted:false
                   }
                   VideoOutput{
                    id:voutput_1
                    source:player_1
                    fillMode:VideoOutput.PreserveAspectFit
                    x:0
                    y:0
                    height: parent.height
                    width:parent.width/2
                 }
                    states:State{
                               name: "rotated"
                               PropertyChanges{ target:player_1;rotation:180)
                              }
                         transitions:Transition{
                                RotationAnimation{duration:3000; direction:RotationAnimation.Numerical}
                                }
                      }  MouseArea {anchors.fill:parent; onClicked:player_1.state="rotated"}
                

                }

                @

                P Offline
                P Offline
                pressurehold
                wrote on last edited by
                #7
                This post is deleted!
                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