Results 1 to 7 of 7

Thread: Phonon::VideoPlayer

  1. #1
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Phonon::VideoPlayer

    Hi

    I'm new to Qt. I'm trying to get a Phonon::VideoPlayer running to playback an MPEG4 video. I have the VideoPlayer window displaying but the the video screen is just black and there is no video playback. I'm running this on Windows XP. My code is below, hope you can help.
    thanks
    Dano

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent), ui(new Ui::MainWindow)
    3. {
    4. ui->setupUi(this);
    5.  
    6. //setup media object
    7. //
    8. media = new Phonon::MediaObject();
    9. media->setCurrentSource(Phonon::MediaSource(QString("C:\\workspace\\sample_mpeg4.mp4")));
    10.  
    11. //setup player
    12. //
    13. videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory);
    14. videoPlayer->setFixedSize(QSize(400,300));
    15. videoPlayer->move(1280-400,0);
    16. videoPlayer->show();
    17. connect(videoPlayer, SIGNAL(finished()), videoPlayer, SLOT(deleteLater()));
    18. videoPlayer->play(media->currentSource());
    19.  
    20. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by dano_labrosse; 17th October 2009 at 19:05.

  2. #2
    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: Phonon::VideoPlayer

    It's possible that your backend can't play the file. Are you able to play the move using Windows Media Player?
    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.


  3. The following user says thank you to wysota for this useful post:

    dano_labrosse (17th October 2009)

  4. #3
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Phonon::VideoPlayer

    Hi wysota

    Yes, it turns out Windows Media Player was unable to playback the file. WinXP DirectShow does not include support for MPEG-4 video by default. I installed 3ivx MPEG-4 (http://www.3ivx.com/) and the code works fine now.

    I think Windows 7 DirectShow has support for MPEG-4 out of the box.

    cheers!

  5. #4
    Join Date
    Jan 2010
    Posts
    18
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Phonon::VideoPlayer

    This may be a bit of a late reply, but:

    Check the path that you have spelled out in the QString. You may not need the double backslashes(only a single backslash).

    Also, be sure that you can play the video file with a different player to make sure you have the right codec loaded.

    To get this code to work on a LINUX box, I used Qt Creator to create a new Qt4 Gui Application project (under options I included multimedia and phonon).

    Then I copied and pasted your code into the mainwindow.cpp file and changed the path spelled out in the QString to a video file (a .mov file) in my directory structure.

    I added the following into the mainwindow.h file:

    #include <Phonon>

    (above the MainWindow class declaration)
    namespace Phonon {

    class MediaObject;
    class VideoPlayer;
    }

    (under the private: data members)
    Phonon::MediaObject *media;
    Phonon::VideoPlayer *videoPlayer;

    I compiled, tried it and it worked fine except there were two different windows: a Mainwindow and a window
    that played the video file and then disappeared. Other than that, it worked fine. Hope this helps.

  6. #5
    Join Date
    Jan 2010
    Posts
    18
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Phonon::VideoPlayer

    Opps. I didn't scroll down far enough to see that the problem was solved before my reply. Please disregard. Sorry.

  7. #6
    Join Date
    Oct 2007
    Posts
    9
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Phonon::VideoPlayer

    I have same problem , I build a player in Win XP using Phonon::videoPlayer but when i am trying to play on window 7 , it show only black screen even no audio is playing .. can you suggest me? I m stuck here..

  8. #7
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Phonon::VideoPlayer

    Hi , you need to place phonon::backend plugin into your application directory. and restart your system, i hope it will work. cheers..

  9. The following user says thank you to MrShahi for this useful post:

    sonu (1st February 2012)

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.