diff options
author | owner <owner@DeeDee-Laptop> | 2012-11-23 09:44:13 -0800 |
---|---|---|
committer | owner <owner@DeeDee-Laptop> | 2012-11-23 09:44:13 -0800 |
commit | cabad9f498dd39e86869a39df95ca24552cefb1b (patch) | |
tree | ce6786a5d56802818f46b42ccb4cbfec1c9b3c5d /subsonic-android | |
parent | 385b399420ee3321bf7624a76276229efc986688 (diff) | |
download | dsub-cabad9f498dd39e86869a39df95ca24552cefb1b.tar.gz dsub-cabad9f498dd39e86869a39df95ca24552cefb1b.tar.bz2 dsub-cabad9f498dd39e86869a39df95ca24552cefb1b.zip |
Added videos to offline mode
Diffstat (limited to 'subsonic-android')
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java | 11 | ||||
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java | 18 |
2 files changed, 21 insertions, 8 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java index 13d8d34a..135a1e12 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -86,7 +86,7 @@ public class OfflineMusicService extends RESTMusicService { Set<String> names = new HashSet<String>(); - for (File file : FileUtil.listMusicFiles(dir)) { + for (File file : FileUtil.listMediaFiles(dir)) { String name = getName(file); if (name != null & !names.contains(name)) { names.add(name); @@ -129,6 +129,9 @@ public class OfflineMusicService extends RESTMusicService { if (albumArt.exists()) { entry.setCoverArt(albumArt.getPath()); } + if(FileUtil.isVideoFile(file)) { + entry.setVideo(true); + } return entry; } @@ -174,7 +177,7 @@ public class OfflineMusicService extends RESTMusicService { } private void recursiveAlbumSearch(String artistName, File file, SearchCritera criteria, Context context, List<MusicDirectory.Entry> albums, List<MusicDirectory.Entry> songs) { - for(File albumFile : FileUtil.listMusicFiles(file)) { + for(File albumFile : FileUtil.listMediaFiles(file)) { if(albumFile.isDirectory()) { String albumName = getName(albumFile); if(matchCriteria(criteria, albumName)) { @@ -183,7 +186,7 @@ public class OfflineMusicService extends RESTMusicService { albums.add(album); } - for(File songFile : FileUtil.listMusicFiles(albumFile)) { + for(File songFile : FileUtil.listMediaFiles(albumFile)) { String songName = getName(songFile); if(songFile.isDirectory()) { recursiveAlbumSearch(artistName, songFile, criteria, context, albums, songs); @@ -376,7 +379,7 @@ public class OfflineMusicService extends RESTMusicService { } private void listFilesRecursively(File parent, List<File> children) { - for (File file : FileUtil.listMusicFiles(parent)) { + for (File file : FileUtil.listMediaFiles(parent)) { if (file.isFile()) { children.add(file); } else { diff --git a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java index da7c8fdc..890420fc 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java @@ -46,6 +46,7 @@ public class FileUtil { private static final String[] FILE_SYSTEM_UNSAFE = {"/", "\\", "..", ":", "\"", "?", "*", "<", ">", "|"}; private static final String[] FILE_SYSTEM_UNSAFE_DIR = {"\\", "..", ":", "\"", "?", "*", "<", ">", "|"}; private static final List<String> MUSIC_FILE_EXTENSIONS = Arrays.asList("mp3", "ogg", "aac", "flac", "m4a", "wav", "wma"); + private static final List<String> VIDEO_FILE_EXTENSIONS = Arrays.asList("flv", "mp4", "m4v", "wmv", "avi", "mov", "mpg", "mkv"); private static final List<String> PLAYLIST_FILE_EXTENSIONS = Arrays.asList("m3u"); private static final File DEFAULT_MUSIC_DIR = createDirectory("music"); @@ -237,23 +238,32 @@ public class FileUtil { return new TreeSet<File>(Arrays.asList(files)); } - public static SortedSet<File> listMusicFiles(File dir) { + public static SortedSet<File> listMediaFiles(File dir) { SortedSet<File> files = listFiles(dir); Iterator<File> iterator = files.iterator(); while (iterator.hasNext()) { File file = iterator.next(); - if (!file.isDirectory() && !isMusicFile(file)) { + if (!file.isDirectory() && !isMediaFile(file)) { iterator.remove(); } } return files; } - private static boolean isMusicFile(File file) { + private static boolean isMediaFile(File file) { String extension = getExtension(file.getName()); - return MUSIC_FILE_EXTENSIONS.contains(extension); + return MUSIC_FILE_EXTENSIONS.contains(extension) || VIDEO_FILE_EXTENSIONS.contains(extension); } + public static boolean isMusicFile(File file) { + String extension = getExtension(file.getName()); + return MUSIC_FILE_EXTENSIONS.contains(extension); + } + public static boolean isVideoFile(File file) { + String extension = getExtension(file.getName()); + return VIDEO_FILE_EXTENSIONS.contains(extension); + } + public static boolean isPlaylistFile(File file) { String extension = getExtension(file.getName()); return PLAYLIST_FILE_EXTENSIONS.contains(extension); |