Video element plays video at wrong position on IOS



  • I want to write a video player for IOS, when I put a video element and set the media source, it plays very well except for that, the video surface is on the top left, not the position I put the video element. I have used a Rectangle to test the Video element is at the right Position.

    Is this a bug?



  • Hi,

    did you solved this issue? I have exactly the same problem - except that I am on an embedded ARM machine running Yocto/Poly Linux.



  • Hi,

    did you solved this issue? I have exactly the same problem - except that I am on an embedded ARM machine running Yocto/Poly Linux.



  • Hey,

    could you please provide us the video-component code you are using in your QML file?



  • Hey,

    could you please provide us the video-component code you are using in your QML file?



  • Hi,

    I am not using QML. Here are the important code snippets:
    @MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    player =  new QMediaPlayer;
    player->setVideoOutput(ui->videoWidget);
    ui->videoWidget->show();
    

    }

    void MainWindow::onActionOpen()
    {
    QString file = QFileDialog::getOpenFileName(this, tr("Open Video File"), ".");
    if(file.isEmpty())
    return;

    player->setMedia(QUrl::fromLocalFile(file));
    player->setVolume(50);
    player->play();
    

    }@

    ui->videoWidget is of type QVideoWidget
    On my Ubuntu 14.04 64bit host everything works fine. Qt is version 4.8.6 for host and 4.8.5 for target. QtMobility is 1.2.0 for both.



  • Hi,

    I am not using QML. Here are the important code snippets:
    @MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    player =  new QMediaPlayer;
    player->setVideoOutput(ui->videoWidget);
    ui->videoWidget->show();
    

    }

    void MainWindow::onActionOpen()
    {
    QString file = QFileDialog::getOpenFileName(this, tr("Open Video File"), ".");
    if(file.isEmpty())
    return;

    player->setMedia(QUrl::fromLocalFile(file));
    player->setVolume(50);
    player->play();
    

    }@

    ui->videoWidget is of type QVideoWidget
    On my Ubuntu 14.04 64bit host everything works fine. Qt is version 4.8.6 for host and 4.8.5 for target. QtMobility is 1.2.0 for both.



  • -Oh okay, your thread is in the QtQuick(QML)-section so i thought you did it with QML-. Well, how do you position your MediaPlayer?

    My bad, this thread is a few months old and you are not OP. Still, i will try to help you trough your problem even if i haven't worked with the QMediaPlayer so far.



  • -Oh okay, your thread is in the QtQuick(QML)-section so i thought you did it with QML-. Well, how do you position your MediaPlayer?

    My bad, this thread is a few months old and you are not OP. Still, i will try to help you trough your problem even if i haven't worked with the QMediaPlayer so far.



  • I have an UI file where I have a few buttons and also the QVideoWidget using Layouts.



  • I have an UI file where I have a few buttons and also the QVideoWidget using Layouts.



  • Have you tried to re-position your videoWidget after you started playing a video?



  • Have you tried to re-position your videoWidget after you started playing a video?



  • How am I supposed to do that? The Widget is part of a layout. setGeometry() has no effect.



  • How am I supposed to do that? The Widget is part of a layout. setGeometry() has no effect.



  • Sorry, my bad, haven't read the layouts part. Well, in that case: Have you tried positioning it without a layout? Does that work? And have you tried playing with the horizontal and vertical settings of the widget?



  • Sorry, my bad, haven't read the layouts part. Well, in that case: Have you tried positioning it without a layout? Does that work? And have you tried playing with the horizontal and vertical settings of the widget?



  • See "QTBUG-42721":https://bugreports.qt-project.org/browse/QTBUG-42721

    I raised this as an issue with iOS video placement (using the QML VideoOutput, but it presumably sits on the same underlying code as the C++ ) a week or so ago which sounds like it's the same as hailong's problem. If it helps identify it's the same thing:

    • It came in with Qt5.3.2; I never saw the problem on 5.3.1.
    • If you rotate the device while the video is playing, it'll move to where you expect it to! (At least until the video ends; if you have it set up to loop, it might move back to the top corner again).


  • See "QTBUG-42721":https://bugreports.qt-project.org/browse/QTBUG-42721

    I raised this as an issue with iOS video placement (using the QML VideoOutput, but it presumably sits on the same underlying code as the C++ ) a week or so ago which sounds like it's the same as hailong's problem. If it helps identify it's the same thing:

    • It came in with Qt5.3.2; I never saw the problem on 5.3.1.
    • If you rotate the device while the video is playing, it'll move to where you expect it to! (At least until the video ends; if you have it set up to loop, it might move back to the top corner again).


  • Well, then I guess it is not the same problem as I am using Qt 4.8.5.



  • Well, then I guess it is not the same problem as I am using Qt 4.8.5.



  • At least in my case it seems to be a problem of gsteramer and not Qt. I was able to reproduce the problem using gst-launch:
    @# gst-launch -v videotestsrc ! xvimagesink@
    When I use ximagesink it works perfectly fine.



  • At least in my case it seems to be a problem of gsteramer and not Qt. I was able to reproduce the problem using gst-launch:
    @# gst-launch -v videotestsrc ! xvimagesink@
    When I use ximagesink it works perfectly fine.



  • wow, so many replies on my thread, I feel so happy that more and more people are using Qt for cross-platform app development.

    I could't not solve my problem on September even if I had done a lot of research on that, so I used one week to learn how to develop for IOS and rewrited the hole app using Obj-C.



  • wow, so many replies on my thread, I feel so happy that more and more people are using Qt for cross-platform app development.

    I could't not solve my problem on September even if I had done a lot of research on that, so I used one week to learn how to develop for IOS and rewrited the hole app using Obj-C.



  • :P
    I already tracked it down to a problem in X server or the kernel.
    I know that it is caused by a change in the X server but I don't know which change and if this change is ok for newer kernels.



  • :P
    I already tracked it down to a problem in X server or the kernel.
    I know that it is caused by a change in the X server but I don't know which change and if this change is ok for newer kernels.



  • I too have this problem. My UI code is all QML and is super simple. I have a video component

        Video {
            id: myVideo
            anchors.fill: parent
            anchors.margins: 10
            source: mediaFolder.fileUrl(filesList[mediaIndex])
        }
    

    and a button.

        Rectangle {
            id: start
            anchors.right: parent.right
            anchors.verticalCenter: parent.verticalCenter
            anchors.margins: 20
            width: parent.height * 0.85
            height: parent.height * 0.85
            color: "blue"
    
            MouseArea {
                anchors.fill : parent
                onPressed: {
                    mediaIndex++; myVideo.play();
                }
            }
    

    When you click the button it plays the next video in the mediaFolder.

    This works as expected on Windows and Android.

    On iOS i have the random positioning problem described in this forum, which can somewhat be worked around by rotating the device (not nice).

    What is my bigger problem is settling on a video encoding that works everywhere. These same videos do not play on Mac (either in my QML app or directly from Finder) or Linux (not in my QML app but DO when I launch directly from the file manager.

    So for now i cant say if the positioning problem is unique to iOS, it could be on Mac and Linux too - i just cant see my video there yet.

    I had settled on using Handbrakes ipod profile as the most cross platform but alas its back to the drawing board for video format. Has anyone else nailed the absolute cross platform video format?



  • I too have this problem. My UI code is all QML and is super simple. I have a video component

        Video {
            id: myVideo
            anchors.fill: parent
            anchors.margins: 10
            source: mediaFolder.fileUrl(filesList[mediaIndex])
        }
    

    and a button.

        Rectangle {
            id: start
            anchors.right: parent.right
            anchors.verticalCenter: parent.verticalCenter
            anchors.margins: 20
            width: parent.height * 0.85
            height: parent.height * 0.85
            color: "blue"
    
            MouseArea {
                anchors.fill : parent
                onPressed: {
                    mediaIndex++; myVideo.play();
                }
            }
    

    When you click the button it plays the next video in the mediaFolder.

    This works as expected on Windows and Android.

    On iOS i have the random positioning problem described in this forum, which can somewhat be worked around by rotating the device (not nice).

    What is my bigger problem is settling on a video encoding that works everywhere. These same videos do not play on Mac (either in my QML app or directly from Finder) or Linux (not in my QML app but DO when I launch directly from the file manager.

    So for now i cant say if the positioning problem is unique to iOS, it could be on Mac and Linux too - i just cant see my video there yet.

    I had settled on using Handbrakes ipod profile as the most cross platform but alas its back to the drawing board for video format. Has anyone else nailed the absolute cross platform video format?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.