void CGUIWindowMusicPlayList::SavePlayList() { CStdString strNewFileName; if (CGUIDialogKeyboard::ShowAndGetInput(strNewFileName, g_localizeStrings.Get(16012), false)) { // need 2 rename it CStdString strFolder, strPath; URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath"), "music", strFolder); strNewFileName= CUtil::MakeLegalFileName( strNewFileName ); strNewFileName += ".m3u"; URIUtils::AddFileToFolder(strFolder, strNewFileName, strPath); // get selected item int iItem = m_viewControl.GetSelectedItem(); CStdString strSelectedItem = ""; if (iItem >= 0 && iItem < m_vecItems->Size()) { CFileItemPtr pItem = m_vecItems->Get(iItem); if (!pItem->IsParentFolder()) { GetDirectoryHistoryString(pItem.get(), strSelectedItem); } } CStdString strOldDirectory = m_vecItems->GetPath(); m_history.SetSelectedItem(strSelectedItem, strOldDirectory); CPlayListM3U playlist; for (int i = 0; i < (int)m_vecItems->Size(); ++i) { CFileItemPtr pItem = m_vecItems->Get(i); // Musicdatabase items should contain the real path instead of a musicdb url // otherwise the user can't save and reuse the playlist when the musicdb gets deleted if (pItem->IsMusicDb()) pItem->SetPath(pItem->GetMusicInfoTag()->GetURL()); playlist.Add(pItem); } CLog::Log(LOGDEBUG, "Saving music playlist: [%s]", strPath.c_str()); playlist.Save(strPath); Update(m_vecItems->GetPath()); // need to update } }
void CGUIWindowMusicPlayList::SavePlayList() { std::string strNewFileName; if (CGUIKeyboardFactory::ShowAndGetInput(strNewFileName, CVariant{g_localizeStrings.Get(16012)}, false)) { // need 2 rename it std::string strFolder = URIUtils::AddFileToFolder(CSettings::GetInstance().GetString(CSettings::SETTING_SYSTEM_PLAYLISTSPATH), "music"); strNewFileName = CUtil::MakeLegalFileName(strNewFileName); strNewFileName += ".m3u"; std::string strPath = URIUtils::AddFileToFolder(strFolder, strNewFileName); // get selected item int iItem = m_viewControl.GetSelectedItem(); std::string strSelectedItem = ""; if (iItem >= 0 && iItem < m_vecItems->Size()) { CFileItemPtr pItem = m_vecItems->Get(iItem); if (!pItem->IsParentFolder()) { GetDirectoryHistoryString(pItem.get(), strSelectedItem); } } std::string strOldDirectory = m_vecItems->GetPath(); m_history.SetSelectedItem(strSelectedItem, strOldDirectory); CPlayListM3U playlist; for (int i = 0; i < (int)m_vecItems->Size(); ++i) { CFileItemPtr pItem = m_vecItems->Get(i); // Musicdatabase items should contain the real path instead of a musicdb url // otherwise the user can't save and reuse the playlist when the musicdb gets deleted if (pItem->IsMusicDb()) pItem->SetPath(pItem->GetMusicInfoTag()->GetURL()); playlist.Add(pItem); } CLog::Log(LOGDEBUG, "Saving music playlist: [%s]", strPath.c_str()); playlist.Save(strPath); Refresh(); // need to update } }
/// \brief Save current playlist to playlist folder void CGUIWindowVideoPlaylist::SavePlayList() { CStdString strNewFileName; if (CGUIKeyboardFactory::ShowAndGetInput(strNewFileName, g_localizeStrings.Get(16012), false)) { // need 2 rename it CStdString strPath, strFolder; URIUtils::AddFileToFolder(g_guiSettings.GetString("system.playlistspath"), "video", strFolder); strNewFileName = CUtil::MakeLegalFileName(strNewFileName); strNewFileName += ".m3u"; URIUtils::AddFileToFolder(strFolder, strNewFileName, strPath); CPlayListM3U playlist; playlist.Add(*m_vecItems); CLog::Log(LOGDEBUG, "Saving video playlist: [%s]", strPath.c_str()); playlist.Save(strPath); } }