Phonon库安装 :

进入源代码的phonon目录,如"../qt-everywhere-opensource-src-4.6.0/src/phonon",实际代码并不在里面,从phonon.pro文件可知源代码在“/src/3rdparty/phonon/phonon”,但并不影响编译。在终端输入 “make;make install”即可,如果安装时出错,也可手动将lib、include下相关文件拷贝到安装目录。

后端插件安装 :

(1)下载phonon-mplayer。

        地址: http://websvn.kde.org/trunk/playground/multimedia/phonon-backends/mplayer/

        使用svn下载: svn co svn://anonsvn.kde.org/home/kde/trunk/playground/multimedia/phonon-backends/mplayer

(2)返回phonon-mplayer目录,编译(qmake;make)生成phonon_backend/libphonon_mplayer.so动态链接库。

(3)将libphonon_mplayer.so拷贝到$QTDIR/plugins/phonon_backend/




​​QT中使用phonon播放语音文件​​


第一步:



你需要将你的qt安装目录下的phonon_backend整个目录拷贝到工程文件夹,我的在



F:\developingtools\Qt\Qt_install\Simulator\Qt\mingw\plugins\phonon_backend



第二步:



在qt的安装bin目录下找到phonon4.dll这个链接库,放在工程目录下,我的在



F:\developingtools\Qt\Qt_install\Simulator\Qt\mingw\bin下



第三步:



在.cpp中加头文件#include  <MediaObject>



第四步:



Phonon::MediaObject * music =Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource("./mySound/3.wav"));

music->play();
注意,用phonon的时候最好是wav格式的音乐。
如果一开始编译出现错误,phonon: No such file or directory


错误:phonon: No such file or directory
1)sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev libgstreamer-plugins-base0.10-0 libgstreamer-plugins-base0.10-dev
2)sudo apt-get install libphonon-dev libphonon4 phonon-backend-gstreamer
3)sudo dpkg -L libphonon-dev
QT中使用mplayer播放语音文件



第一步:


肯定是在你的机器中安装mplayer,我的调试机器是windows,那么我下载windows版本的mplayer,放在工程的同级目录下。


第二步:


在头文件中加入QProcess头文件,在私有成员变量处
QProcess
*
music_1
;


第三步:


在.cpp文件的构造函数或者初始化函数中new一个对象出来,例如:
music1
=
new
QProcess
;


第四步:


在需要调用的地方:


QString
music
=
"./mySound/2.mp3"
;
//歌曲位置
const QString mplayerPath("./mplayer/mplayer/mplayer.exe"); //播放器位置
QStringList args;
args << "-slave";
args << "-quiet";
args << music;

music_1->start(mplayerPath,args);


到此为止,你就可以用mplayer播放语音了。




第一步:



你需要将你的qt安装目录下的phonon_backend整个目录拷贝到工程文件夹,我的在



F:\developingtools\Qt\Qt_install\Simulator\Qt\mingw\plugins\phonon_backend



第二步:



在qt的安装bin目录下找到phonon4.dll这个链接库,放在工程目录下,我的在



F:\developingtools\Qt\Qt_install\Simulator\Qt\mingw\bin下



第三步:



在.cpp中加头文件#include  <MediaObject>



第四步:



Phonon::MediaObject * music =Phonon::createPlayer(Phonon::MusicCategory,Phonon::MediaSource("./mySound/3.wav"));

music->play();
注意,用phonon的时候最好是wav格式的音乐。
如果一开始编译出现错误,phonon: No such file or directory


错误:phonon: No such file or directory
1)sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev libgstreamer-plugins-base0.10-0 libgstreamer-plugins-base0.10-dev
2)sudo apt-get install libphonon-dev libphonon4 phonon-backend-gstreamer
3)sudo dpkg -L libphonon-dev
QT中使用mplayer播放语音文件



第一步:


肯定是在你的机器中安装mplayer,我的调试机器是windows,那么我下载windows版本的mplayer,放在工程的同级目录下。


第二步:


在头文件中加入QProcess头文件,在私有成员变量处
QProcess
*
music_1
;


第三步:


在.cpp文件的构造函数或者初始化函数中new一个对象出来,例如:
music1
=
new
QProcess
;


第四步:


在需要调用的地方:


QString
music
=
"./mySound/2.mp3"
;
//歌曲位置
const QString mplayerPath("./mplayer/mplayer/mplayer.exe"); //播放器位置
QStringList args;
args << "-slave";
args << "-quiet";
args << music;

music_1->start(mplayerPath,args);


到此为止,你就可以用mplayer播放语音了。


错误:phonon: No such file or directory

1)sudo  apt-get install libgstreamer0.10-0 libgstreamer0.10-dev libgstreamer-plugins-base0.10-0 libgstreamer-plugins-base0.10-dev

2)sudo apt-get install libphonon-dev libphonon4 phonon-backend-gstreamer

3)sudo dpkg -L libphonon-dev


第一步:


肯定是在你的机器中安装mplayer,我的调试机器是windows,那么我下载windows版本的mplayer,放在工程的同级目录下。


第二步:


QProcess  *  music_1 ;


第三步:


在.cpp文件的构造函数或者初始化函数中new一个对象出来,例如: music1  =  new  QProcess ;


第四步:


在需要调用的地方:


QString  music  =  "./mySound/2.mp3" ;  //歌曲位置

const QString mplayerPath("./mplayer/mplayer/mplayer.exe"); //播放器位置QStringList args;args << "-slave";args << "-quiet";args << music;     

music_1->start(mplayerPath,args);

到此为止,你就可以用mplayer播放语音了。