基于Linux的音频播放器的设计 源代码Word下载.docx
- 文档编号:19095473
- 上传时间:2023-01-03
- 格式:DOCX
- 页数:11
- 大小:25.89KB
基于Linux的音频播放器的设计 源代码Word下载.docx
《基于Linux的音频播放器的设计 源代码Word下载.docx》由会员分享,可在线阅读,更多相关《基于Linux的音频播放器的设计 源代码Word下载.docx(11页珍藏版)》请在冰豆网上搜索。
QPlayer)
{
audioOutput=newPhonon:
AudioOutput(Phonon:
MusicCategory,this);
//初始化系列变量
mediaObject=newPhonon:
MediaObject(this);
metaInformationResolver=newPhonon:
mediaObject->
setTickInterval(1000);
connect(mediaObject,SIGNAL(tick(qint64)),this,SLOT(tick(qint64)));
connect(mediaObject,SIGNAL(stateChanged(Phonon:
State,Phonon:
State)),
this,SLOT(stateChanged(Phonon:
State)));
connect(metaInformationResolver,SIGNAL(stateChanged(Phonon:
State,Phonon:
this,SLOT(metaStateChanged(Phonon:
connect(mediaObject,SIGNAL(currentSourceChanged(constPhonon:
MediaSource&
)),
this,SLOT(sourceChanged(constPhonon:
)));
connect(mediaObject,SIGNAL(aboutToFinish()),this,SLOT(aboutToFinish()));
Phonon:
createPath(mediaObject,audioOutput);
setupActions();
ui->
setupUi(this);
seekSlider->
setMediaObject(mediaObject);
volumeSlider->
setAudioOutput(audioOutput);
setSizePolicy(QSizePolicy:
Maximum,QSizePolicy:
Maximum);
QPalettepalette;
palette.setBrush(QPalette:
Light,Qt:
darkGray);
lcdNumber->
setPalette(palette);
QStringListheaders;
headers<
<
tr("
标题"
)<
作者"
唱片"
年代"
);
tableWidget->
setHorizontalHeaderLabels(headers);
setSelectionMode(QAbstractItemView:
SingleSelection);
setSelectionBehavior(QAbstractItemView:
SelectRows);
connect(ui->
tableWidget,SIGNAL(cellPressed(int,int)),
this,SLOT(tableClicked(int,int)));
display("
00:
00"
PauseButton->
hide();
}
~QPlayer()
deleteui;
voidQPlayer:
changeEvent(QEvent*e)
QMainWindow:
changeEvent(e);
switch(e->
type()){
caseQEvent:
LanguageChange:
retranslateUi(this);
break;
default:
}
setupActions()
playAction=newQAction(style()->
standardIcon(QStyle:
SP_MediaPlay),tr("
Play"
),this);
playAction->
setShortcut(tr("
Crl+P"
));
setDisabled(true);
pauseAction=newQAction(style()->
SP_MediaPause),tr("
Pause"
pauseAction->
Ctrl+A"
stopAction=newQAction(style()->
SP_MediaStop),tr("
Stop"
stopAction->
Ctrl+S"
nextAction=newQAction(style()->
SP_MediaSkipForward),tr("
Next"
nextAction->
Ctrl+N"
previousAction=newQAction(style()->
SP_MediaSkipBackward),tr("
Previous"
previousAction->
Ctrl+R"
addFilesAction=newQAction(tr("
Add&
Files"
addFilesAction->
Ctrl+F"
connect(playAction,SIGNAL(triggered()),mediaObject,SLOT(play()));
connect(pauseAction,SIGNAL(triggered()),mediaObject,SLOT(pause()));
connect(stopAction,SIGNAL(triggered()),mediaObject,SLOT(stop()));
connect(addFilesAction,SIGNAL(triggered()),this,SLOT(addFiles()));
addFiles()
QStringListfiles=QFileDialog:
getOpenFileNames(this,tr("
选择音乐文件"
),
QDesktopServices:
storageLocation(QDesktopServices:
MusicLocation));
if(files.isEmpty())
return;
intindex=sources.size();
foreach(QStringstring,files){
MediaSourcesource(string);
sources.append(source);
if(!
sources.isEmpty())
metaInformationResolver->
setCurrentSource(sources.at(index));
//显示歌曲名字
tableClicked(introw,int)
boolwasPlaying=mediaObject->
state()==Phonon:
PlayingState;
stop();
clearQueue();
if(row>
=sources.size())
setCurrentSource(sources[row]);
if(wasPlaying)
play();
else
//显示歌曲时间
tick(qint64time)
QTimedisplayTime(0,(time/60000)%60,(time/1000)%60);
display(displayTime.toString("
mm:
ss"
sourceChanged(constPhonon:
source)
selectRow(sources.indexOf(source));
metaStateChanged(Phonon:
StatenewState,Phonon:
State)
if(newState==Phonon:
ErrorState){
QMessageBox:
warning(this,tr("
文件格式错误"
errorString());
while(!
sources.isEmpty()&
&
!
(sources.takeLast()==metaInformationResolver->
currentSource())){};
if(newState!
=Phonon:
StoppedState&
newState!
PausedState)
if(metaInformationResolver->
currentSource().type()==Phonon:
MediaSource:
Invalid)
QMap<
QString,QString>
metaData=metaInformationResolver->
metaData();
QStringtitle=metaData.value("
TITLE"
if(title=="
"
)
title=metaInformationResolver->
currentSource().fileName();
QTableWidgetItem*titleItem=newQTableWidgetItem(title);
titleItem->
setFlags(titleItem->
flags()^Qt:
ItemIsEditable);
QTableWidgetItem*artistItem=newQTableWidgetItem(metaData.value("
ARTIST"
artistItem->
setFlags(artistItem->
QTableWidgetItem*albumItem=newQTableWidgetItem(metaData.value("
ALBUM"
albumItem->
setFlags(albumItem->
QTableWidgetItem*yearItem=newQTableWidgetItem(metaData.value("
DATE"
yearItem->
setFlags(yearItem->
intcurrentRow=ui->
rowCount();
insertRow(currentRow);
setItem(currentRow,0,titleItem);
setItem(currentRow,1,artistItem);
setItem(currentRow,2,albumItem);
setItem(currentRow,3,yearItem);
if(ui->
selectedItems().isEmpty()){
selectRow(0);
setCurrentSource(metaInformationResolver->
currentSource());
MediaSourcesource=metaInformationResolver->
currentSource();
intindex=sources.indexOf(metaInformationResolver->
currentSource())+1;
if(sources.size()>
index){
else{
resizeColumnsToContents();
columnWidth(0)>
300)
setColumnWidth(0,300);
stateChanged(Phonon:
switch(newState){
casePhonon:
ErrorState:
if(mediaObject->
errorType()==Phonon:
FatalError){
致命错误"
}else{
错误"
PlayingState:
setEnabled(false);
setEnabled(true);
show();
PlayButton->
StoppedState:
PausedState:
BufferingState:
;
nextFile()
intindex=sources.indexOf(mediaObject->
prevFile()
currentSource())-1;
index&
index>
=0){
rndFile()
intindex=sources.indexOf(mediaObject->
intmax=sources.size();
boolisWhile=true;
if(index>
0){
while(isWhile){
srand((unsigned)time(0));
intrndex=rand()%max;
if(!
rndex==index){
isWhile=false;
setCurrentSource(sources.at(rndex));
aboutToFinish()
nextFile();
finished()
setChecked(false);
removeFiles()
intp=ui->
currentRow();
if(p==index){
sources.removeAt(p);
removeRow(p);
on_AddButton_clicked()
trigger();
on_PlayButton_clicked()
on_StopButton_clicked()
on_PauseButton_clicked()
on_NextButton_clicked()
on_PrevButton_clicked()
prevFile();
on_StyleButton_clicked()
rndFile();
on_pushButton_clicked()
about(this,tr("
版本信息"
),tr("
版本:
QT音乐_V1.0.10版.\n\n作者:
_HeyKite(EN)独男(CN)"
on_RemoveButton_clicked()
removeFiles();
on_MuButton_clicked()
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 基于Linux的音频播放器的设计 源代码 基于 Linux 音频 播放 设计
![提示](https://static.bdocx.com/images/bang_tan.gif)