MusicPlayer::MusicPlayer(QWidget *parent) : QMainWindow(parent), ui(new Ui::MusicPlayer) { ui->setupUi(this); Player = new QMediaPlayer(this); PlayList = new QMediaPlaylist; connect(Player,SIGNAL(positionChanged(qint64)),this,SLOT(PositionChanged(qint64))); connect(ui->LengthSlider,SIGNAL(sliderMoved(int)),this,SLOT(SetPosition(int))); connect(Player,SIGNAL(durationChanged(qint64)),this,SLOT(DurationChanged(qint64))); connect(Player,SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),this,SLOT(StatusChanged(QMediaPlayer::MediaStatus))); connect(ui->VolumeSlider,SIGNAL(valueChanged(int)),this,SLOT(SetVolume(int))); connect(ui->button_start,SIGNAL(released()),this,SLOT(Play())); connect(ui->button_stop,SIGNAL(released()),this,SLOT(Stop())); connect(ui->button_next,SIGNAL(released()),this,SLOT(Next())); connect(ui->button_prev,SIGNAL(released()),this,SLOT(Prev())); connect(ui->button_add,SIGNAL(released()),this,SLOT(Add())); connect(ui->button_remove,SIGNAL(released()),this,SLOT(Remove())); connect(ui->playlist,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(PlaySelected(QModelIndex))); connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(SavePlayList())); connect(ui->actionLoad,SIGNAL(triggered()),this,SLOT(OpenPlayList())); Player->setPlaylist(PlayList); ui->VolumeSlider->setRange(0,100); ui->VolumeSlider->setValue(100); }
void PlayListModel::playSelected() { emit PlaySelected(); }