0

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

1 に答える 1

1

試してみてください

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

wav ファイルがコンパイル済みの実行可能ファイルと同じディレクトリにあることを確認してください。QMediaPlayer::MediaStatusが QMediaPlayer::LoadedMedia と等しい場合、スロットをmediaStatusChanged シグナルに接続し、そこから再生を開始する方がよい場合があります。

于 2013-11-10T19:19:26.457 に答える