简体   繁体   English

在Windows XP中在Qt 4.4中播放音频文件

[英]playing an audio file in Qt 4.4 in windows XP

I tried to play a audio file in Qt 4.4 in windows XP using phonon classes (MediaObject,MediaSource,AudioOutput). 我试图在Windows XP的Qt 4.4中使用声子类(MediaObject,MediaSource,AudioOutput)播放音频文件。 The code gets compiled and ran but the audio file is not playing. 代码已编译并运行,但音频文件未播放。 I enabled the phonon support and setup the backend as well. 我启用了声子支持并设置了后端。 Someone can please help me with this. 有人可以帮我这个忙。 i attached my code also for reference. 我还附上了我的代码以供参考。 Also i dont want to use QDesktopServices and all. 我也不想使用QDesktopServices和所有。

Phonon::AudioOutput *audioOutput=new Phonon::AudioOutput(Phonon::MusicCategory,this);
Phonon::MediaObject *mediaObject=new Phonon::MediaObject(this);
mediaObject->setTickInterval(1000);
Phonon::createPath(mediaObject,audioOutput);
Phonon::MediaSource source("D:\\CAT\\audioFile.mp3");
mediaObject->setCurrentSource(source);
mediaObject->play();

your code seem to be fine; 您的代码似乎很好; what you might want to check if your backend (I guess DirectShow if you're running windows) has needed audio device available or/and the audio format is supported by backend. 您可能想检查后端(如果您正在运行Windows,我想是DirectShow)是否需要可用的音频设备或/和后端是否支持音频格式。 In order to do this you can use functions from Phonon BackendCapabilities namespace. 为此,您可以使用Phonon BackendCapabilities命名空间中的函数。 As an alternative you can build and run an example application which comes with QT, it should be in your_qt_folder/examples/phonon/capabilities 作为替代方案,您可以构建和运行QT附带的示例应用程序,它应位于your_qt_folder / examples / phonon / capabilities中

alt text http://qt.nokia.com/doc/4.4/images/capabilitiesexample.png 替代文字http://qt.nokia.com/doc/4.4/images/capabilitiesexample.png

more details regarding this example here: Capabilities Example 有关此示例的更多详细信息,请参见: 功能示例

I guess if it doesn't show you anything then you need to check your backend installation or your audio device or\\and format are not supported 我想如果它没有显示任何内容,那么您需要检查后端安装或音频设备或\\和格式不受支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM