示例#1
0
void RemoteServer::onClientShuffle(int shuffle)
{
    if (shuffle == 0)
        emit shuffleOff();
    if (shuffle == 1)
        emit shuffleOn();
}
示例#2
0
 MainWindow::MainWindow()
 {
     //serv = new Server(*this);

     setWindowTitle("Music Player");

     menuFile = menuBar()->addMenu(tr("&File"));
     actionPlay = new QAction(QIcon(":images/play.png"),"Play", this);
     connect(actionPlay, SIGNAL(triggered()), this, SLOT(play()));
     menuFile->addAction(actionPlay);
     actionPause = new QAction(QIcon(":images/pause.png"),"Pause", this);
     connect(actionPause, SIGNAL(triggered()), this, SLOT(pause()));
     menuFile->addAction(actionPause);
     actionStop = new QAction(QIcon(":images/stop.png"),"Stop", this);
     connect(actionStop, SIGNAL(triggered()), this, SLOT(stop()));
     menuFile->addAction(actionStop);

     tbar = addToolBar(tr("Control Bar"));

     buttonPlay = new QToolButton;
     buttonPlay->setIcon(QIcon(":images/play.png"));
     connect(buttonPlay, SIGNAL(clicked()), this, SLOT(play()));
     buttonPause = new QToolButton;
     buttonPause->setIcon(QIcon(":images/pause.png"));
     connect(buttonPause, SIGNAL(clicked()), this, SLOT(pause()));
     buttonStop = new QToolButton;
     buttonStop->setIcon(QIcon(":images/stop.png"));
     connect(buttonStop, SIGNAL(clicked()), this, SLOT(stop()));
     buttonPrevious = new QToolButton;
     buttonPrevious->setIcon(QIcon(":images/prev.png"));
     connect(buttonPrevious, SIGNAL(clicked()), this, SLOT(previous()));
     buttonNext = new QToolButton;
     buttonNext->setIcon(QIcon(":images/next.png"));
     connect(buttonNext, SIGNAL(clicked()), this, SLOT(next()));
     buttonShuffle = new QToolButton;
     buttonShuffle->setIcon(QIcon(":images/shuffle.png"));
     connect(buttonShuffle, SIGNAL(clicked()), this, SLOT(shuffle()));
     buttonShuffleOff = new QToolButton;
     buttonShuffleOff->setIcon(QIcon(":images/shuffleoff.png"));
     connect(buttonShuffleOff, SIGNAL(clicked()), this, SLOT(shuffleOff()));
     buttonClearPl = new QToolButton;
     buttonClearPl->setIcon(QIcon(":images/clearpl.png"));
     connect(buttonClearPl, SIGNAL(clicked()), this, SLOT(clearPl()));
     QToolButton *addDir = new QToolButton;
     addDir->setIcon(QIcon(":images/addfolder.png"));
     connect(addDir, SIGNAL(clicked()), this, SLOT(addDir()));
     QToolButton *addFile = new QToolButton;
     addFile->setIcon(QIcon(":images/addfiles.png"));
     connect(addFile, SIGNAL(clicked()), this, SLOT(addFile()));
     QToolButton *runServer = new QToolButton;
     runServer->setIcon(QIcon(":images/server.png"));
     connect(runServer, SIGNAL(clicked()), this, SLOT(runServer()));

     progressSlider = new QSlider(Qt::Horizontal, this);
     volumeSlider = new QSlider(Qt::Horizontal, this);
     volumeLabel = new QLabel(this);
     durationLabel = new QLabel(this);
     nowPlayingLabel = new QLabel(this);
     volumeLabel->setText("Volume");
     tbar->addWidget(buttonPlay);
     tbar->addSeparator();
     tbar->addWidget(buttonPause);
     tbar->addSeparator();
     tbar->addWidget(buttonStop);
     tbar->addSeparator();
     tbar->addWidget(buttonPrevious);
     tbar->addSeparator();
     tbar->addWidget(buttonNext);
     tbar->addSeparator();
     tbar->addWidget(buttonShuffle);
     tbar->addSeparator();
     tbar->addWidget(buttonShuffleOff);
     tbar->addSeparator();
     tbar->addWidget(buttonClearPl);
     tbar->addSeparator();
     tbar->addWidget(addFile);
     tbar->addSeparator();
     tbar->addWidget(addDir);
     tbar->addSeparator();
     tbar->addWidget(runServer);
     tbar->addSeparator();
     tbar->addWidget(volumeLabel);
     tbar->addWidget(volumeSlider);
     tbar->addSeparator();
     barProgress = addToolBar(tr("Progress Bar"));
     barProgress->addWidget(progressSlider);
     barProgress->addSeparator();
     barProgress->addWidget(durationLabel);
     insertToolBarBreak(barProgress);
     statusBar()->addWidget(nowPlayingLabel);
     player = new QMediaPlayer;
     playlist = new QMediaPlaylist(player);
     playlist->setCurrentIndex(0);
     playlist->setPlaybackMode(QMediaPlaylist::Loop);
     tableWidget = new QListWidget(this);
     setCentralWidget(tableWidget);
     player->setPlaylist(playlist);
     player->setVolume(100);
     volumeSlider->setTickPosition(QSlider::TicksRight);
     volumeSlider->setValue(100);
     connect(volumeSlider, SIGNAL(valueChanged(int)), player, SLOT(setVolume(int)));
     connect(player,SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64)));
     connect(player,SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(setDuration()));
     connect(player,SIGNAL(positionChanged(qint64)), this, SLOT(setDuration()));
     connect(progressSlider,SIGNAL(sliderMoved(int)), this, SLOT(setPosition(int)));
     connect(playlist, SIGNAL(currentMediaChanged(QMediaContent)), this, SLOT(checkAv()));
     connect(tableWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(objectClicked(QListWidgetItem*)));
     checkPlItems();

 }