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. QMediaPlayer

QMediaPlayer

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.6k 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.
  • D Offline
    D Offline
    danielbsig
    wrote on last edited by
    #1

    Regarding the QMediaPlayer type, what exactly is needed to get it to work? I'm using it to play an mp3 file, and currently it is not working. My code is basically as follows:
    @
    m_pMediaPlayer = new QMediaPlayer( );
    m_pMediaPlayer->setMedia( QUrl::fromLocalFile( m_strNotificationSound ) );
    m_pMediaPlayer->setVolume(100);
    m_pMediaPlayer->play();
    @
    I've verified that m_strNotificationSound is a valid path and it points to a valid file (which I could previously play just fine using Phonon in Qt 4.8).

    Also, I have this code:
    @
    QStringList types = m_pMediaPlayer->supportedMimeTypes();
    foreach( QString t, types )
    {
    qDebug() << t;
    }
    @

    and it doesn't print out a single line. This is what I have in my .pro file:
    @
    CONFIG += mobility
    MOBILITY = multimedia

    QT += core
    QT += qml
    QT += quick
    QT += declarative
    QT += xml
    QT += gui
    QT += widgets
    QT += multimedia
    @
    Any ideas?

    Regards,
    Daníel

    [edit: code wrapping added, koahnig]

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Please use "code wrapping":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01
      This makes your code sections readable.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        danielbsig
        wrote on last edited by
        #3

        Thanks for the code wrapping hint, wasn't aware of it.

        I still haven't figured out why this didn't work, but since I am using QML in the same class, I switched to the Audio QML element, and that is able to play my file just fine. So this is at least partially solved.

        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