Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. QMediaPlayer. Issue with playing the video in Reverse

QMediaPlayer. Issue with playing the video in Reverse

Scheduled Pinned Locked Moved Unsolved Qt 6
qmediaplayervideoreverse
2 Posts 2 Posters 396 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.
  • X Offline
    X Offline
    XatikoCart
    wrote on 16 Jan 2024, 09:01 last edited by
    #1

    Hello, this is my void that plays video using QMediaPlayer. I tried to look for something in the internet to play my video in reverse while using QMediaPlayer, but didn`t find what will work for me. Maybe I was wrong somewhere.
    Can anybody help to write code, so when the video will be played, the video will be played in reverse?

    P.S. Also I have an issue that the video is not played while using the path from resources and working only the path that is in the code. Maybe anybody knows anything about this issue

    void Form::on_pushButton_6_clicked()
    {
        clickCountButton6++;
    
        int currentTabIndex = ui->tabWidget->currentIndex();
        static QMediaPlayer *player = nullptr;
        static QVideoWidget *videoWidget = nullptr;
    
        if (currentTabIndex == 0)
        {
            if (clickCountButton6 == 1 && clickCountButton2 != 0)
            {
                ui->label_17->lower();
    
                if (!videoWidget)
                {
                    videoWidget = new QVideoWidget(ui->tabWidget->widget(0));
                    videoWidget->resize(605, 482);
                    videoWidget->move(1317, 213);
    
                    connect(videoWidget, &QObject::destroyed, this, &Form::onVideoWidgetDestroyed);
                }
    
                if (!player)
                {
                    player = new QMediaPlayer(videoWidget);
                    player->setVideoOutput(videoWidget);
                    QString videoPath("F:/Mongoose Throw/Gepard/Videos/Sonar_Radar.avi");
                    player->stop();
                    player->setSource(QUrl::fromLocalFile(QFileInfo(videoPath).absoluteFilePath()));
                    player->setLoops(QMediaPlayer::Infinite);
                }
                player->play();
                videoWidget->show();
            }
            else if (clickCountButton6 == 1)
            {
                ui->label_17->lower();
            }
            else if (clickCountButton6 == 2)
            {
                ui->label_17->raise();
                clickCountButton6 = 0;
    
                if (player)
                {
                    player->stop();
                    delete player;
                    player = nullptr;
                }
    
                if (videoWidget)
                {
                    videoWidget->close();
                    delete videoWidget;
                    videoWidget = nullptr;
                }
            }
            ui->pushButton_6->raise();
        }
    }
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 16 Jan 2024, 20:49 last edited by
      #2

      Hi and welcome to devnet,

      Which version of Qt are you using ?

      To the best of my knowledge, there's no option for reverse play.

      As for the resource issue, the native backends cannot access the files within the resources. You have to copy the file in a temporary location and play it from there.

      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
      1

      1/2

      16 Jan 2024, 09:01

      • Login

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