Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Newby needs help building QMediaPlayer Example
Forum Updated to NodeBB v4.3 + New Features

Newby needs help building QMediaPlayer Example

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 2 Posters 10.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.
  • Z Offline
    Z Offline
    zambotti
    wrote on last edited by
    #1

    Trying to make a simple code example that uses XMediaPlayer to play a couple of mp3 files.

    Partial code below, followed by error codes.

    The build is for Simulator Qt for MinGW 4.4 (Nokia Qt SDK) (Nokia Forum QT 4.7.0)

    Any ideas for this newby lab rat developer. (I haven't used this IDE before)
    @
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QtMultimediaKit/QMediaPlayer.h>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::playAudioFile(QString localFile)
    {
    QMediaPlayer *player; // line 19
    player = new QMediaPlayer; // Line 20
    // line 21
    player->setMedia(QUrl::fromLocalFile(localFile)); // line 22
    player->setVolume(50); // line 23
    player->play(); // line 24
    }

    void MainWindow::on_playButton1_clicked()
    {
    playAudioFile(ui->lineEdit1->text());
    }

    void MainWindow::on_playButton2_clicked()
    {
    playAudioFile(ui->lineEdit2->text());
    }
    @
    Build results in the following errors :

    Running build steps for project TestPlayMedia...
    Configuration unchanged, skipping qmake step.
    Starting: "C:/NokiaQtSDK/mingw/bin/mingw32-make.exe" -w
    mingw32-make: Entering directory `C:/Documents and Settings/walter/QT/TestPlayMedia-build-simulator'

    C:/NokiaQtSDK/mingw/bin/mingw32-make -f Makefile.Debug

    mingw32-make[1]: Entering directory `C:/Documents and Settings/walter/QT/TestPlayMedia-build-simulator'

    g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\TestPlayMedia.exe debug/main.o debug/mainwindow.o debug/moc_mainwindow.o -L"c:\NokiaQtSDK\Simulator\Qt\mingw\lib" -lmingw32 -lqtmaind -LC:\NokiaQtSDK\Simulator\QtMobility\mingw\lib -lQtMobilitySimulatord1 -lQtGuid4 -lQtCored4 -LC:\OpenSSL-Win32_full\lib

    mingw32-make[1]: Leaving directory `C:/Documents and Settings/walter/QT/TestPlayMedia-build-simulator'

    mingw32-make: Leaving directory `C:/Documents and Settings/walter/QT/TestPlayMedia-build-simulator'

    debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:20: undefined reference to `_imp___ZN21QMediaServiceProvider22defaultServiceProviderEv'

    debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:20: undefined reference to `_imp___ZN12QMediaPlayerC1EP7QObject6QFlagsINS_4FlagEEP21QMediaServiceProvider'

    debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:22: undefined reference to `_imp___ZN13QMediaContentC1ERK4QUrl'

    debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:22: undefined reference to `_imp___ZN12QMediaPlayer8setMediaERK13QMediaContentP9QIODevice'

    debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:22: undefined reference to `_imp___ZN13QMediaContentD1Ev'

    debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:22: undefined reference to `_imp___ZN13QMediaContentD1Ev'

    debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:23: undefined reference to `_imp___ZN12QMediaPlayer9setVolumeEi'

    debug/mainwindow.o:C:\Documents and Settings\walter\QT\TestPlayMedia-build-simulator/../TestPlayMedia/mainwindow.cpp:24: undefined reference to `_imp___ZN12QMediaPlayer4playEv'

    collect2: ld returned 1 exit status

    mingw32-make[1]: *** [debug\TestPlayMedia.exe] Error 1

    mingw32-make: *** [debug] Error 2

    The process "C:/NokiaQtSDK/mingw/bin/mingw32-make.exe" exited with code %2.
    Error while building project TestPlayMedia (target: Qt Simulator)
    When executing build step 'Make'

    [edit: Highlighting added / Denis Kormalev]

    1 Reply Last reply
    0
    • D Offline
      D Offline
      danilocesar
      wrote on last edited by
      #2

      Looks like a linking problem.

      Did you include QtMobility and Multimediakit in your .pro file?

      <a href="http://www.danilocesar.com">Danilo Cesar Lemes de Paula</a>
      Software Engineer

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

        Adding mobility and multimediakit to your .pro solved the problem?

        <a href="http://www.danilocesar.com">Danilo Cesar Lemes de Paula</a>
        Software Engineer

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          zambotti
          wrote on last edited by
          #4

          Thanks for quick reply. I think your telling me to add the mobility and multimediakit librarys to the build step. Linking der!!! Is this correct? Do I manually edit the build step or is there an gui option for adding libraries in QT creater?

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #5

            danilocesar says that you have to add these in your .pro file manually

            @
            CONFIG += mobility
            MOBILITY = multimedia
            @

            There is a media player mobility example, you can check for it in the Qt assistant

            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