remove local playlist save functionality
This commit is contained in:
parent
e622037e01
commit
35088170b2
2 changed files with 0 additions and 54 deletions
|
|
@ -1,8 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
|
||||||
|
|
||||||
public interface M3UConstants {
|
|
||||||
String EXTENSION = "m3u";
|
|
||||||
String HEADER = "#EXTM3U";
|
|
||||||
String ENTRY = "#EXTINF:";
|
|
||||||
String DURATION_SEPARATOR = ",";
|
|
||||||
}
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
package com.kabouzeid.gramophone.helper;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.loader.PlaylistSongLoader;
|
|
||||||
import com.kabouzeid.gramophone.model.Playlist;
|
|
||||||
import com.kabouzeid.gramophone.model.Song;
|
|
||||||
import com.kabouzeid.gramophone.model.playlist.AbsSmartPlaylist;
|
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class M3UWriter implements M3UConstants {
|
|
||||||
|
|
||||||
public static File write(Context context, File dir, Playlist playlist) throws IOException {
|
|
||||||
if (!dir.exists()) //noinspection ResultOfMethodCallIgnored
|
|
||||||
dir.mkdirs();
|
|
||||||
File file = new File(dir, playlist.name.concat("." + EXTENSION));
|
|
||||||
|
|
||||||
List<? extends Song> songs;
|
|
||||||
if (playlist instanceof AbsSmartPlaylist) {
|
|
||||||
songs = ((AbsSmartPlaylist) playlist).getSongs(context);
|
|
||||||
} else {
|
|
||||||
songs = PlaylistSongLoader.getPlaylistSongList(context, playlist.id.hashCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (songs.size() > 0) {
|
|
||||||
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
|
|
||||||
|
|
||||||
bw.write(HEADER);
|
|
||||||
for (Song song : songs) {
|
|
||||||
bw.newLine();
|
|
||||||
bw.write(ENTRY + song.duration + DURATION_SEPARATOR + song.artistName + " - " + song.title);
|
|
||||||
bw.newLine();
|
|
||||||
bw.write(song.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
bw.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue