Results 1 to 2 of 2

Thread: QMediaPlayer problems

  1. #1
    Join Date
    Aug 2012
    Posts
    55
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QMediaPlayer problems

    Hi

    I installed Qt5 and since Phonon is not supported in Qt5 I'm forced to use something else, so I decided to use QtMultimedia.

    .pro file:

    Qt Code:
    1. QT += core gui
    2. CONFIG += mobility
    3. MOBILITY += multimedia
    To copy to clipboard, switch view to plain text mode 

    .cpp code:

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include <QtGui>
    4. #include <QtCore>
    5. #include <QtMultimedia/QMediaPlayer>
    6.  
    7. ...
    8.  
    9. void MainWindow::on_pushButton_clicked()
    10. {
    11. QMediaPlayer *player = new QMediaPlayer(this);
    12. player->setVolume(50);
    13. player->setMedia(QUrl::fromLocalFile("some_path"));
    14. player->play();
    15. }
    To copy to clipboard, switch view to plain text mode 

    But I'm getting following errors:

    df5cb69d80eadef8a7a0ce6b0ec6cc04.jpg

    How can I solve this. Thank you

  2. #2
    Join Date
    Feb 2013
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QMediaPlayer problems

    Hi,

    Using Qt5, your .pro file should look like this:
    Qt Code:
    1. QT += multimedia
    To copy to clipboard, switch view to plain text mode 
    ... or:
    Qt Code:
    1. QT += multimedia multimediawidgets
    To copy to clipboard, switch view to plain text mode 
    ... if you plan to use QVideoWidget for video rendering.

    AFAIK, you don't need to set CONFIG and MOBILITY anymore with Qt5.

    Cheers.

    EDIT : by the way, you don't need to specify the module path in your #include. The standard way is to simply #include <QMediaPlayer>.
    Last edited by Vlavv; 25th February 2013 at 17:30.

Similar Threads

  1. Replies: 1
    Last Post: 26th November 2012, 20:09
  2. QMediaPlayer seeking in stream
    By n1ghtly in forum Qt Programming
    Replies: 0
    Last Post: 24th August 2012, 14:28
  3. videoplayer problem in qmediaplayer
    By vinayaka in forum Newbie
    Replies: 3
    Last Post: 25th August 2011, 13:44
  4. Replies: 0
    Last Post: 8th July 2011, 06:04
  5. Does QMediaPlayer work with URLs in QT 4.7.0 and QT mobility 1.1?
    By Gajendra in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 24th February 2011, 06:22

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.