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. Show Video on dialog
Forum Updated to NodeBB v4.3 + New Features

Show Video on dialog

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 848 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.
  • A Offline
    A Offline
    aim0d
    wrote on last edited by
    #1

    HI! I'm new to QT and I'm trying to understand how to play video.

    I'm trying to play a video on a dialog that I open throught "Menubar" in my MainWindow.
    When I click on the voice, that it should show my dialog with window, it shows this message on the console: DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80040216 ()
    This is the code in video.cpp:

    #include "video.h"
    #include "ui_video.h"
    
    #include <QMediaPlayer>
    #include <QVideoWidget>
    
    Video::Video(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::Video)
    {
        ui->setupUi(this);
        setWindowTitle("Video");
    
        QMediaPlayer *player = new QMediaPlayer;
        QVideoWidget *vw = new QVideoWidget;
    
        player->setVideoOutput(vw);
        player->setMedia(QUrl::fromLocalFile("Strada.mp4"));
    
        vw->setGeometry(400,300,300,400);
        vw->show();
    
        player->play();
    }
    
    Video::~Video()
    {
        delete ui;
    }
    

    And this how I open the dialog in MainWindows.cpp:

    void MainWindow::on_actionVideo_triggered()
    {
        Video vd;
        vd.exec();
    }
    

    What am I doing wrong?

    JonBJ 1 Reply Last reply
    0
    • A aim0d

      HI! I'm new to QT and I'm trying to understand how to play video.

      I'm trying to play a video on a dialog that I open throught "Menubar" in my MainWindow.
      When I click on the voice, that it should show my dialog with window, it shows this message on the console: DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80040216 ()
      This is the code in video.cpp:

      #include "video.h"
      #include "ui_video.h"
      
      #include <QMediaPlayer>
      #include <QVideoWidget>
      
      Video::Video(QWidget *parent) :
          QDialog(parent),
          ui(new Ui::Video)
      {
          ui->setupUi(this);
          setWindowTitle("Video");
      
          QMediaPlayer *player = new QMediaPlayer;
          QVideoWidget *vw = new QVideoWidget;
      
          player->setVideoOutput(vw);
          player->setMedia(QUrl::fromLocalFile("Strada.mp4"));
      
          vw->setGeometry(400,300,300,400);
          vw->show();
      
          player->play();
      }
      
      Video::~Video()
      {
          delete ui;
      }
      

      And this how I open the dialog in MainWindows.cpp:

      void MainWindow::on_actionVideo_triggered()
      {
          Video vd;
          vd.exec();
      }
      

      What am I doing wrong?

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

      @aim0d said in Show Video on dialog:

      player->setMedia(QUrl::fromLocalFile("Strada.mp4"));

      Replace "Strada.mp4" with the full path to that file, and try again. See e.g. https://stackoverflow.com/questions/65886167/how-to-solve-qt-unresolved-error-code-0x80040216

      A 1 Reply Last reply
      2
      • JonBJ JonB

        @aim0d said in Show Video on dialog:

        player->setMedia(QUrl::fromLocalFile("Strada.mp4"));

        Replace "Strada.mp4" with the full path to that file, and try again. See e.g. https://stackoverflow.com/questions/65886167/how-to-solve-qt-unresolved-error-code-0x80040216

        A Offline
        A Offline
        aim0d
        wrote on last edited by
        #3

        @JonB I'm gonna try it, thanks
        I just wrote the name of the video because I put it in the project directory and thought it was enought.

        jsulmJ 1 Reply Last reply
        0
        • A aim0d

          @JonB I'm gonna try it, thanks
          I just wrote the name of the video because I put it in the project directory and thought it was enought.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @aim0d said in Show Video on dialog:

          I put it in the project directory and thought it was enought

          No, it needs to be in the current working directory of your application if you only wantr to use the file name. By default the build folder where the executable is will be the working directory. But you should never trust such assumptions! So, do not use relative paths but construct the path, see https://doc.qt.io/qt-6/qstandardpaths.html

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply
          1
          • jsulmJ jsulm

            @aim0d said in Show Video on dialog:

            I put it in the project directory and thought it was enought

            No, it needs to be in the current working directory of your application if you only wantr to use the file name. By default the build folder where the executable is will be the working directory. But you should never trust such assumptions! So, do not use relative paths but construct the path, see https://doc.qt.io/qt-6/qstandardpaths.html

            A Offline
            A Offline
            aim0d
            wrote on last edited by
            #5

            @jsulm I tried changing the path, as u told me (also trying the one in the stackoverflow answer) but still same error :(

            jsulmJ 1 Reply Last reply
            0
            • A Offline
              A Offline
              aim0d
              wrote on last edited by aim0d
              #6

              I dont get it; even if I try this example i get error -> DirectShowPlayerService::doRender: Unresolved error code 0x80040266 ()
              And it's the official example from QT

              JonBJ 1 Reply Last reply
              0
              • A aim0d

                I dont get it; even if I try this example i get error -> DirectShowPlayerService::doRender: Unresolved error code 0x80040266 ()
                And it's the official example from QT

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

                @aim0d
                Since you have the reference and solution of someone who encountered the same, I would guess you are not specifying the full path correctly.

                However, you are just as capable as I am of Googling for DirectShowPlayerService::doRender or similar, e.g. https://stackoverflow.com/questions/53328979/directshowplayerservicedorender-unresolved-error-code-0x80040266. Maybe

                the problem is caused because the Qt Multimedia DirectShow backend does not support some formats because you do not have the codecs, so the solution is to install those codec

                The problem itself is not from Qt but from Directshow which is ultimately the one that reproduces the sound so you will have to look for alternative codecs for DirectShow

                A 1 Reply Last reply
                1
                • JonBJ JonB

                  @aim0d
                  Since you have the reference and solution of someone who encountered the same, I would guess you are not specifying the full path correctly.

                  However, you are just as capable as I am of Googling for DirectShowPlayerService::doRender or similar, e.g. https://stackoverflow.com/questions/53328979/directshowplayerservicedorender-unresolved-error-code-0x80040266. Maybe

                  the problem is caused because the Qt Multimedia DirectShow backend does not support some formats because you do not have the codecs, so the solution is to install those codec

                  The problem itself is not from Qt but from Directshow which is ultimately the one that reproduces the sound so you will have to look for alternative codecs for DirectShow

                  A Offline
                  A Offline
                  aim0d
                  wrote on last edited by
                  #8

                  @JonB

                  I would guess you are not specifying the full path correctly
                  If writing the exact same stuff as the example or copy and paste the path isnt enought i dont know what. It's make more sense that i'm doing something else wrong.

                  for the DirectShowPlayerService::doRender i havent found anything on internet that resolved the problem but found by myself what was the problem: basically the player doesnt read .mp4 files, just .mpg

                  Google very often offerts to much solution and very rarely the right one, this is why its rarely a good advice to look into it. In the past months i've been jumping between HTML, C++, QT and other stuff so prefered blog and forum like this.

                  JonBJ 1 Reply Last reply
                  0
                  • A aim0d

                    @JonB

                    I would guess you are not specifying the full path correctly
                    If writing the exact same stuff as the example or copy and paste the path isnt enought i dont know what. It's make more sense that i'm doing something else wrong.

                    for the DirectShowPlayerService::doRender i havent found anything on internet that resolved the problem but found by myself what was the problem: basically the player doesnt read .mp4 files, just .mpg

                    Google very often offerts to much solution and very rarely the right one, this is why its rarely a good advice to look into it. In the past months i've been jumping between HTML, C++, QT and other stuff so prefered blog and forum like this.

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

                    @aim0d said in Show Video on dialog:

                    for the DirectShowPlayerService::doRender i havent found anything on internet that resolved the problem but found by myself what was the problem: basically the player doesnt read .mp4 files, just .mpg

                    Is this not the

                    the problem is caused because the Qt Multimedia DirectShow backend does not support some formats because you do not have the codecs, so the solution is to install those codec

                    precisely from the stackoverflow I gave you as an example?

                    A 1 Reply Last reply
                    0
                    • A aim0d

                      @jsulm I tried changing the path, as u told me (also trying the one in the stackoverflow answer) but still same error :(

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @aim0d said in Show Video on dialog:

                      I tried changing the path, as u told me

                      Please show the code.
                      And did you verify that the path you constructed is correct and the file exists at that location?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      A 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @aim0d said in Show Video on dialog:

                        I tried changing the path, as u told me

                        Please show the code.
                        And did you verify that the path you constructed is correct and the file exists at that location?

                        A Offline
                        A Offline
                        aim0d
                        wrote on last edited by
                        #11

                        @jsulm I tried changing the type of file (from mp4 to mpg) and it worked.

                        1 Reply Last reply
                        0
                        • JonBJ JonB

                          @aim0d said in Show Video on dialog:

                          for the DirectShowPlayerService::doRender i havent found anything on internet that resolved the problem but found by myself what was the problem: basically the player doesnt read .mp4 files, just .mpg

                          Is this not the

                          the problem is caused because the Qt Multimedia DirectShow backend does not support some formats because you do not have the codecs, so the solution is to install those codec

                          precisely from the stackoverflow I gave you as an example?

                          A Offline
                          A Offline
                          aim0d
                          wrote on last edited by
                          #12

                          @JonB >precisely from the stackoverflow I gave you as an example?
                          As I answered to Jsulm, apparently the problem was the extension of the file. If I change it, it works just fine

                          JonBJ 1 Reply Last reply
                          0
                          • A aim0d

                            @JonB >precisely from the stackoverflow I gave you as an example?
                            As I answered to Jsulm, apparently the problem was the extension of the file. If I change it, it works just fine

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

                            @aim0d
                            You should not be changing extensions of files, you should (presumably) be changing your Windows system settings to cope correctly with the file extensions it does support. Up to you.

                            A 1 Reply Last reply
                            0
                            • JonBJ JonB

                              @aim0d
                              You should not be changing extensions of files, you should (presumably) be changing your Windows system settings to cope correctly with the file extensions it does support. Up to you.

                              A Offline
                              A Offline
                              aim0d
                              wrote on last edited by
                              #14

                              @JonB I didnt change it manually,. I't the wrong way to do it.
                              I convert it in the right way. I cannot touch stuff for system, I'm using a work computer

                              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