Results 1 to 15 of 15

Thread: Video Avi and QT

  1. #1
    Join Date
    Feb 2012
    Posts
    33
    Qt products
    Qt4

    Default Video Avi and QT

    Hi,
    I tried to play a vedeo Avi in Windows XP using QT4.

    My code is very simple:

    QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"), QDir::homePath(), NULL);
    Phonon::VideoPlayer *player = new Phonon::VideoPlayer(Phonon::VideoCategory, ui->graphicsView);
    player->play(fileName);

    I have no errors, but starting the program nothing happens, the graphicsView remains empty and the video does not start.

    On Windows XP I loaded the video codec, in fact the video start normally using any video player.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Video Avi and QT

    answered elsewhere
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Feb 2012
    Posts
    33
    Qt products
    Qt4

    Default Re: Video Avi and QT

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include <QFileDialog>
    4. #include <Phonon/VideoPlayer>
    5.  
    6. MainWindow::MainWindow(QWidget *parent) :
    7. QMainWindow(parent),
    8. ui(new Ui::MainWindow)
    9. {
    10. ui->setupUi(this);
    11. }
    12.  
    13. MainWindow::~MainWindow()
    14. {
    15. delete ui;
    16. }
    17.  
    18. void MainWindow::on_pushButton_clicked()
    19. {
    20.  
    21. QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"), QDir::homePath(), NULL);
    22. Phonon::VideoPlayer *player = new Phonon::VideoPlayer(Phonon::VideoCategory, ui->graphicsView);
    23. player->play(fileName);
    24.  
    25. }
    To copy to clipboard, switch view to plain text mode 



    I have only a pushbutton and a graphicswiev in the designer mainwindow.ui
    Last edited by wysota; 16th April 2012 at 11:27. Reason: missing [code] tags

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Video Avi and QT

    yes, thats the problem.

    (just because you make a parent doesnt mean graphics will show there.)
    Last edited by amleto; 16th April 2012 at 10:08.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    Feb 2012
    Posts
    33
    Qt products
    Qt4

    Default Re: Video Avi and QT

    so how do I do to watch the video?

  6. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Video Avi and QT

    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  7. #7
    Join Date
    Feb 2012
    Posts
    33
    Qt products
    Qt4

    Default Re: Video Avi and QT

    This is the example on the page that you linked:

    Qt Code:
    1. VideoPlayer *player = new VideoPlayer(Phonon::VideoCategory, parentWidget);
    2. connect(player, SIGNAL(finished()), player, SLOT(deleteLater()));
    3. player->play(url);
    To copy to clipboard, switch view to plain text mode 

    I don't see difference between this example and my code, except the parentWidget. If I write in my code "parentWidget" I have an error:
    C3867: 'QWidget:arentWidget': function call missing argument list; use '&QWidget:arentWidget' to create a pointer to member

    I do not understand the error and I do not know what to do. What it means "use '&QWidget:arentWidget' to create a pointer to member"?
    Last edited by wysota; 16th April 2012 at 11:28. Reason: missing [code] tags

  8. #8
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Video Avi and QT

    Qt Code:
    1. QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"), QDir::homePath(), NULL);
    2. Phonon::VideoPlayer *player = new Phonon::VideoPlayer(Phonon::VideoCategory, ui->graphicsView);
    3. player->play(fileName);
    4.  
    5. player->videoWidget()->show();
    To copy to clipboard, switch view to plain text mode 


    I think you need to learn some basics of Qt and go though some tutorials
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  9. #9
    Join Date
    Feb 2012
    Posts
    33
    Qt products
    Qt4

    Default Re: Video Avi and QT

    You're right, I need to learn the basics of QT, because I always worked until a few days ago on VB6.
    Anyway I tried your code and not change anything, I do not see anything yet ....

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Video Avi and QT

    If you want to show a video on a graphics view then you need to create a graphics item that you will put into the view. You are not creating a regular widget and putting it in the graphics view widget, probably under the viewport() of the view which is why you can't see anything. First of all pass null as the parent widget and see if the video works at all. If not, then you have some problem with Phonon. If it does, then have a look at the Video Graphics Item Example.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Feb 2012
    Posts
    33
    Qt products
    Qt4

    Default Re: Video Avi and QT

    I passed null as the parent widget, but it don't change anything. I have some problem with Phonon.

    I tried the example "Video Graphics Item Example", but this code is only for animated gif and bmg video, not for avi.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Video Avi and QT

    Quote Originally Posted by eltecprogetti View Post
    I passed null as the parent widget, but it don't change anything.
    Completely no change? Are you sure you rebuilt your project? At worst you should have gotten a new empty window.

    I tried the example "Video Graphics Item Example", but this code is only for animated gif and bmg video, not for avi.
    And the difference is...?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Feb 2012
    Posts
    33
    Qt products
    Qt4

    Default Re: Video Avi and QT

    I rebuilt my project and I have not a empty window. I see only a empty form with a empty graphics view.

    In the example linked from you, before to open the dialog box "Open Movie...", all the supported format are loaded:

    QStringList supportedFormats;
    foreach (QString fmt, QMovie::supportedFormats())
    supportedFormats << fmt;
    foreach (QString fmt, QImageReader::supportedImageFormats())
    supportedFormats << fmt;


    So I can't play avi files because its are not supported; only gif and bmg are supported....


    ps. I don't use tags for the code because I don't know these tags.
    Last edited by eltecprogetti; 16th April 2012 at 14:07.

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Video Avi and QT

    Quote Originally Posted by eltecprogetti View Post
    I rebuilt my project and I have not a empty window. I see only a empty form with a empty graphics view.
    Please provide a minimal compilable example reproducing this behaviour.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #15
    Join Date
    Feb 2012
    Posts
    33
    Qt products
    Qt4

    Default Re: Video Avi and QT

    Resolved !!!!

    I forgot the:

    player->show();

Similar Threads

  1. how to set duration of a video in a video player in qt
    By qt_user in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2010, 10:51
  2. Playing video using Phonon video widget
    By Leolander in forum Newbie
    Replies: 0
    Last Post: 26th February 2010, 06:15
  3. Replies: 3
    Last Post: 5th July 2009, 17:22
  4. Video freezes during mpeg video playback using Phonon
    By davejames in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2009, 08:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.