PluginPlaylist::PluginPlaylist(const QString &service, const QVariantMap &playlist, QObject *parent) : CTPlaylist(parent), m_request(new ResourcesRequest(this)) { loadPlaylist(service, playlist); connect(m_request, SIGNAL(finished()), this, SLOT(onRequestFinished())); }
QModelIndex KNMusicPlaylistManager::importPlaylist(const QString &filePath) { //Tried load the file first. KNMusicPlaylistModel *model=loadPlaylist(filePath); //Check if the model is loaded. if(model) { //Allocate a file path to model. model->allcateFilePath(); //Set the changed flag. model->setChanged(true); //Give back the index, import successfully. return m_playlistList->append(model); } //Use the playlist engine to parse the file. model=m_playlistEngine->read(filePath); //Check the model. if(model) { //Allocate a file path to model. model->allcateFilePath(); //Set the changed flag. model->setChanged(true); //If it's not null, add to playlist list, import successfully. return m_playlistList->append(model); } //Or else failed. return QModelIndex(); }
void PluginPlaylist::onRequestFinished() { if (m_request->status() == ResourcesRequest::Ready) { loadPlaylist(m_request->service(), m_request->result().toMap()); } emit statusChanged(status()); }
bool RequestAction_LoadPlaylist::executeAction() { auto id = getOptionValue("id"); auto value = getOptionValue("value"); auto trackIndexString = getOptionValue("trackIndex"); std::int32_t trackIndex = 0; if (!trackIndexString.empty()) trackIndex = Raumkernel::Tools::CommonUtil::toInt32(trackIndexString); if (trackIndex < 0) trackIndex = 0; // if we got an id we try to stop the playing for the id (which may be a roomUDN, a zoneUDM or a roomName) if (!id.empty()) { auto mediaRenderer = getVirtualMediaRenderer(id); if (!mediaRenderer) { logError("Room or Zone with ID: " + id + " not found!", CURRENT_FUNCTION); return false; } mediaRenderer->loadPlaylist(value, trackIndex, sync); } return true; }
void Player::loadPlaylist() { QString fileName = QFileDialog::getOpenFileName(this, tr("Select file"), QDir::homePath(), "*.plst"); if (fileName.isEmpty()) return; clearPlaylist(); if (!loadPlaylist(fileName)) QMessageBox::critical(this, tr("Error!"), tr("Failed to load playlist!")); }
void LibSpotifyPlaybackHandler::playAlbum( const Album& album, int startIndex ) { mtx_.lock(); currentlyPlayingFromType_ = ALBUM; loadPlaylist( album, startIndex ); if( enquedQueue_.empty() && ( playQueueIter_ != playQueue_.end() ) ) libSpotifyIf_.playTrack(*playQueueIter_); mtx_.unlock(); }
void LibSpotifyPlaybackHandler::playPlaylist( const Playlist& playlist, int startIndex ) { mtx_.lock(); currentlyPlayingFromType_ = PLAYLIST; loadPlaylist( playlist, startIndex ); if( enquedQueue_.empty() && ( playQueueIter_ != playQueue_.end() ) ) libSpotifyIf_.playTrack(*playQueueIter_); mtx_.unlock(); }
void TinyMainWindow::on_action_playlist_edit_triggered() { EditPlaylistDialog dlg(this, mpc()); if (dlg.exec() != QDialog::Accepted) return; QString name = dlg.name(); if (name.isEmpty()) return; if (!MusicPlayerClient::isValidPlaylistName(name)) { QMessageBox::warning(this, qApp->applicationName(), tr("The name is invalid.")); return; } loadPlaylist(name, dlg.forReplace()); }
bool LiveSource::switchToNext() { mSignalDiscontinuity = false; mOffsetBias += mSourceSize; mSourceSize = 0; if (mLastFetchTimeUs < 0 || getNowUs() >= mLastFetchTimeUs + 15000000ll || mPlaylistIndex == mPlaylist->size()) { int32_t nextSequenceNumber = mPlaylistIndex + mFirstItemSequenceNumber; if (!loadPlaylist(mLastFetchTimeUs < 0)) { LOGE("failed to reload playlist"); return false; } if (mLastFetchTimeUs < 0) { mPlaylistIndex = 0; } else { if (nextSequenceNumber < mFirstItemSequenceNumber || nextSequenceNumber >= mFirstItemSequenceNumber + (int32_t)mPlaylist->size()) { LOGE("Cannot find sequence number %d in new playlist", nextSequenceNumber); return false; } mPlaylistIndex = nextSequenceNumber - mFirstItemSequenceNumber; } mLastFetchTimeUs = getNowUs(); } AString uri; sp<AMessage> itemMeta; CHECK(mPlaylist->itemAt(mPlaylistIndex, &uri, &itemMeta)); LOGV("switching to %s", uri.c_str()); if (mSource->connect(uri.c_str()) != OK || mSource->getSize(&mSourceSize) != OK) { return false; } int32_t val; if (itemMeta->findInt32("discontinuity", &val) && val != 0) { mSignalDiscontinuity = true; } mPlaylistIndex++; return true; }
SoundManager::SoundManager() { // doThis(); printf("Initializing the Soundmanager\n"); mEchoAmount = 1.5f; song = NULL; fading = false; musicFadeTime = 0.0; musicFadeTimeCounter = 0.0; mTrack = 0; mTrackTime = 0; mMusicEcho = false; mInitFailed = false; result = FMOD::System_Create(&mSystem); checkErrors(); if(result != FMOD_OK) { mInitFailed = true; printf("FMOD Error!\n"); checkErrors(); } //printf("init system\n"); result = mSystem->init(64, (FMOD_INITFLAGS)(FMOD_INIT_NORMAL), NULL); if(result != FMOD_OK) mInitFailed = true; checkErrors(); //printf("make dsp\n"); result = mSystem->createDSPByType(FMOD_DSP_TYPE_REVERB, &mReverb); result = mSystem->createDSPByType(FMOD_DSP_TYPE_ECHO, &mEcho); mEcho->setParameter(0, 0.25); checkErrors(); int imax; result = mEcho->getNumParameters(&imax); checkErrors(); //printDSPParameterInfo(mEcho, "echo"); //printDSPParameterInfo(mReverb, "reverb"); unsigned int version; result = mSystem->getVersion(&version); if (version < FMOD_VERSION) { printf("Warning! You are using an old version of FMOD %08x. This program requires %08x\n", version, FMOD_VERSION); } mSilent = false; if(mInitFailed) mSilent = true; loadPlaylist("music/StarList.m3u"); std::cout<<"Soundmanager init complete" << std::endl; }
void QMediaPlayerPrivate::_q_error(int error, const QString &errorString) { Q_Q(QMediaPlayer); if (error == int(QMediaPlayer::MediaIsPlaylist)) { loadPlaylist(); } else { this->error = QMediaPlayer::Error(error); this->errorString = errorString; emit q->error(this->error); if (playlist) playlist->next(); } }
LRESULT CPlayList::OnBnClickedBtnLoadpl(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { unsigned int selFilter = 0; _TCHAR szFilter[] = _T("Tedplay playlists (*.pls)\0" "*.pls\0" "All Files (*.*)\0*.*\0\0"); WTL::CFileDialog wndFileDialog ( TRUE, NULL, NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER, szFilter, m_hWnd ); wndFileDialog.m_ofn.nFilterIndex = selFilter; if (IDOK == wndFileDialog.DoModal() ) { LPTSTR sFileName = wndFileDialog.m_ofn.lpstrFile; selFilter = wndFileDialog.m_ofn.nFilterIndex; playListView.DeleteAllItems(); loadPlaylist(sFileName); } return 0; }
/** * SLOT * Load songs from playlist * selected in QTreeView ui->tvPlaylists */ void MainWindow::loadPlaylist() { QStandardItemModel *model = (QStandardItemModel*)ui->tvPlaylists->model(); QStandardItem *item = model->itemFromIndex(ui->tvPlaylists->selectionModel()->currentIndex()); int data = item->data(DATA_KEY_PLAYLIST).toInt(); switch(data) { case DATA_SEARCH: loadSearchResults(); break; case DATA_EMPTY: break; // do nothing case DATA_HISTORY: loadHistory(); break; default: loadPlaylist(data); break; } }
void KNMusicPlaylistManager::loadPlaylistList() { //Set the loaded flag. m_isPlaylistListLoaded = true; //Get the playlist list file. QFile playlistListFile(m_playlistDirPath + PlaylistListFileName); //Check the existence and try to open the file in read only mode. if(!playlistListFile.exists() || !playlistListFile.open(QIODevice::ReadOnly)) { //Return back. return; } //Read and parse the json object from the playlist list file. QJsonObject playlistListObject= QJsonDocument::fromJson(playlistListFile.readAll()).object(); //Close the playlist list file. playlistListFile.close(); //Check the valid of the json object, then check the playlist list version, //we can only load one version. if(playlistListObject.isEmpty() || playlistListObject.value("Version").toInt()!=PlaylistListVersion) { //Return back. return; } //Get the playlist file path content. QJsonArray playlistPaths=playlistListObject.value("Playlists").toArray(); //A counter for those failed loaded file path. int failedCounter=0; //Generate those models. for(auto i=playlistPaths.constBegin(); i!=playlistPaths.constEnd(); ++i) { //Get the file path. QString playlistPath=(*i).toString(); //Load the playlist file to a playlist model, but don't need to parse //it. If it's failed to load the playlist, add it to failed path list. KNMusicPlaylistModel *model=loadPlaylist(playlistPath); //Check the model. if(model) { //Set the file path to the playlist pointer. model->setFilePath(playlistPath); } else { //Add the path to failed path list. ++failedCounter; } } //Check whether the failedPaths is empty, if it's not empty, a message box //should be display to hint the user there's invalid playlist. if(failedCounter>0) { //Push notifications for failed loaded playlist. knNotification->push( tr("%1 playlists cannot be loaded.").arg( QString::number(failedCounter)), tr("Those playlists may be moved, deleted or renamed.")); } }
// constructor: warm up all stuff MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) //,audioInfo(QAudioDeviceInfo::defaultInputDevice()) { // draws the ui ui->setupUi(this); // test for saving settings QCoreApplication::setOrganizationName("Agostinho"); /** some settings attempt */ QSettings settings; /*!<aloha */ settings.setValue("alo","maria"); // defines sample size equals to spectrum size sample.resize(SPECSIZE); // threads are as separate processes running within the same // program. for fft calculation, it is better to move it // to another thread to make the calcs faster. // moreover, it will not slow down the ui // fftThread = new QThread(this); calculator = new FFTCalc(); // calculator->moveToThread(fftThread); // launches the new media player player = new QMediaPlayer(); // starts a new playlist playlist = new QMediaPlaylist(); // starts the playlist model playlistModel = new PlaylistModel(this); // tell playlistmodel where is the playlist playlistModel->setPlaylist(playlist); // attach the listView to the playlistModel ui->listViewPlaylist->setModel(playlistModel); // set current index to the first element ui->listViewPlaylist->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0)); loadPlaylist(); // attachs the playlist to the player player->setPlaylist(playlist); // playlist plays in loop mode. It restarts after last song has finished playing. playlist->setPlaybackMode(QMediaPlaylist::Loop); // this allow the user to select the media it wants to play connect(ui->listViewPlaylist, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(goToItem(QModelIndex))); // if some metadata changed for media, display it somewhere // it seems not work on windows // but works for linux :) connect(player,SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged())); // the media status changed (new stream has arrived) connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(mediaStatusChanged(QMediaPlayer::MediaStatus))); // the user selected a new position on music to play // perharps using some scrollbar connect(this,SIGNAL(positionChanged(qint64)), player,SLOT(setPosition(qint64))); connect(player,SIGNAL(volumeChanged(int)), ui->control,SLOT(onVolumeChanged(int))); connect(player,SIGNAL(stateChanged(QMediaPlayer::State)), SLOT(mediaStateChanged(QMediaPlayer::State))); // that is the audio probe object that "listen to" // the music. It will help with fft stuff probe = new QAudioProbe(); // fft is delivered using a QVector<double> but // signal/slot scheme does not recognizes this type by default // therefore, we have to register it qRegisterMetaType< QVector<double> >("QVector<double>"); // here goes the control unit event handlers connect(ui->control, SIGNAL(playPause()), this, SLOT(playPause())); connect(ui->control, SIGNAL(prev()), this, SLOT(prev())); connect(ui->control, SIGNAL(next()), this, SLOT(next())); connect(this, SIGNAL(playPauseChanged(bool)), ui->control,SLOT(onPlayerStateChanged(bool))); // when the music position changes on player, it has to be // informed to the control unit to redraw it ui connect(player, SIGNAL(positionChanged(qint64)), ui->control,SLOT(onElapsedChanged(qint64))); // fft goes here... // if a new audio buffer is ok, we have to make some // calcs (fft) to display the spectrum connect(probe, SIGNAL(audioBufferProbed(QAudioBuffer)), this, SLOT(processBuffer(QAudioBuffer))); // when fft is available, we deliver it to // the visualization widget connect(this, SIGNAL(spectrumChanged(QVector<double>&)), ui->visualizer,SLOT(loadSamples(QVector<double>&))); // communicate the left and right audio levels... // ...mean levels connect(this, SIGNAL(levels(double,double)), ui->visualizer,SLOT(loadLevels(double,double))); // when fft is available, we deliver it to // the visualization widget //connect(this, SIGNAL(spectrumChanged(QVector<double>&)), // ui->glVisualizer,SLOT(loadSamples(QVector<double>&))); // communicate the left and right audio levels... // ...mean levels //connect(this, SIGNAL(levels(double,double)), // ui->glVisualizer,SLOT(loadLevels(double,double))); // if the user selected a new position on stream to play // we have to tell it to the player connect(ui->control, SIGNAL(elapsedSelected(qint64)), player, SLOT(setPosition(qint64))); // changing audio volume connect(ui->control, SIGNAL(volumeSelected(int)), player, SLOT(setVolume(int))); // calculator is the thead that calcs the ffts we need to display // every time a new spectrum is available, the calculator // emits a calculatedSpectrum signal connect(calculator, SIGNAL(calculatedSpectrum(QVector<double>)), this, SLOT(spectrumAvailable(QVector<double>))); connect(ui->library,SIGNAL(addMediaToPlayList(QString)), SLOT(onAddMediaToPlayList(QString))); // tells the probe what to probe probe->setSource(player); // load directories to library connect(ui->actionLoadDirectory,SIGNAL(triggered()),this,SLOT(onAddFolderToLibrary())); // load a single file to library connect(ui->actionLoadFile,SIGNAL(triggered()),this,SLOT(loadMedia())); // it connects the signals emiteds via the visualizer to the buttons (ui->control) and the lightCycle(ui->widgetInfo) connect(ui->visualizer,SIGNAL(trocaCor(QColor)),ui->control,SLOT(onColorChanged(QColor))); connect(ui->visualizer,SIGNAL(trocaCor(QColor)),ui->widgetInfo,SLOT(changedColor(QColor))); //this->setStyleSheet(QString("QMainWindow {background-color: black}")); }
Player::Player(QWidget *parent): QMainWindow(parent), _ui(new Ui::Player), _player(new Phonon::MediaObject(this)), _audioOutput(new Phonon::AudioOutput(Phonon::MusicCategory, this)), _trayIcon(new QSystemTrayIcon(this)), _isStopped(false), _isPaused(false), _artistToPlaylistAction(new QAction(tr("Add to playlist"), this)), _artistsMenu(new QMenu(this)), _albumToPlaylistAction(new QAction(tr("Add to playlist"), this)), _albumsMenu(new QMenu(this)), _trackToPlaylistAction(new QAction(tr("Add to playlist"), this)), _tracksMenu(new QMenu(this)), _removeTrackAction(new QAction(tr("Remove track"), this)), _playlistMenu(new QMenu(this)), _playAction(new QAction(tr("Play"), this)), _pauseAction(new QAction(tr("Pause"), this)), _playNextAction(new QAction(tr("Play next"), this)), _playPrevAction(new QAction(tr("Play previous"), this)), _stopAction(new QAction(tr("Stop"), this)), _trayMenu(new QMenu(this)), _lastFMDialog(new LastFMAuthDialog(this)) { _ui->setupUi(this); this->setWindowIcon(QIcon(":/icon.png")); this->setWindowTitle(qApp->applicationName()); _ui->pauseButton->setHidden(true); fixHeader(_ui->tracks->horizontalHeader()); fixHeader(_ui->playlist->horizontalHeader()); _ui->tracks->verticalHeader()->setDefaultSectionSize(_ui->artists->sizeHintForRow(0) + 4); _ui->playlist->verticalHeader()->setDefaultSectionSize(_ui->artists->sizeHintForRow(0) + 4); _ui->previousButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipBackward)); _ui->playButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPlay)); _ui->pauseButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPause)); _ui->stopButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaStop)); _ui->nextButton->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipForward)); _playPrevAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipBackward)); _playAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPlay)); _pauseAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaPause)); _pauseAction->setVisible(false); _stopAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaStop)); _playNextAction->setIcon(qApp->style()->standardIcon(QStyle::SP_MediaSkipForward)); _ui->actionQuit->setIcon(qApp->style()->standardIcon(QStyle::SP_DialogCloseButton)); _trayMenu->addAction(_playAction); _trayMenu->addAction(_pauseAction); _trayMenu->addAction(_playPrevAction); _trayMenu->addAction(_playNextAction); _trayMenu->addAction(_stopAction); _trayMenu->addAction(_ui->actionQuit); _trayIcon->setContextMenu(_trayMenu); _trayIcon->setIcon(QIcon(":/icon.png")); _trayIcon->show(); Phonon::createPath(_player, _audioOutput); _ui->seekSlider->setMediaObject(_player); _ui->volumeSlider->setAudioOutput(_audioOutput); _artistsMenu->addAction(_artistToPlaylistAction); _albumsMenu->addAction(_albumToPlaylistAction); _tracksMenu->addAction(_trackToPlaylistAction); _playlistMenu->addAction(_removeTrackAction); connect(_ui->actionQuit, SIGNAL(triggered()), qApp, SLOT(quit())); connect(_ui->actionAdd_directory, SIGNAL(triggered()), this, SLOT(addDirToLibrary())); connect(_ui->actionAdd_files, SIGNAL(triggered()), this, SLOT(addFilesToLibrary())); connect(_ui->actionClear_playlist, SIGNAL(triggered()), this, SLOT(clearPlaylist())); connect(_ui->actionLoad_playlist, SIGNAL(triggered()), this, SLOT(loadPlaylist())); connect(_ui->actionSave_playlist, SIGNAL(triggered()), this, SLOT(savePlaylist())); connect(_ui->nextButton, SIGNAL(clicked()), this, SLOT(playNext())); connect(_ui->playButton, SIGNAL(clicked()), this, SLOT(play())); connect(_ui->tracks, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(playSelected())); connect(_ui->playlist, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(playSelected())); connect(_ui->stopButton, SIGNAL(clicked()), this, SLOT(stop())); connect(_ui->pauseButton, SIGNAL(clicked()), this, SLOT(pause())); connect(_ui->stopButton, SIGNAL(clicked()), _player, SLOT(stop())); connect(_ui->previousButton, SIGNAL(clicked()), this, SLOT(playPrevious())); connect(_playAction, SIGNAL(triggered()), this, SLOT(play())); connect(_pauseAction, SIGNAL(triggered()), _player, SLOT(pause())); connect(_stopAction, SIGNAL(triggered()), _player, SLOT(stop())); connect(_playNextAction, SIGNAL(triggered()), this, SLOT(playNext())); connect(_playPrevAction, SIGNAL(triggered()), this, SLOT(playPrevious())); connect(_ui->artists, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showArtistsContextMenu(const QPoint &))); connect(_ui->albums, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showAlbumsContextMenu(const QPoint &))); connect(_ui->tracks, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showTracksContextMenu(const QPoint &))); connect(_ui->playlist, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showPlaylistContextMenu(const QPoint &))); connect(DataBase::instance(), SIGNAL(albumsUpdated()), this, SLOT(updateAlbums())); connect(DataBase::instance(), SIGNAL(artistsUpdated()), this, SLOT(updateArtists())); connect(DataBase::instance(), SIGNAL(tracksUpdated()), this, SLOT(updateTracks())); connect(_ui->artists, SIGNAL(currentRowChanged(int)), this, SLOT(updateAlbums())); connect(_ui->albums, SIGNAL(currentRowChanged(int)), this, SLOT(updateTracks())); connect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); connect(_player, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(stateChanged(Phonon::State,Phonon::State))); connect(_player, SIGNAL(tick(qint64)), this, SLOT(tick(qint64))); connect(_player, SIGNAL(totalTimeChanged(qint64)), this, SLOT(totalTimeChanged(qint64))); connect(_player, SIGNAL(finished()), this, SLOT(trackFinished())); connect(_ui->actionSettings, SIGNAL(triggered()), _lastFMDialog, SLOT(show())); connect(_ui->actionScrobbling, SIGNAL(toggled(bool)), this, SLOT(scrobblingToggled(bool))); connect(Settings::instance(), SIGNAL(scrobblingChanged(bool)), _ui->actionScrobbling, SLOT(setChecked(bool))); _allArtists = _ui->artists->item(0); _allArtists->setText(ALL); _allAlbums = _ui->albums->item(0); _allAlbums->setText(ALL); loadPlaylist(RECENTPLAYLIST); _ui->actionScrobbling->setChecked(Settings::instance()->isScrobblingEnabled()); _ui->actionSettings->setEnabled(Settings::instance()->isScrobblingEnabled()); scrobblingToggled(Settings::instance()->isScrobblingEnabled()); }
void checkEndSound() { if(getMode() != SOUNDPLAYER) { return; } if(!soundLoaded) { char ext[256]; char tmp[256]; strcpy(tmp,getFileName()); separateExtension(tmp,ext); strlwr(ext); if(strcmp(ext,".pls") == 0 || strcmp(ext,".m3u") == 0) { sndMode = TYPE_PLS; if(loadPlaylist(getFileName(), &curPlaylist)) { DRAGON_chdir("/"); loadSound(curPlaylist.urlEntry[0].data); plsPos = 0; } else { destroyRandomList(); exitSound(0,0); return; } } else { sndMode = TYPE_NORMAL; bool success = loadSound(getFileName()); if(soundMode == SOUND_ONESHOT || firstTime) { if(success == false) { destroyRandomList(); exitSound(0,0); return; } } else { while(!success) { getNextSoundInternal(false); if(getMode() == BROWSER) // cover for no files found { destroyRandomList(); return; } success = loadSound(getFileName()); } } } sampleWidth = (getSoundLength() / 236); soundLoaded = true; } firstTime = false; if(getState() == STATE_STOPPED || getState() == STATE_UNLOADED) { if(sndMode == TYPE_NORMAL) { if(soundMode == SOUND_ONESHOT) { exitSound(0,0); } else { getNextSoundInternal(true); } } if(sndMode == TYPE_PLS) { if(!queued) { if(plsPos == curPlaylist.numEntries - 1) plsPos = 0; else plsPos++; } DRAGON_chdir("/"); loadSound(curPlaylist.urlEntry[plsPos].data); queued = false; } } }
PlaylistWindow::PlaylistWindow(QMediaPlaylist *playList, QWidget *parent, int playModel) : QWidget(parent) { this->setWindowTitle("Playlist"); this->setWindowIcon(QIcon(":/image/playlist.ico")); playBackMode = playModel; playlist = playList; playlist->setPlaybackMode((QMediaPlaylist::PlaybackMode)playBackMode); listWidget = new QListWidget(this); loadPlaylist(); this->doubleClicked = false; //----布局--------------------------------------- QHBoxLayout *topLayout = new QHBoxLayout; topLayout->addWidget(listWidget); QHBoxLayout *bottomLayout = new QHBoxLayout; playType = new QPushButton(QIcon(":image/seq.png"),""); playType->setToolTip("点击切换播放模式"); search_edit = new QLineEdit(); search_btn = new QPushButton(QIcon(":image/search.ico"),""); search_btn->setToolTip("搜索"); addBtn = new QPushButton(QIcon(":image/openfile.ico"),""); addBtn->setToolTip("添加"); delBtn = new QPushButton(QIcon(":image/rmfile.ico"), ""); delBtn->setToolTip("移除"); clearBtn = new QPushButton(QIcon(":image/clear.ico"),""); clearBtn->setToolTip("清空"); bottomLayout->addWidget(playType); bottomLayout->addWidget(search_edit); bottomLayout->addWidget(search_btn); bottomLayout->addWidget(addBtn); bottomLayout->addWidget(delBtn); bottomLayout->addWidget(clearBtn); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(topLayout); mainLayout->addLayout(bottomLayout); this->setLayout(mainLayout); //-----signal-start------------ connect(listWidget,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*))); connect(listWidget,SIGNAL(currentRowChanged(int)),this,SIGNAL(currentRowChanged(int))); connect(listWidget,SIGNAL(currentTextChanged(QString)),this,SIGNAL(currentTextChanged(QString))); connect(listWidget,SIGNAL(itemActivated(QListWidgetItem*)),this,SIGNAL(itemActivated(QListWidgetItem*))); connect(listWidget,SIGNAL(itemChanged(QListWidgetItem*)),this,SIGNAL(itemChanged(QListWidgetItem*))); connect(listWidget,SIGNAL(itemClicked(QListWidgetItem*)),this,SIGNAL(itemClicked(QListWidgetItem*))); //connect(listWidget,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SIGNAL(itemDoubleClicked(QListWidgetItem*))); connect(listWidget,SIGNAL(itemEntered(QListWidgetItem*)),this,SIGNAL(itemEntered(QListWidgetItem*))); connect(listWidget,SIGNAL(itemPressed(QListWidgetItem*)),this,SIGNAL(itemPressed(QListWidgetItem*))); connect(listWidget,SIGNAL(itemSelectionChanged()),this,SIGNAL(itemSelectionChanged())); connect(delBtn,SIGNAL(clicked(bool)),this,SLOT(removeItems())); connect(clearBtn,SIGNAL(clicked(bool)),this,SLOT(clear())); connect(search_btn,SIGNAL(clicked(bool)),this,SLOT(searchItem())); connect(listWidget,SIGNAL(clicked(QModelIndex)),this,SLOT(clearSearch())); connect(listWidget,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(setPlaylistIndex(QListWidgetItem*))); connect(playlist,SIGNAL(currentIndexChanged(int)),this,SLOT(setItemPlay(int))); connect(playType,SIGNAL(clicked(bool)),this,SLOT(setPlayMode())); connect(addBtn,SIGNAL(clicked(bool)),this,SLOT(openfiles())); //------signal-end------------ }
void TinyMainWindow::on_action_playlist_quick_load_2_triggered() { loadPlaylist("_quick_save_2_", true); }