QMediaPlayer 在 qt5 中不起作用



我在Mac OS X 10.8和Qt 5.1上使用Xcode 4.6。我想在我的应用程序中使用 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.

尝试使用

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

确保 wav 文件与编译的可执行文件位于同一目录中。最好将插槽连接到mediaStatusChanged信号,并在QMediaPlayer::MediaStatus等于QMediaPlayer::LoadedMedia时从那里开始播放。

相关内容

  • 没有找到相关文章

最新更新