Exemplo n.º 1
0
//![0]
MainWindow::MainWindow ( QWidget * parent ) {

	audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
	mediaObject = new Phonon::MediaObject(this);
	metaInformationResolver = new Phonon::MediaObject(this);

	mediaObject->setTickInterval(1000);
//![0]
//![2]
	connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
	connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
			this, SLOT(stateChanged(Phonon::State, Phonon::State)));
	connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
			this, SLOT(metaStateChanged(Phonon::State, Phonon::State)));
	connect(mediaObject, SIGNAL(currentSourceChanged(const Phonon::MediaSource &)),
			this, SLOT(sourceChanged(const Phonon::MediaSource &)));
	connect(mediaObject, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish()));
//![2]

//![1]
	Phonon::createPath(mediaObject, audioOutput);
//![1]

	setupActions();
	setupMenus();
	setupUi();
	timeLcd->display("00:00");
}
Exemplo n.º 2
0
void TouchKeyboard::clearMetaState(void)
{
	_metaKeyBits._shift = false;
	_metaKeyBits._ctrl = false;
	_metaKeyBits._alt = false;
	metaStateChanged();
}
Exemplo n.º 3
0
int Playengine::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: volume((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: statusChanged((*reinterpret_cast< Playengine::STATUS(*)>(_a[1]))); break;
        case 2: buffering((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: tick((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 4: togglePause(); break;
        case 5: play((*reinterpret_cast< const QUrl(*)>(_a[1]))); break;
        case 6: stop(); break;
        case 7: setVolume((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 8: stateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break;
        case 9: tickslot((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 10: sourceChanged((*reinterpret_cast< const Phonon::MediaSource(*)>(_a[1]))); break;
        case 11: metaStateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break;
        case 12: aboutToFinish(); break;
        case 13: bufferPercent((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 14: volumeChanged((*reinterpret_cast< qreal(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 15;
    }
    return _id;
}
Exemplo n.º 4
0
MadaoWindow::MadaoWindow()
{
    audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    mediaObject = new Phonon::MediaObject(this);
    musicGetter = new Phonon::MediaObject(this);

    connect(mediaObject, SIGNAL(aboutToFinish()),
            this, SLOT(autoNext()));

    connect(musicGetter, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
            this, SLOT(metaStateChanged(Phonon::State,Phonon::State)));

    connect(mediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
            this, SLOT(stateChanged(Phonon::State,Phonon::State)));

    connect(mediaObject, SIGNAL(currentSourceChanged(Phonon::MediaSource)),
             this, SLOT(sourceChanged(Phonon::MediaSource)));

    Phonon::createPath(mediaObject, audioOutput);

    setAllActions();
    setGui();

    resize(720,480);
    setMinimumSize(720,480);
    playing = false;
    set = false;
    currentSong = 0;
    songsNumber = 0;
    addToTable = 0;
    lastRow = 0;
    QIcon icon("Data/taizo_hasegawa_2564.jpg");
    setWindowIcon(icon);
}
Exemplo n.º 5
0
int MusicPlayer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: updateTime((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 1: playOrpause(); break;
        case 2: openFile(); break;
        case 3: setMod(); break;
        case 4: previousSong(); break;
        case 5: nextSong(); break;
        case 6: whatiLike(); break;
        case 7: showLrc(); break;
        case 8: setPlayer(); break;
        case 9: showPlayList(); break;
        case 10: metaStateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break;
        case 11: tableWidgetClicked((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 12: aboutToFinish(); break;
        case 13: clearSources(); break;
        case 14: saveAndQuit(); break;
        case 15: trayIconActivated((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 16;
    }
    return _id;
}
Exemplo n.º 6
0
void Widget::CreateMusicPlayer()
{
    MainLayout = new QGridLayout;

    //创建播放音乐器
    mediaObject = new Phonon::MediaObject(this);
    Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    Phonon::createPath(mediaObject, audioOutput);
    //创建控制播放进度的滑块
    seekSlider = new Phonon::SeekSlider(mediaObject, this);
    //音量控制部件
    volumeSlider = new Phonon::VolumeSlider(audioOutput, this);
    volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

    //单击获取选中的歌曲行号
    connect(PlayList,SIGNAL(cellClicked(int,int)),this,SLOT(ChangRow(int)));
    //若双击了播放列表里的歌曲就播放该歌曲
    connect(PlayList, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(tableClicked(int)));
    //创建用来解析媒体的信息的元信息解析器
    metaInformationResolver = new Phonon::MediaObject(this);
    //需要与AudioOutput;连接后才能使用metaInformationResolver
    Phonon::AudioOutput *metaInformationAudioPutput =
            new Phonon::AudioOutput(Phonon::MusicCategory,this);
    Phonon::createPath(metaInformationResolver,metaInformationAudioPutput);
    //歌曲改变后把状态传给metaStateChanged函数
    connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
            this, SLOT(metaStateChanged(Phonon::State)));

    //歌曲播放源发生改变时传给SourceChanged函数
    connect(mediaObject,SIGNAL(currentSourceChanged(Phonon::MediaSource)),this,
            SLOT(SourceChanged(Phonon::MediaSource)));
    //当歌曲播放完后传给aboutTofinish函数播放下一首歌
    connect(mediaObject,SIGNAL(aboutToFinish()),this,SLOT(aboutToFinish()));
    //获取下一首歌曲的名字
    connect(mediaObject,SIGNAL(tick(qint64)),this,SLOT(GetNextMusicName()));
    //关联媒体对象的tick()信号来更新播放时间的显示
    mediaObject->setTickInterval(1000);//设置信号发射时间间隔
    //媒体对象mediaObject后在指定的时间间隔发射tick信号,信号的值是音乐当时播放的时间
    connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime(qint64)));

    //获取歌曲播放的状态用来改变歌曲名字
    connect(mediaObject,SIGNAL(stateChanged(Phonon::State,Phonon::State)),
            this,SLOT(GetMusicName(Phonon::State)));

    //控制界面布局
    MainLayout->addWidget(TitleLabel,0,0);
    MainLayout->addWidget(seekSlider,1,0,1,2);
    MainLayout->addLayout(LabelLayout,2,0,1,2);
    MainLayout->addLayout(ButtonLayout,3,0);
    MainLayout->addWidget(volumeSlider,3,1);
    MainLayout->setSizeConstraint(QLayout::SetFixedSize);//用户无法改变窗口的大小,保持窗口相对固定
    //总体布局
    Layout = new QVBoxLayout(this);
    Layout->addLayout(MainLayout);
    Layout->addWidget(PlayList);
}
Exemplo n.º 7
0
void TouchKeyboard::toggleMetaKeyState(MetaKeys metaKeys)
{
	if (metaKeys & mkShift)
		_metaKeyBits._shift = !_metaKeyBits._shift;
	if (metaKeys & mkCtrl)
		_metaKeyBits._ctrl = !_metaKeyBits._ctrl;
	if (metaKeys & mkAlt)
		_metaKeyBits._alt = !_metaKeyBits._alt;
	if (metaKeys & mkCaps)
		_metaKeyBits._caps = !_metaKeyBits._caps;
	metaStateChanged();
}
Exemplo n.º 8
0
disqteca::disqteca(QWidget *parent) : QMainWindow(parent), ui(new Ui::disqteca) {

    audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, this);
    videoWidget = new Phonon::VideoWidget();
    videoWidget->setGeometry(0, 0, 1920, 1080);
    videoWidget->setMinimumWidth(320);
    videoWidget->setMinimumHeight(240);

    mediaObject = new Phonon::MediaObject(this);
    metaInformationResolver = new Phonon::MediaObject(this);

    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,Phonon::State)));
    connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
            this, SLOT(metaStateChanged(Phonon::State,Phonon::State)));
    connect(mediaObject, SIGNAL(currentSourceChanged(Phonon::MediaSource)),
            this, SLOT(sourceChanged(Phonon::MediaSource)));
    connect(mediaObject, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish()));

    // Nunca referenciar nenhum objeto da UI antes dessa linha
    ui->setupUi(this);

    // Liga objetos de busca, volume e os widgets de áudio e video
    ui->seekSlider->setMediaObject(mediaObject);
    ui->volumeSlider->setAudioOutput(audioOutput);
    Phonon::createPath(mediaObject, audioOutput);
    Phonon::createPath(mediaObject, videoWidget);

    DivisorVideoMixteca = new QSplitter;
    DivisorVideoMixteca->addWidget(videoWidget);
    DivisorVideoMixteca->addWidget(ui->Mixteca);

    QVBoxLayout *DivisorCentral = new QVBoxLayout;
    DivisorCentral->addWidget(DivisorVideoMixteca);
    DivisorCentral->addWidget(ui->controlesWidget);

    QWidget *Central = new QWidget;
    Central->setLayout(DivisorCentral);

    setCentralWidget(Central);

    QStringList Cabecalhos;
    Cabecalhos << tr("Titulo") << tr("Artista") << tr("Disco") << tr("Ano");

    ui->Mixteca->setHorizontalHeaderLabels(Cabecalhos);
    ui->sairAction->setShortcuts(QKeySequence::Quit);

}
//start id="get"
void PhononItem::fetchMetaData() {
    delete m_metaMedia;

    m_mediaSource = Phonon::MediaSource(fileName());
    if (m_mediaSource.type() == Phonon::MediaSource::Invalid) {
        qDebug() << "Invalid Media Source." << fileName();
        emit fetched(false);

    }
    m_metaMedia = new Phonon::MediaObject(this);


    QObject::connect(m_metaMedia, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
                     this, SLOT(metaStateChanged(Phonon::State, Phonon::State)), Qt::QueuedConnection);
    QObject::connect(m_metaMedia, SIGNAL(totalTimeChanged(qint64)),
                     this, SLOT(setTotalTime(qint64)), Qt::QueuedConnection);

    m_metaMedia->setCurrentSource(m_mediaSource);

}
Exemplo n.º 10
0
//![0]
MainWindow::MainWindow()
{
    audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    mediaObject = new Phonon::MediaObject(this);
    metaInformationResolver = new Phonon::MediaObject(this);

    mediaObject->setTickInterval(1000);
//![0]
//![2]
    connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
    connect(mediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
            this, SLOT(stateChanged(Phonon::State,Phonon::State)));
    connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
            this, SLOT(metaStateChanged(Phonon::State,Phonon::State)));
    connect(mediaObject, SIGNAL(currentSourceChanged(Phonon::MediaSource)),
            this, SLOT(sourceChanged(Phonon::MediaSource)));
    connect(mediaObject, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish()));
//![2]

//![1]
    Phonon::createPath(mediaObject, audioOutput);
//![1]

    setupActions();
    setupMenus();
    setupUi();
    timeLcd->display("00:00");
    QList<Phonon::AudioOutputDevice> audioOutputDevices =
            Phonon::BackendCapabilities::availableAudioOutputDevices();

    QList<Phonon::AudioOutputDevice>::iterator i;
    for (i=audioOutputDevices.begin(); i != audioOutputDevices.end(); i++) {
        QString description = (*i).name();
        std::cout << "adi: " << description.toStdString() << "\n";
    }
    audioOutput->setName("Halleluja");


}
Exemplo n.º 11
0
int QPlayer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: on_MuButton_clicked(); break;
        case 1: on_RemoveButton_clicked(); break;
        case 2: on_pushButton_clicked(); break;
        case 3: on_StyleButton_clicked(); break;
        case 4: on_PrevButton_clicked(); break;
        case 5: on_NextButton_clicked(); break;
        case 6: on_PauseButton_clicked(); break;
        case 7: on_StopButton_clicked(); break;
        case 8: on_PlayButton_clicked(); break;
        case 9: on_AddButton_clicked(); break;
        case 10: addFiles(); break;
        case 11: nextFile(); break;
        case 12: prevFile(); break;
        case 13: aboutToFinish(); break;
        case 14: finished(); break;
        case 15: tick((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 16: rndFile(); break;
        case 17: stateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break;
        case 18: metaStateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break;
        case 19: sourceChanged((*reinterpret_cast< const Phonon::MediaSource(*)>(_a[1]))); break;
        case 20: tableClicked((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 21: setupActions(); break;
        case 22: removeFiles(); break;
        default: ;
        }
        _id -= 23;
    }
    return _id;
}
Exemplo n.º 12
0
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: addFiles(); break;
        case 1: about(); break;
        case 2: next(); break;
        case 3: preview(); break;
        case 4: doubleclickplay(); break;
        case 5: stateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break;
        case 6: tick((*reinterpret_cast< qint64(*)>(_a[1]))); break;
        case 7: sourceChanged((*reinterpret_cast< const Phonon::MediaSource(*)>(_a[1]))); break;
        case 8: metaStateChanged((*reinterpret_cast< Phonon::State(*)>(_a[1])),(*reinterpret_cast< Phonon::State(*)>(_a[2]))); break;
        case 9: aboutToFinish(); break;
        case 10: tableClicked((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 11;
    }
    return _id;
}
Exemplo n.º 13
0
mainwindow::mainwindow(){
    currentState=0;
    hd = new helpdialog;
    m=new mediaobject;
    setupUi(this);
    setWindowTitle("Music Player");
    m=new mediaobject;
    QObject::connect(actionAbout, SIGNAL(triggered()), this, SLOT(helpShow()));
    QObject::connect(actionExit,SIGNAL(triggered()),this,SLOT(close()));
    QObject::connect(actionAdd_Files,SIGNAL(triggered()),this,SLOT(addFiles()));
    QObject::connect(buttonPause,SIGNAL(clicked()),this,SLOT(pauseFile()));
    QObject::connect(buttonPlay,SIGNAL(clicked()),this,SLOT(playCurrent()));
    QObject::connect(buttonStop,SIGNAL(clicked()),m->mobj,SLOT(stop()));
    QObject::connect(m,SIGNAL(currentSourceChanged(Phonon::MediaSource)),this,SLOT(fetchNext(Phonon::MediaSource)));
    QObject::connect(m->mobj,SIGNAL(aboutToFinish()),this,SLOT(aboutToFinish()));
    QObject::connect(m->mobj,SIGNAL(stateChanged(Phonon::State,Phonon::State)),this,SLOT(metaStateChanged(Phonon::State,Phonon::State)));
    seekSlider->setMediaObject(m->mobj);
    volumeSlider->setAudioOutput(m->audioOutput);
    show();
    // Signal and slots for help -> AboutUs

    //m->setQueue(list);
}
Exemplo n.º 14
0
MusicPlayer::MusicPlayer(QObject *parent) : QObject(parent)
{
    downIcon = QIcon(QLatin1String(":/files/images/arrow-270.png"));
    upIcon = QIcon(QLatin1String(":/files/images/arrow-090.png"));
    removeIcon = QIcon(QLatin1String(":/files/images/cross-circle.png"));


    lastRowClicked = -1;
    currentSource = 0;
    audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    audioOutput->setVolume(.5f);
    mediaObject = new Phonon::MediaObject(this);
    metaInformationResolver = new Phonon::MediaObject(this);


    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,Phonon::State)));
    connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(metaStateChanged(Phonon::State,Phonon::State)));
    connect(mediaObject, SIGNAL(currentSourceChanged(Phonon::MediaSource)), this, SLOT(sourceChanged(Phonon::MediaSource)));
    connect(mediaObject, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish()));

    Phonon::createPath(mediaObject, audioOutput);
}
Exemplo n.º 15
0
// 初始化播放器
void MyWidget::initPlayer()
{
    // 设置主界面标题、图标和大小
    setWindowTitle(tr("MyPlayer音乐播放器"));
    setWindowIcon(QIcon(":/images/icon.png"));
    setMinimumSize(320, 160);
    setMaximumSize(320, 160);

    // 创建媒体图
    mediaObject = new Phonon::MediaObject(this);
    Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
    Phonon::createPath(mediaObject, audioOutput);

    // 关联媒体对象的tick()信号来更新播放时间的显示
    connect(mediaObject, SIGNAL(tick(qint64)), this, SLOT(updateTime(qint64)));

    // 创建顶部标签,用于显示一些信息
    topLabel = new QLabel(tr("<a href = \" http://www.yafeilinux.com \"> www.yafeilinux.com </a>"));
    topLabel->setTextFormat(Qt::RichText);
    topLabel->setOpenExternalLinks(true);
    topLabel->setAlignment(Qt::AlignCenter);

    // 创建控制播放进度的滑块
    Phonon::SeekSlider *seekSlider = new Phonon::SeekSlider(mediaObject, this);

    // 创建包含播放列表图标、显示时间标签和桌面歌词图标的工具栏
    QToolBar *widgetBar = new QToolBar(this);
    // 显示播放时间的标签
    timeLabel = new QLabel(tr("00:00 / 00:00"), this);
    timeLabel->setToolTip(tr("当前时间 / 总时间"));
    timeLabel->setAlignment(Qt::AlignCenter);
    timeLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    // 创建图标,用于控制是否显示播放列表
    QAction *PLAction = new QAction(tr("PL"), this);
    PLAction->setShortcut(QKeySequence("F4"));
    PLAction->setToolTip(tr("播放列表(F4)"));
    connect(PLAction, SIGNAL(triggered()), this, SLOT(setPlaylistShown()));
    // 创建图标,用于控制是否显示桌面歌词
    QAction *LRCAction = new QAction(tr("LRC"), this);
    LRCAction->setShortcut(QKeySequence("F2"));
    LRCAction->setToolTip(tr("桌面歌词(F2)"));
    connect(LRCAction, SIGNAL(triggered()), this, SLOT(setLrcShown()));
    // 添加到工具栏
    widgetBar->addAction(PLAction);
    widgetBar->addSeparator();
    widgetBar->addWidget(timeLabel);
    widgetBar->addSeparator();
    widgetBar->addAction(LRCAction);

    // 创建播放控制动作工具栏
    QToolBar *toolBar = new QToolBar(this);
    // 播放动作
    playAction = new QAction(this);
    playAction->setIcon(QIcon(":/images/play.png"));
    playAction->setText(tr("播放(F5)"));
    playAction->setShortcut(QKeySequence(tr("F5")));
    connect(playAction, SIGNAL(triggered()), this, SLOT(setPaused()));
    // 停止动作
    stopAction = new QAction(this);
    stopAction->setIcon(QIcon(":/images/stop.png"));
    stopAction->setText(tr("停止(F6)"));
    stopAction->setShortcut(QKeySequence(tr("F6")));
    connect(stopAction, SIGNAL(triggered()), mediaObject, SLOT(stop()));
    // 跳转到上一首动作
    skipBackwardAction = new QAction(this);
    skipBackwardAction->setIcon(QIcon(":/images/skipBackward.png"));
    skipBackwardAction->setText(tr("上一首(Ctrl+Left)"));
    skipBackwardAction->setShortcut(QKeySequence(tr("Ctrl+Left")));
    connect(skipBackwardAction, SIGNAL(triggered()), this, SLOT(skipBackward()));
    // 跳转到下一首动作
    skipForwardAction = new QAction(this);
    skipForwardAction->setIcon(QIcon(":/images/skipForward.png"));
    skipForwardAction->setText(tr("下一首(Ctrl+Right)"));
    skipForwardAction->setShortcut(QKeySequence(tr("Ctrl+Right")));
    connect(skipForwardAction, SIGNAL(triggered()), this, SLOT(skipForward()));
    // 打开文件动作
    QAction *openAction = new QAction(this);
    openAction->setIcon(QIcon(":/images/open.png"));
    openAction->setText(tr("播放文件(Ctrl+O)"));
    openAction->setShortcut(QKeySequence(tr("Ctrl+O")));
    connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));
    // 音量控制部件
    Phonon::VolumeSlider *volumeSlider = new Phonon::VolumeSlider(audioOutput, this);
    volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
    // 添加到工具栏
    toolBar->addAction(playAction);
    toolBar->addSeparator();
    toolBar->addAction(stopAction);
    toolBar->addSeparator();
    toolBar->addAction(skipBackwardAction);
    toolBar->addSeparator();
    toolBar->addAction(skipForwardAction);
    toolBar->addSeparator();
    toolBar->addWidget(volumeSlider);
    toolBar->addSeparator();
    toolBar->addAction(openAction);

    // 创建主界面布局管理器
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(topLabel);
    mainLayout->addWidget(seekSlider);
    mainLayout->addWidget(widgetBar);
    mainLayout->addWidget(toolBar);
    setLayout(mainLayout);

    // 在3-2中添加的代码
    connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
            this, SLOT(stateChanged(Phonon::State, Phonon::State)));

    // 以下是在3-3中添加的代码

    // 创建播放列表
    playlist = new MyPlaylist(this);
    connect(playlist, SIGNAL(cellClicked(int, int)), this, SLOT(tableClicked(int)));
    connect(playlist, SIGNAL(playlistClean()), this, SLOT(clearSources()));

    // 创建用来解析媒体的信息的元信息解析器
    metaInformationResolver = new Phonon::MediaObject(this);
    // 需要与AudioOutput连接后才能使用metaInformationResolver来获取歌曲的总时间
    Phonon::AudioOutput *metaInformationAudioOutput =
            new Phonon::AudioOutput(Phonon::MusicCategory, this);
    Phonon::createPath(metaInformationResolver, metaInformationAudioOutput);
    connect(metaInformationResolver, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
            this, SLOT(metaStateChanged(Phonon::State, Phonon::State)));

    connect(mediaObject, SIGNAL(currentSourceChanged(Phonon::MediaSource)),
            this, SLOT(sourceChanged(Phonon::MediaSource)));
    connect(mediaObject, SIGNAL(aboutToFinish()), this, SLOT(aboutToFinish()));

    // 初始化动作图标的状态
    playAction->setEnabled(false);
    stopAction->setEnabled(false);
    skipBackwardAction->setEnabled(false);
    skipForwardAction->setEnabled(false);
    topLabel->setFocus();

}