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 Playlist::OnPlOpen() { CFileDialog fd(TRUE,NULL,NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST, "M3U & PLS Playlists|*.m3u;*.pls|M3U Playlists|*.m3u|ShoutCast Playlists|*.pls|"); if (fd.DoModal() != IDOK) return; Clear(); OpenPlayList(fd.GetPathName()); m_cur_entry = 0; Play(); }
void Playlist::QueueURL(CString filename) { char *ext = (char *) strrchr(filename, '.'); if (ext && (!stricmp(ext, ".m3u") || !stricmp(ext, ".pls")) ) { OpenPlayList(filename); } else { PLEntry *ple = new PLEntry(filename); gf_list_add(m_entries, ple); } m_all_dead_entries=-1; }