// _SetItemPosition void PickMoveCommand::_SetItemPosition(int64 startFrame, uint32 track) { Playlist* list = fItem->Parent(); AutoNotificationSuspender _(list); fItem->SuspendNotifications(true); // undo any changes to other items on the (old) track // (that's the track that our item is currently on) if (fPushedBackFrames > 0) { list->MoveItems(fPushedBackStart, -fPushedBackFrames, fItem->Track(), fItem); fPushedBackFrames = 0; // at this point, nothing is pushed around anymore } // do the change to our item fItem->SetTrack(track); fItem->SetStartFrame(startFrame); // push other items arround to make room int64 start = fItem->StartFrame(); int64 end = start + fItem->Duration(); list->MakeRoom(start, end, track, fItem, &fPushedBackStart, &fPushedBackFrames); // TODO: not nice that this is done here instead of "automatic" list->ItemsChanged(); fItem->SuspendNotifications(false); }
void ApiComponent::getPlaylistFromReply(QNetworkReply *reply) { QDomDocument domDocument; domDocument.setContent(reply->readAll()); QDomElement responseElement = domDocument.firstChildElement(); //! <response list = true> QDomNode itemNode = responseElement.firstChildElement(); //! <audio> Playlist playlist; while(!itemNode.isNull()) { PlaylistItem data; QString const artist = itemNode.toElement().elementsByTagName("artist").item(0).toElement().text(); QString const title = itemNode.toElement().elementsByTagName("title").item(0).toElement().text(); QString const duration = itemNode.toElement().elementsByTagName("duration").item(0).toElement().text(); QString const url = itemNode.toElement().elementsByTagName("url").item(0).toElement().text(); if (!artist.isEmpty() && !title.isEmpty() && !duration.isEmpty() && !url.isEmpty()) { data[Artist] = artist; data[Title] = title; data[Duration] = duration; data[Url] = url; playlist.push_back(data); } itemNode = itemNode.nextSibling(); } reply->deleteLater(); emit playlistReceived(playlist); }
void LibSpotifyPlaybackHandler::loadPlaylist( const Playlist& playlist, int startIndex ) { playQueue_.clear(); currentlyPlayingFromName_ = playlist.getName(); currentlyPlayingFromUri_ = playlist.getLink(); playQueue_.insert(playQueue_.end(), playlist.getTracks().begin(), playlist.getTracks().end()); playQueueIter_ = playQueue_.begin(); if ( startIndex >= 0 ) { while ( ( playQueueIter_ != playQueue_.end() ) && ( (*playQueueIter_).getIndex() != startIndex ) ) playQueueIter_++; if ( playQueueIter_ != playQueue_.end() && isShuffle ) { Track first = *playQueueIter_; playQueue_.erase(playQueueIter_); shuffle(); playQueue_.push_front(first); playQueueIter_ = playQueue_.begin(); } } else if ( isShuffle ) { shuffle(); } }
QStringList OverviewPlaylistWidget::LetUserSelectMediaFile(QWidget *pParent, QString pDescription, bool pMultipleFiles) { QStringList tResult; LOGEX(OverviewPlaylistWidget, LOG_VERBOSE, "Current data directory is \"%s\"", CONF.GetDataDirectory().toStdString().c_str()); if (pMultipleFiles) tResult = QFileDialog::getOpenFileNames(pParent, pDescription, CONF.GetDataDirectory(), sLoadMediaFilters, &sAllLoadMediaFilter, CONF_NATIVE_DIALOGS); else { tResult = QStringList(QFileDialog::getOpenFileName(pParent, pDescription, CONF.GetDataDirectory(), sLoadMediaFilters, &sAllLoadMediaFilter, CONF_NATIVE_DIALOGS)); // use the file parser to avoid playlists and resolve them to one single entry if (!tResult.isEmpty()) { Playlist tPlaylist = Parse(tResult.first(), ""); if (tPlaylist.size() > 0) tResult = QStringList(tPlaylist.first().Location); else tResult.clear(); } } if (!tResult.isEmpty()) CONF.SetDataDirectory(tResult.first().left(tResult.first().lastIndexOf('/'))); return tResult; }
int main(int argc, char *argv[]) { if (argc != PARAMS+1) usage(argv[0]); SimilarityStrategy similarity; SQLiteDatabase database(argv[1]); OptionList options("",1,3000,0,0,0,0,25); Generator generator(database, similarity); if(generator.initialization() == 0) { cout << "Erreur d'initialisation" << endl; exit(EXIT_FAILURE); } Playlist playlist = generator.generate(options); auto first = playlist.begin(); int i = 1; for(auto it = playlist.begin(); it != playlist.end(); ++it) cout << "Similarité entre le morceau 1 et " << i++ << " : " << similarity.compute(*first,*it) << endl; return EXIT_SUCCESS; }
iwMusicPlayer::~iwMusicPlayer() { // Playlist ggf. speichern, die ausgewählt ist, falls eine ausgewählt ist unsigned short selection = GetCtrl<ctrlComboBox>(2)->GetSelection(); // Entsprechende Datei speichern if(selection != 0xFFFF) { Playlist pl; pl.ReadMusicPlayer(this); std::string str(GetCtrl<ctrlComboBox>(2)->GetText(selection)); // RTTR-Playlisten dürfen nicht gelöscht werden if(str == "S2_Standard") return; if(!pl.SaveAs(GetFullPlaylistPath(str), true)) // Fehler, konnte nicht gespeichert werden WINDOWMANAGER.Show(new iwMsgbox(_("Error"), _("The specified file couldn't be saved!"), this, MSB_OK, MSB_EXCLAMATIONRED)); } // Entsprechenden Dateipfad speichern if(selection != 0xFFFF) SETTINGS.sound.playlist = GetCtrl<ctrlComboBox>(2)->GetText(selection); // Werte in Musikplayer bringen if(changed) { MUSICPLAYER.GetPlaylist().ReadMusicPlayer(this); MUSICPLAYER.Play(); } }
bool PlaylistDialog::loadListByFileName( QString filename ) { Playlist* pPlaylist = Playlist::load ( filename ); if ( ! pPlaylist ) { _ERRORLOG( "Error loading the playlist" ); return 0; } Preferences::get_instance()->setLastPlaylistFilename( filename ); Hydrogen* pEngine = Hydrogen::get_instance(); if ( pEngine->m_PlayList.size() > 0 ) { QTreeWidget* m_pPlaylist = m_pPlaylistTree; m_pPlaylist->clear(); for ( uint i = 0; i < pEngine->m_PlayList.size(); ++i ){ QTreeWidgetItem* m_pPlaylistItem = new QTreeWidgetItem ( m_pPlaylistTree ); m_pPlaylistItem->setText ( 0, pEngine->m_PlayList[i].m_hFile ); m_pPlaylistItem->setText ( 1, pEngine->m_PlayList[i].m_hScript ); if ( pEngine->m_PlayList[i].m_hScriptEnabled == "Use Script" ) { m_pPlaylistItem->setCheckState( 2, Qt::Checked ); } else { m_pPlaylistItem->setCheckState( 2, Qt::Unchecked ); } } QTreeWidgetItem* m_pPlaylistItem = m_pPlaylist->topLevelItem ( 0 ); m_pPlaylist->setCurrentItem ( m_pPlaylistItem ); pPlaylist->setSelectedSongNr( 0 ); setWindowTitle ( trUtf8 ( "Playlist Browser" ) + QString(" - ") + pPlaylist->get_filename() ); } return 1; }
void StopMenu::slotActivated( int index ) { Playlist* pl = Playlist::instance(); const int mode = pl->stopAfterMode(); switch( index ) { case NOW: Amarok::actionCollection()->action( "stop" )->activate(); if( mode == Playlist::StopAfterCurrent || mode == Playlist::StopAfterQueue ) pl->setStopAfterMode( Playlist::DoNotStop ); break; case AFTER_TRACK: pl->setStopAfterMode( mode == Playlist::StopAfterCurrent ? Playlist::DoNotStop : Playlist::StopAfterCurrent ); break; case AFTER_QUEUE: pl->setStopAfterMode( mode == Playlist::StopAfterQueue ? Playlist::DoNotStop : Playlist::StopAfterQueue ); break; } }
Playlist* PlaylistManager::AddPlaylist(int id, const QString& name, const QString& special_type, const QString& ui_path, bool favorite) { Playlist* ret = new Playlist(playlist_backend_, app_->task_manager(), library_backend_, id, special_type, favorite); ret->set_sequence(sequence_); ret->set_ui_path(ui_path); connect(ret, SIGNAL(CurrentSongChanged(Song)), SIGNAL(CurrentSongChanged(Song))); connect(ret, SIGNAL(PlaylistChanged()), SLOT(OneOfPlaylistsChanged())); connect(ret, SIGNAL(PlaylistChanged()), SLOT(UpdateSummaryText())); connect(ret, SIGNAL(EditingFinished(QModelIndex)), SIGNAL(EditingFinished(QModelIndex))); connect(ret, SIGNAL(Error(QString)), SIGNAL(Error(QString))); connect(ret, SIGNAL(PlayRequested(QModelIndex)), SIGNAL(PlayRequested(QModelIndex))); connect(playlist_container_->view(), SIGNAL(ColumnAlignmentChanged(ColumnAlignmentMap)), ret, SLOT(SetColumnAlignment(ColumnAlignmentMap))); playlists_[id] = Data(ret, name); emit PlaylistAdded(id, name, favorite); if (current_ == -1) { SetCurrentPlaylist(id); } if (active_ == -1) { SetActivePlaylist(id); } return ret; }
/* Ensures that the playlist given exists. * Only used to check for collisions * when creating a new playlist */ bool PlaylistManager::playlistExists(QString name) { Playlist *playlist = new Playlist(name); bool b = playlist->exists(); return b; }
void PlaylistDialog::saveListAs() { QString sDirectory = Preferences::get_instance()->getDataDirectory() + "playlists/"; QFileDialog fd(this); fd.setFileMode ( QFileDialog::AnyFile ); fd.setFilter ( trUtf8 ( "Hydrogen Playlist (*.h2playlist)" ) ); fd.setAcceptMode ( QFileDialog::AcceptSave ); fd.setWindowTitle ( trUtf8 ( "Save Playlist" ) ); fd.setDirectory ( sDirectory ); QString defaultFilename = "untitled.h2playlist"; fd.selectFile ( defaultFilename ); if ( fd.exec() != QDialog::Accepted ){ return; } QString filename = fd.selectedFiles().first(); Playlist* pPlaylist = Playlist::get_instance(); if ( ! pPlaylist->save ( filename ) ){ return; } Playlist::get_instance()->setIsModified(false); setWindowTitle ( trUtf8 ( "Playlist Browser" ) + QString(" - ") + filename ); }
/* * Remove a song from the queue. * * Returns true on success, false on failure. */ bool Control::remove(Songlist * list, Song * song) { Playlist * playlist; assert(song != NULL); assert(list != NULL); assert(list != _library); EXIT_IDLE; pms->log(MSG_DEBUG, 0, "Removing song with id=%d pos=%d uri=%s from list %s.\n", song->id, song->pos, song->file.c_str(), list->filename.c_str()); /* Remove song from queue */ if (list == _queue) { // All songs must have ID's // FIXME: version requirement assert(song->id != MPD_SONG_NO_ID); return mpd_run_delete_id(conn->h(), song->id); } /* Remove song from stored playlist */ assert(list->filename.size() > 0); if (mpd_run_playlist_delete(conn->h(), (char *)list->filename.c_str(), song->pos)) { playlist = static_cast<Playlist *>(list); playlist->set_synchronized(false); } return get_error_bool(); }
/* Returns each line of a playlist in a QStringList */ QStringList PlaylistManager::getPlaylistContents(QString name) { Playlist *playlist = new Playlist(name); QStringList tracks = playlist->getContents(); return tracks; }
void PlaylistHistory::addToCurrent(const QList<QUrl> &filelist) { Playlist *playlist = current(); if (playlist != 0) playlist->append(filelist); else replaceCurrent(new Playlist(filelist)); }
void immediateAutoplayStart() { Playlist *p = Playlists::currentPlaylist(); AutoplayStructure settings; p->getAutoplaySettings(&settings); immediateAutoplayCount = min(settings.maxChirps, p->nChirps); // items to play immediateAutoplayTimeSeconds = 0; // will play immediately }
void CustomizeThemeDialog::toggleAlternativeBackgroundColor(bool b) { SettingsPrivate::instance()->setColorsAlternateBG(b); for (int i = 0; i < _mainWindow->tabPlaylists->count(); i++) { Playlist *p = _mainWindow->tabPlaylists->playlist(i); p->setAlternatingRowColors(b); } }
void PlaylistManager::newPlaylist(QString name, QStringList tracks) { Playlist *playlist = new Playlist(name); playlist->addTracks(tracks); //Reset Info so it finds the new playlist resetInfo(); emit resetPlaylists(); }
Playlist Read2Sources (const QString& path) { QFile file (path); if (!file.open (QIODevice::ReadOnly)) { qWarning () << Q_FUNC_INFO << "unable to open" << path << file.errorString (); return {}; } const auto& m3uDir = QFileInfo (path).absoluteDir (); QVariantMap lastMetadata; Playlist result; while (!file.atEnd ()) { const auto& line = file.readLine ().trimmed (); if (line.startsWith ('#')) { const auto& pair = ParseMetadata (line); if (!pair.first.isEmpty ()) lastMetadata [pair.first] = pair.second; continue; } const auto& url = QUrl::fromEncoded (line); auto src = QString::fromUtf8 (line); const auto mdGuard = std::shared_ptr<void> (nullptr, [&lastMetadata] (void*) { lastMetadata.clear (); }); #ifdef Q_OS_WIN32 if (url.scheme ().size () > 1) #else if (!url.scheme ().isEmpty ()) #endif { result.Append ({ url, lastMetadata }); continue; } src.replace ('\\', '/'); const QFileInfo fi (src); if (fi.isRelative ()) src = m3uDir.absoluteFilePath (src); if (fi.suffix () == "m3u" || fi.suffix () == "m3u8") result += Read2Sources (src); else result.Append ({ src, lastMetadata }); } return result; }
Playlist OpenMediaFolderDialog::playlist() const { Playlist list; for (int i=0; i<d->ui.list->count(); ++i) { const auto item = d->ui.list->item(i); if (item->checkState() == Qt::Checked) list.append(item->data(Path).toString()); } return list; }
int main() { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); Playlist MusicList; MusicList.Menu(); return(0); }
bool setSong( int songnumber ) { Hydrogen *pEngine = Hydrogen::get_instance(); Playlist *PL = Playlist::get_instance(); int asn = PL->getActiveSongNumber(); if(asn != songnumber && songnumber >= 0 && songnumber <= pEngine->m_PlayList.size()-1){ PL->setNextSongByNumber( songnumber ); } return true; }
void PlaylistListContainer::PlaylistPathChanged(int id, const QString& new_path) { // Update the path in the database app_->playlist_backend()->SetPlaylistUiPath(id, new_path); Playlist* playlist = app_->playlist_manager()->playlist(id); // Check the playlist exists (if it's not opened it's not in the manager) if (playlist) { playlist->set_ui_path(new_path); } }
void PlaylistDialog::o_downBClicked() { timer->stop(); Playlist* pList = Playlist::get_instance(); QTreeWidget* m_pPlaylist = m_pPlaylistTree; int length = m_pPlaylist->topLevelItemCount(); QTreeWidgetItem* m_pPlaylistItem = m_pPlaylistTree->currentItem(); int index = m_pPlaylist->indexOfTopLevelItem ( m_pPlaylistItem ); if ( index == length - 1){ timer->start( 1000 ); return; } QTreeWidgetItem* tmpPlaylistItem = m_pPlaylist->takeTopLevelItem ( index ); m_pPlaylist->insertTopLevelItem ( index +1, tmpPlaylistItem ); m_pPlaylist->setCurrentItem ( tmpPlaylistItem ); if ( pList->getSelectedSongNr() >= 0 ) pList->setSelectedSongNr( pList->getSelectedSongNr() +1 ); if (pList ->getActiveSongNumber() == index ){ pList->setActiveSongNumber( pList->getActiveSongNumber() +1 ); }else if ( pList->getActiveSongNumber() == index +1 ){ pList->setActiveSongNumber( pList->getActiveSongNumber() -1 ); } updatePlayListVector(); }
void PlaylistDialog::saveList() { Playlist* P = Playlist::get_instance(); if ( P->get_filename() == "") { // just in case! return saveListAs(); } if ( ! P->save ( P->get_filename() ) ) return; }
void PlaylistManager::delPlaylist(QString name) { Playlist *playlist = new Playlist(name); if(playlist->exists()) { playlist->deleteList(); } //Reset Info so it finds the new playlist resetInfo(); emit resetPlaylists(); }
QList< Playlist::Entry > Playlist::read( const QString &url, QString *name ) { QList< Entry > list; Playlist *playlist = create( url, ReadOnly, name ); if ( playlist ) { list = playlist->_read(); delete playlist; } return list; }
bool Playlist::write( const QList< Entry > &list, const QString &url, QString *name ) { bool OK = false; Playlist *playlist = create( url, WriteOnly, name ); if ( playlist ) { OK = playlist->_write( list ); delete playlist; } return OK; }
void DialogsProvider::OnPlaylist( wxCommandEvent& WXUNUSED(event) ) { /* Show/hide the playlist window */ if( !p_playlist_dialog ) p_playlist_dialog = new Playlist( p_intf, this ); if( p_playlist_dialog ) { p_playlist_dialog->ShowPlaylist( !p_playlist_dialog->IsShown() ); } }
Playlist* Playlist::load( const QString& filename ) { LocalFileMng fileMng; int ret = fileMng.loadPlayList( filename.toLocal8Bit().constData() ); if ( ret == 0 ) { Playlist* P = get_instance(); P->set_filename( filename ); return P; } return NULL; }
void PlaylistDialog::o_upBClicked() { timer->stop(); Playlist* pPlaylist = Playlist::get_instance(); QTreeWidget* pPlaylistTree = m_pPlaylistTree; QTreeWidgetItem* pPlaylistTreeItem = m_pPlaylistTree->currentItem(); int index = pPlaylistTree->indexOfTopLevelItem ( pPlaylistTreeItem ); if (index == 0 ){ timer->start( 1000 ); return; } QTreeWidgetItem* tmpPlaylistItem = pPlaylistTree->takeTopLevelItem ( index ); pPlaylistTree->insertTopLevelItem ( index -1, tmpPlaylistItem ); pPlaylistTree->setCurrentItem ( tmpPlaylistItem ); if ( pPlaylist->getSelectedSongNr() >= 0 ){ pPlaylist->setSelectedSongNr( pPlaylist->getSelectedSongNr() -1 ); } if ( pPlaylist->getActiveSongNumber() == index ){ pPlaylist->setActiveSongNumber( pPlaylist->getActiveSongNumber() -1 ); }else if ( pPlaylist->getActiveSongNumber() == index -1 ){ pPlaylist->setActiveSongNumber( pPlaylist->getActiveSongNumber() +1 ); } updatePlayListVector(); }