nach drücken der ? taste erscheint der filebrowser, wo man ein Verzeichnis auswählen kann (OK wählt das markierte Verzeichnis). Danach kann man den Dateinamen eingeben, .m3u wird automatisch drangehängt. Alternativ kann man auch eine bestehende .m3u auswählen.
Die generierte Datei sollte relative Pfade enthalten und kann auch wieder über das normale hinzufügen im audioplayer geladen werden. wenn man dann allerdings nochmal eine playliste aus diesen .mp3s erstellt, dann sind die neuen relativen pfade mitunter etwas umständlich, sie können zb so aussehen:
../tmp/../mnt/MP3s/abd.mp3
das liegt daran, dass der Audioplayer die relativen pfade geladen hat und ich diese nur noch an den Speicherungsort der playlist anpasse.
Testen konnte ich das speichern auf ein nfs-share nicht, da es da wohl ein problem mit den berechtigungen gab (vermutlich root-squash, war jetzt aber zu faul, da rumzuprobieren. es sollte auf jeden fall gehen

Hier ein diff auf das aktuelle (01:00 Uhr) CVS, wobei ich erstmal verstehen musste, wie sich die localize-Änderungen von thegoodguy auf mich auswirken

Die gamelist.cpp hat auch nicht mehr kompiliert, das Ziel der Änderung habe ich nicht ganz verstanden...
Ach ja, da ich nicht so der C Kenner bin, vielleicht nochmal auf die char-Buffer/Arrays schauen


Ich hoffe mal das ist alles, damit es kompiliert und auch funktioniert

ciao,
ChakaZulu
Code: Alles auswählen
Index: data/locale/deutsch.locale
===================================================================
RCS file: /cvs/tuxbox/apps/tuxbox/neutrino/data/locale/deutsch.locale,v
retrieving revision 1.306
diff -u -r1.306 deutsch.locale
--- a/data/locale/deutsch.locale 7 Jun 2004 07:14:32 -0000 1.306
+++ b/data/locale/deutsch.locale 8 Jun 2004 23:46:36 -0000
@@ -462,6 +462,14 @@
mp3player.shuffle Shuffle
mp3player.stop Stopp
mp3player.title_artist Titel, Interpret
+mp3player.save_playlist Playlist speichern
+mp3player.playlist_name Dateiname der Playlist
+mp3player.playlist_name_hint1 Geben Sie den Dateinamen der Playlist ein
+mp3player.playlist_name_hint2 Die Erweiterung .m3u wird automatisch angehaengt
+mp3player.playlist_fileerror_title Fehler
+mp3player.playlist_fileerror_msg Datei kann nicht erstellt werden:
+mp3player.playlist_fileoverwrite_title Ueberschreiben?
+mp3player.playlist_fileoverwrite_msg Soll diese Datei ueberschrieben werden:
networkmenu.broadcast Broadcast
networkmenu.dhcp DHCP
networkmenu.gateway Standard Gateway
Index: data/locale/english.locale
===================================================================
RCS file: /cvs/tuxbox/apps/tuxbox/neutrino/data/locale/english.locale,v
retrieving revision 1.241
diff -u -r1.241 english.locale
--- a/data/locale/english.locale 7 Jun 2004 07:14:32 -0000 1.241
+++ b/data/locale/english.locale 8 Jun 2004 23:46:38 -0000
@@ -462,6 +462,14 @@
mp3player.shuffle shuffle
mp3player.stop Stop
mp3player.title_artist Title, Artist
+mp3player.save_playlist save play list
+mp3player.playlist_name filename of the play list
+mp3player.playlist_name_hint1 Please enter the filename of the playlist
+mp3player.playlist_name_hint2 The extension .m3u will be added automatically
+mp3player.playlist_fileerror_title Error
+mp3player.playlist_fileerror_msg File could not be created:
+mp3player.playlist_fileoverwrite_title Overwrite?
+mp3player.playlist_fileoverwrite_msg Do you want to overwrite this file:
networkmenu.broadcast Broadcast
networkmenu.dhcp DHCP
networkmenu.gateway default gateway
Index: src/gui/audioplayer.cpp
===================================================================
RCS file: /cvs/tuxbox/apps/tuxbox/neutrino/src/gui/audioplayer.cpp,v
retrieving revision 1.8
diff -u -r1.8 audioplayer.cpp
--- a/src/gui/audioplayer.cpp 4 Jun 2004 22:51:15 -0000 1.8
+++ b/src/gui/audioplayer.cpp 8 Jun 2004 23:46:44 -0000
@@ -62,6 +62,7 @@
#include <algorithm>
#include <sys/time.h>
#include <fstream>
+#include <iostream>
#if HAVE_DVB_API_VERSION >= 3
#include <linux/dvb/audio.h>
@@ -555,10 +556,14 @@
}
else
{
- if(m_state!=CAudioPlayerGui::STOP)
+ if(m_state!=CAudioPlayerGui::STOP)
{
key_level=1;
paintFoot();
+ } else {
+ if (!playlist.empty()) {
+ savePlaylist();
+ }
}
}
}
@@ -819,6 +824,11 @@
{
frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_OKAY, x + 1* ButtonWidth2 + 25, y+(height-info_height-buttonHeight)-3);
g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(x + 1 * ButtonWidth2 + 53 , y+(height-info_height-buttonHeight)+24 - 4, ButtonWidth2- 28, g_Locale->getText(LOCALE_AUDIOPLAYER_PLAY), COL_INFOBAR, 0, true); // UTF-8
+ if (m_state==CAudioPlayerGui::STOP) {
+ // help will store a playlist file
+ frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_HELP, x+ 0* ButtonWidth + 25, y+(height-info_height-buttonHeight)-3);
+ g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(x+ 0* ButtonWidth +53 , y+(height-info_height-buttonHeight)+24 - 4, ButtonWidth2- 28, g_Locale->getText(LOCALE_AUDIOPLAYER_SAVE_PLAYLIST), COL_INFOBAR, 0, true); // UTF-8
+ }
}
if(m_state!=CAudioPlayerGui::STOP)
{
@@ -1358,3 +1368,150 @@
}
}
+void CAudioPlayerGui::savePlaylist() {
+
+ // .m3u playlist
+ // http://hanna.pyxidis.org/tech/m3u.html
+
+ // let user select target directory
+ CFileBrowser browser;
+ browser.Multi_Select = false;
+ browser.Dir_Mode = true;
+ CFileFilter dirFilter;
+ dirFilter.addFilter("m3u");
+ browser.Filter = &dirFilter;
+ std::string path;
+ if(strlen(g_settings.network_nfs_mp3dir)!=0)
+ path = g_settings.network_nfs_mp3dir;
+ else
+ path = "/";
+
+ if (browser.exec(path)) {
+ // refresh view
+ this->paint();
+ CFile *file = browser.getSelectedFile();
+ std::string playlistDirPath = file->getPath();
+ std::string absPlaylistDir;
+
+ // add a trailing slash if necessary
+ if (playlistDirPath[playlistDirPath.size()-1] == '/') {
+ absPlaylistDir = playlistDirPath + file->getFileName();
+ } else {
+ absPlaylistDir = playlistDirPath + "/" + file->getFileName();
+ }
+
+ const int filenamesize = 30;
+ char filename[filenamesize] = "";
+
+ if (file->getType() == CFile::FILE_PLAYLIST) {
+ // file is playlist so we should ask if we can overwrite it
+ std::string name = file->getPath() + "/" + file->getFileName();
+ bool overwrite = askToOverwriteFile(name);
+ if (!overwrite) {
+ return;
+ }
+ snprintf(filename, name.size(), "%s", name.c_str());
+ } else if (file->getType() == CFile::FILE_DIR) {
+ // query for filename
+ CStringInputSMS filenameInput(LOCALE_AUDIOPLAYER_PLAYLIST_NAME,
+ filename,
+ filenamesize-1,
+ LOCALE_AUDIOPLAYER_PLAYLIST_NAME_HINT1,
+ LOCALE_AUDIOPLAYER_PLAYLIST_NAME_HINT2,
+ "abcdefghijklmnopqrstuvwxyz0123456789-.,:!?/ ");
+ filenameInput.exec(NULL, "");
+ // refresh view
+ this->paint();
+ std::string name = absPlaylistDir + "/" + filename + ".m3u";
+ std::ifstream input(name.c_str());
+
+ // test if file exists and query for overwriting it or not
+ if (input.is_open()) {
+ bool overwrite = askToOverwriteFile(name);
+ if (!overwrite) {
+ return;
+ }
+ }
+ input.close();
+ } else {
+ std::cout << "neither .m3u nor directory selected, abort" << std::endl;
+ return;
+ }
+ std::string absPlaylistFilename = absPlaylistDir;
+ absPlaylistFilename.append("/").append(filename).append(".m3u");
+ std::ofstream playlistFile(absPlaylistFilename.c_str());
+ std::cout << "Audioplayer: writing playlist to " << absPlaylistFilename << std::endl;
+ if (!playlistFile) {
+ const int msgsize = 255;
+ char msg[msgsize] = "";
+ snprintf(msg,
+ msgsize,
+ "%s\n%s",
+ g_Locale->getText(LOCALE_AUDIOPLAYER_PLAYLIST_FILEERROR_MSG),
+ absPlaylistFilename.c_str());
+
+ DisplayErrorMessage(msg);
+ // refresh view
+ this->paint();
+ std::cout << "could not create play list file "
+ << absPlaylistFilename << std::endl;
+ return;
+ }
+ playlistFile << "#EXTM3U" << std::endl;
+
+ CPlayList::const_iterator it;
+ for (it = playlist.begin();it!=playlist.end();it++) {
+ playlistFile << "#EXTINF:" << it->Duration << ","
+ << it->Artist << " - " << it->Title << std::endl;
+ playlistFile << absPath2Rel(absPlaylistDir, it->Filename) << std::endl;
+ }
+ playlistFile.close();
+ }
+ this->paint();
+}
+
+bool CAudioPlayerGui::askToOverwriteFile(const std::string& filename) {
+
+ char msg[filename.length()+127];
+ snprintf(msg,
+ filename.length()+126,
+ "%s\n%s",
+ g_Locale->getText(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_MSG),
+ filename.c_str());
+ bool res = (ShowMsgUTF(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_TITLE,
+ msg,CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo)
+ == CMessageBox::mbrYes);
+ this->paint();
+ return res;
+}
+
+std::string CAudioPlayerGui::absPath2Rel(const std::string& fromDir,
+ const std::string& absFilename) {
+ std::string res = "";
+
+ int length = fromDir.size() > absFilename.size() ? fromDir.length() : absFilename.length();
+ int lastSlash = 0;
+ // find common prefix for both paths
+ for (int i=0;i<length;i++) {
+ if (fromDir[i] == absFilename[i]) {
+ if (fromDir[i] == '/') {
+ lastSlash = i;
+ }
+ } else {
+ break;
+ }
+ }
+ // cut common prefix
+ std::string relFilepath = absFilename.substr(lastSlash+1,absFilename.length()-lastSlash+1);
+ std::string relFromDir = fromDir.substr(lastSlash,fromDir.length()-lastSlash);
+
+ // go up as many directories as neccessary
+ for (unsigned int i=0;i<relFromDir.size();i++) {
+ if (relFromDir[i] == '/') {
+ res = res + "../";
+ }
+ }
+ res = res + relFilepath;
+ return res;
+}
+
Index: src/gui/audioplayer.h
===================================================================
RCS file: /cvs/tuxbox/apps/tuxbox/neutrino/src/gui/audioplayer.h,v
retrieving revision 1.1
diff -u -r1.1 audioplayer.h
--- a/src/gui/audioplayer.h 30 May 2004 16:47:36 -0000 1.1
+++ b/src/gui/audioplayer.h 8 Jun 2004 23:46:44 -0000
@@ -140,6 +140,31 @@
void updateTimes(const bool force = false);
void showMetaData();
void screensaver(bool on);
+ void savePlaylist();
+
+ /**
+ * Converts an absolute filename to a relative one
+ * as seen from a file in fromDir.
+ * Example:
+ * absFilename: /mnt/audio/A/abc.mp3
+ * fromDir: /mnt/audio/B
+ * => ../A/abc.mp3 will be returned
+ * @param fromDir the directory from where we want to
+ * access the file
+ * @param absFilename the file we want to access in a
+ * relative way from fromDir (given as an absolute path)
+ * @return the location of absFilename as seen from fromDir
+ * (relative path)
+ */
+ std::string absPath2Rel(const std::string& fromDir,
+ const std::string& absFilename);
+
+ /**
+ * Asks the user if the file filename should be overwritten or not
+ * @param filename the name of the file
+ * @return true if file should be overwritten, false otherwise
+ */
+ bool CAudioPlayerGui::askToOverwriteFile(const std::string& filename);
public:
CAudioPlayerGui();
Index: src/system/locals.h
===================================================================
RCS file: /cvs/tuxbox/apps/tuxbox/neutrino/src/system/locals.h,v
retrieving revision 1.3
diff -u -r1.3 locals.h
--- a/src/system/locals.h 7 Jun 2004 07:14:33 -0000 1.3
+++ b/src/system/locals.h 8 Jun 2004 23:46:46 -0000
@@ -489,6 +489,14 @@
LOCALE_AUDIOPLAYER_SHUFFLE ,
LOCALE_AUDIOPLAYER_STOP ,
LOCALE_AUDIOPLAYER_TITLE_ARTIST ,
+ LOCALE_AUDIOPLAYER_SAVE_PLAYLIST ,
+ LOCALE_AUDIOPLAYER_PLAYLIST_NAME ,
+ LOCALE_AUDIOPLAYER_PLAYLIST_NAME_HINT1 ,
+ LOCALE_AUDIOPLAYER_PLAYLIST_NAME_HINT2 ,
+ LOCALE_AUDIOPLAYER_PLAYLIST_FILEERROR_TITLE ,
+ LOCALE_AUDIOPLAYER_PLAYLIST_FILEERROR_MSG ,
+ LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_TITLE ,
+ LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_MSG ,
LOCALE_NETWORKMENU_BROADCAST ,
LOCALE_NETWORKMENU_DHCP ,
LOCALE_NETWORKMENU_GATEWAY ,
Index: src/system/locals_intern.h
===================================================================
RCS file: /cvs/tuxbox/apps/tuxbox/neutrino/src/system/locals_intern.h,v
retrieving revision 1.4
diff -u -r1.4 locals_intern.h
--- a/src/system/locals_intern.h 7 Jun 2004 07:14:33 -0000 1.4
+++ b/src/system/locals_intern.h 8 Jun 2004 23:46:47 -0000
@@ -489,6 +489,14 @@
"mp3player.shuffle",
"mp3player.stop",
"mp3player.title_artist",
+ "mp3player.save_playlist",
+ "mp3player.playlist_name",
+ "mp3player.playlist_name_hint1",
+ "mp3player.playlist_name_hint2",
+ "mp3player.playlist_fileerror_title",
+ "mp3player.playlist_fileerror_msg",
+ "mp3player.playlist_fileoverwrite_title",
+ "mp3player.playlist_fileoverwrite_msg",
"networkmenu.broadcast",
"networkmenu.dhcp",
"networkmenu.gateway",