QMediaPlayer не работает в qt5

Я использую Xcode 4.6 в Mac OS X 10.8 и Qt 5.1. Я хочу использовать класс QMeduaPlayer в своем приложении. Вот мой код:

#include <QApplication>
#include <QMediaPlayer>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QMediaPlayer* pl = new QMediaPlayer();
    pl->setMedia(QUrl::fromLocalFile("Crashday.wav"));
    pl->play();
    a.exec();
}

Но не работает и в консоли вижу:

objc97058: Class AVFCaptureFramesDelegate is implemented in both /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqavfcamera.dylib and /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqavfcamera_debug.dylib. One of the two will be used. Which one is undefined.
objc97058: Class AVFMediaRecorderDelegate is implemented in both /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqavfcamera.dylib and /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqavfcamera_debug.dylib. One of the two will be used. Which one is undefined.
objc97058: Class AVFCameraSessionObserver is implemented in both /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqavfcamera.dylib and /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqavfcamera_debug.dylib. One of the two will be used. Which one is undefined.
objc97058: Class AVFMediaPlayerSessionObserver is implemented in both /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqavfmediaplayer.dylib and /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqavfmediaplayer_debug.dylib. One of the two will be used. Which one is undefined.
objc97058: Class TransparentQTMovieView is implemented in both /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqqt7engine.dylib and /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqqt7engine_debug.dylib. One of the two will be used. Which one is undefined.
objc97058: Class HiddenQTMovieView is implemented in both /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqqt7engine.dylib and /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqqt7engine_debug.dylib. One of the two will be used. Which one is undefined.
objc97058: Class QTMovieObserver is implemented in both /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqqt7engine.dylib and /Users/liri/Qt/5.1.1/clang_64/plugins/mediaservice/libqqt7engine_debug.dylib. One of the two will be used. Which one is undefined.

person isomoar    schedule 07.10.2013    source источник


Ответы (1)


Попробуйте с

QMediaContent media(QUrl::fromLocalFile("Crashday.wav"));
pl->setMedia(media); 
pl->play();

Убедитесь, что wav-файл находится в том же каталоге, что и скомпилированный исполняемый файл. Возможно, лучше подключить слот к сигналу mediaStatusChanged. и начать воспроизведение оттуда, когда QMediaPlayer::MediaStatus равно в QMediaPlayer::LoadedMedia.

person Christian Rapp    schedule 10.11.2013