From b32004b4a4e8c1bbca0c55dfe1d95d6ac5b91ac0 Mon Sep 17 00:00:00 2001 From: owner Date: Wed, 21 Nov 2012 20:39:48 -0800 Subject: Fix artists not refreshing properly when prompted --- .../src/github/daneren2005/dsub/service/RESTMusicService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java index 60cffc7b..56e199df 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -214,7 +214,7 @@ public class RESTMusicService implements MusicService { return cachedIndexes; } - long lastModified = cachedIndexes == null ? 0L : cachedIndexes.getLastModified(); + long lastModified = (cachedIndexes == null || refresh) ? 0L : cachedIndexes.getLastModified(); List parameterNames = new ArrayList(); List parameterValues = new ArrayList(); -- cgit v1.2.3 From 20a9b339b9231fca62bef2d1f0b37ce588b8918c Mon Sep 17 00:00:00 2001 From: owner Date: Wed, 21 Nov 2012 20:50:05 -0800 Subject: Increase playlist cache timeout --- .../src/github/daneren2005/dsub/service/CachedMusicService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java index 798cf8e6..d5b4bc9d 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -53,7 +53,7 @@ public class CachedMusicService implements MusicService { private final LRUCache> cachedMusicDirectories; private final TimeLimitedCache cachedLicenseValid = new TimeLimitedCache(120, TimeUnit.SECONDS); private final TimeLimitedCache cachedIndexes = new TimeLimitedCache(60 * 60, TimeUnit.SECONDS); - private final TimeLimitedCache> cachedPlaylists = new TimeLimitedCache>(60, TimeUnit.SECONDS); + private final TimeLimitedCache> cachedPlaylists = new TimeLimitedCache>(3600, TimeUnit.SECONDS); private final TimeLimitedCache> cachedMusicFolders = new TimeLimitedCache>(10 * 3600, TimeUnit.SECONDS); private String restUrl; -- cgit v1.2.3 From 2a4a56f035a57fa6a2a38718a1ca5023f361b0b9 Mon Sep 17 00:00:00 2001 From: owner Date: Wed, 21 Nov 2012 22:03:22 -0800 Subject: Fixed null (...) for all videos --- .../src/github/daneren2005/dsub/view/SongView.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/view/SongView.java b/subsonic-android/src/github/daneren2005/dsub/view/SongView.java index f1701822..98ceebba 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/SongView.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/SongView.java @@ -78,9 +78,13 @@ public class SongView extends UpdateView implements Checkable { fileFormat = song.getSuffix(); } - artist.append(song.getArtist()).append(" (") - .append(String.format(getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat)) - .append(")"); + if(!song.isVideo()) { + artist.append(song.getArtist()).append(" (") + .append(String.format(getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat)) + .append(")"); + } else { + artist.append(String.format(getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat)); + } titleTextView.setText(song.getTitle()); artistTextView.setText(artist); -- cgit v1.2.3 From d638f35850ab86304d39373121f4d512abbbcfdc Mon Sep 17 00:00:00 2001 From: owner Date: Wed, 21 Nov 2012 22:04:26 -0800 Subject: Duration string now shows hours instead of > 100 minutes --- subsonic-android/src/github/daneren2005/dsub/util/Util.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Util.java b/subsonic-android/src/github/daneren2005/dsub/util/Util.java index 7616964b..497df90c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Util.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Util.java @@ -462,10 +462,17 @@ public final class Util { return null; } - int minutes = seconds / 60; + int hours = seconds / 3600; + int minutes = (seconds / 60) % 60; int secs = seconds % 60; - StringBuilder builder = new StringBuilder(6); + StringBuilder builder = new StringBuilder(7); + if(hours > 0) { + builder.append(hours).append(":"); + if(minutes < 10) { + builder.append("0"); + } + } builder.append(minutes).append(":"); if (secs < 10) { builder.append("0"); -- cgit v1.2.3 From df87756cd3330be032671ff8cb694395cebe1457 Mon Sep 17 00:00:00 2001 From: owner Date: Wed, 21 Nov 2012 23:13:43 -0800 Subject: Added special context menu for videos --- subsonic-android/res/menu/select_video_context.xml | 25 ++++++++++++++++++++++ .../res/menu/select_video_context_offline.xml | 25 ++++++++++++++++++++++ subsonic-android/res/values/strings.xml | 1 + .../dsub/activity/SelectAlbumActivity.java | 15 ++++++++++--- 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 subsonic-android/res/menu/select_video_context.xml create mode 100644 subsonic-android/res/menu/select_video_context_offline.xml (limited to 'subsonic-android/src') diff --git a/subsonic-android/res/menu/select_video_context.xml b/subsonic-android/res/menu/select_video_context.xml new file mode 100644 index 00000000..2edcb10a --- /dev/null +++ b/subsonic-android/res/menu/select_video_context.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + diff --git a/subsonic-android/res/menu/select_video_context_offline.xml b/subsonic-android/res/menu/select_video_context_offline.xml new file mode 100644 index 00000000..2edcb10a --- /dev/null +++ b/subsonic-android/res/menu/select_video_context_offline.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index feb1bf9e..8a21950e 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -17,6 +17,7 @@ Details Name Comment + Play Web View Home Library diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java index ccd5d5af..2d87c263 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java @@ -222,13 +222,19 @@ public class SelectAlbumActivity extends SubsonicTabActivity { inflater.inflate(R.menu.select_album_context_offline, menu); else inflater.inflate(R.menu.select_album_context, menu); - } else { + } else if(!entry.isVideo()) { MenuInflater inflater = getMenuInflater(); if(Util.isOffline(this)) inflater.inflate(R.menu.select_song_context_offline, menu); else inflater.inflate(R.menu.select_song_context, menu); - } + } else { + MenuInflater inflater = getMenuInflater(); + if(Util.isOffline(this)) + inflater.inflate(R.menu.select_video_context_offline, menu); + else + inflater.inflate(R.menu.select_video_context, menu); + } if (!Util.isOffline(this)) { menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star).setTitle(entry.isStarred() ? R.string.common_unstar : R.string.common_star); @@ -284,6 +290,9 @@ public class SelectAlbumActivity extends SubsonicTabActivity { case R.id.song_menu_star: toggleStarred(entry); break; + case R.id.song_menu_webview: + playVideo(entry); + break; default: return super.onContextItemSelected(menuItem); } @@ -486,7 +495,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { private void playVideo(MusicDirectory.Entry entry) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(MusicServiceFactory.getMusicService(this).getVideoUrl(this, entry.getId()))); - + startActivity(intent); } -- cgit v1.2.3 From 4b2d6294476ca3cddee884733304acfd1f69bb7a Mon Sep 17 00:00:00 2001 From: owner Date: Wed, 21 Nov 2012 23:14:13 -0800 Subject: Added getVideoStreamUrl to service --- .../github/daneren2005/dsub/service/CachedMusicService.java | 5 +++++ .../src/github/daneren2005/dsub/service/MusicService.java | 2 ++ .../github/daneren2005/dsub/service/OfflineMusicService.java | 5 +++++ .../src/github/daneren2005/dsub/service/RESTMusicService.java | 11 +++++++++++ 4 files changed, 23 insertions(+) (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java index d5b4bc9d..4cd878b5 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -213,6 +213,11 @@ public class CachedMusicService implements MusicService { public String getVideoUrl(Context context, String id) { return musicService.getVideoUrl(context, id); } + + @Override + public String getVideoStreamUrl(Context context, String id) { + return musicService.getVideoStreamUrl(context, id); + } @Override public JukeboxStatus updateJukeboxPlaylist(List ids, Context context, ProgressListener progressListener) throws Exception { diff --git a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java index 1dc247f1..ebcfe9aa 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java @@ -84,6 +84,8 @@ public interface MusicService { Version getLatestVersion(Context context, ProgressListener progressListener) throws Exception; String getVideoUrl(Context context, String id); + + String getVideoStreamUrl(Context context, String id); JukeboxStatus updateJukeboxPlaylist(List ids, Context context, ProgressListener progressListener) throws Exception; diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java index 29249268..13d8d34a 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -315,6 +315,11 @@ public class OfflineMusicService extends RESTMusicService { public String getVideoUrl(Context context, String id) { return null; } + + @Override + public String getVideoStreamUrl(Context context, String id) { + return null; + } @Override public JukeboxStatus updateJukeboxPlaylist(List ids, Context context, ProgressListener progressListener) throws Exception { diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java index 56e199df..25bacb61 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -619,6 +619,17 @@ public class RESTMusicService implements MusicService { Log.i(TAG, "Using video URL: " + url); return url; } + + @Override + public String getVideoStreamUrl(Context context, String id) { + StringBuilder builder = new StringBuilder(Util.getRestUrl(context, "stream")); + builder.append("&id=").append(id); + builder.append("&maxBitRate=500"); + + String url = rewriteUrlWithRedirect(context, builder.toString()); + Log.i(TAG, "Using video URL: " + url); + return url; + } @Override public JukeboxStatus updateJukeboxPlaylist(List ids, Context context, ProgressListener progressListener) throws Exception { -- cgit v1.2.3 From 385b399420ee3321bf7624a76276229efc986688 Mon Sep 17 00:00:00 2001 From: owner Date: Fri, 23 Nov 2012 09:18:39 -0800 Subject: Added option to play videos with external player --- subsonic-android/res/menu/select_video_context.xml | 4 ++++ .../res/menu/select_video_context_offline.xml | 23 ++-------------------- subsonic-android/res/values/strings.xml | 1 + .../dsub/activity/SelectAlbumActivity.java | 14 ++++++++++--- 4 files changed, 18 insertions(+), 24 deletions(-) (limited to 'subsonic-android/src') diff --git a/subsonic-android/res/menu/select_video_context.xml b/subsonic-android/res/menu/select_video_context.xml index 2edcb10a..ed04b6ff 100644 --- a/subsonic-android/res/menu/select_video_context.xml +++ b/subsonic-android/res/menu/select_video_context.xml @@ -1,5 +1,9 @@ + + - - - - - - - - + android:id="@+id/song_menu_play_external" + android:title="@string/common.play_external"/> diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index 26301b17..531c84eb 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -18,6 +18,7 @@ Name Comment Play Web View (Flash) + Play External Player Home Library diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java index 2d87c263..cd71db36 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java @@ -78,7 +78,7 @@ public class SelectAlbumActivity extends SubsonicTabActivity { intent.putExtra(Constants.INTENT_EXTRA_NAME_NAME, entry.getTitle()); Util.startActivityWithoutTransition(SelectAlbumActivity.this, intent); } else if (entry.isVideo()) { - playVideo(entry); + playExternalPlayer(entry); } } } @@ -291,7 +291,10 @@ public class SelectAlbumActivity extends SubsonicTabActivity { toggleStarred(entry); break; case R.id.song_menu_webview: - playVideo(entry); + playWebView(entry); + break; + case R.id.song_menu_play_external: + playExternalPlayer(entry); break; default: return super.onContextItemSelected(menuItem); @@ -492,12 +495,17 @@ public class SelectAlbumActivity extends SubsonicTabActivity { } } - private void playVideo(MusicDirectory.Entry entry) { + private void playWebView(MusicDirectory.Entry entry) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(MusicServiceFactory.getMusicService(this).getVideoUrl(this, entry.getId()))); startActivity(intent); } + private void playExternalPlayer(MusicDirectory.Entry entry) { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType(Uri.parse(entry.getPath()), "video/*"); + startActivity(intent); + } private void checkLicenseAndTrialPeriod(Runnable onValid) { if (licenseValid) { -- cgit v1.2.3 From cabad9f498dd39e86869a39df95ca24552cefb1b Mon Sep 17 00:00:00 2001 From: owner Date: Fri, 23 Nov 2012 09:44:13 -0800 Subject: Added videos to offline mode --- .../daneren2005/dsub/service/OfflineMusicService.java | 11 +++++++---- .../src/github/daneren2005/dsub/util/FileUtil.java | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'subsonic-android/src') 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 names = new HashSet(); - 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 albums, List 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 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 MUSIC_FILE_EXTENSIONS = Arrays.asList("mp3", "ogg", "aac", "flac", "m4a", "wav", "wma"); + private static final List VIDEO_FILE_EXTENSIONS = Arrays.asList("flv", "mp4", "m4v", "wmv", "avi", "mov", "mpg", "mkv"); private static final List 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(Arrays.asList(files)); } - public static SortedSet listMusicFiles(File dir) { + public static SortedSet listMediaFiles(File dir) { SortedSet files = listFiles(dir); Iterator 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); -- cgit v1.2.3 From 428f305bd8e9e1b370b13c5ec65ffefe3090e5d9 Mon Sep 17 00:00:00 2001 From: owner Date: Fri, 23 Nov 2012 10:23:34 -0800 Subject: Added error message if trying to play videos which haven't been downloaded yet --- subsonic-android/res/values/strings.xml | 1 + .../daneren2005/dsub/activity/SelectAlbumActivity.java | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'subsonic-android/src') diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index 531c84eb..12e93949 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -136,6 +136,7 @@ Show Now Playing Start Timer Stop Timer + Video needs to be downloaded first Starred \"%s\" Unstarred \"%s\" diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java index cd71db36..fea1cfd0 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java @@ -34,9 +34,11 @@ import android.widget.*; import com.actionbarsherlock.view.Menu; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.MusicDirectory; +import github.daneren2005.dsub.service.DownloadFile; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; import github.daneren2005.dsub.util.*; +import java.io.File; import java.util.ArrayList; import java.util.HashSet; @@ -502,9 +504,14 @@ public class SelectAlbumActivity extends SubsonicTabActivity { startActivity(intent); } private void playExternalPlayer(MusicDirectory.Entry entry) { - Intent intent = new Intent(Intent.ACTION_VIEW); - intent.setDataAndType(Uri.parse(entry.getPath()), "video/*"); - startActivity(intent); + DownloadFile check = new DownloadFile(this, entry, false); + if(!check.isCompleteFileAvailable()) { + Util.toast(this, R.string.download_need_download); + } else { + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType(Uri.parse(entry.getPath()), "video/*"); + startActivity(intent); + } } private void checkLicenseAndTrialPeriod(Runnable onValid) { -- cgit v1.2.3 From ffeb88092eb1be96d9bbb843bfe7d855b8abab67 Mon Sep 17 00:00:00 2001 From: owner Date: Fri, 23 Nov 2012 12:17:28 -0800 Subject: Removed unused activity --- .../dsub/activity/PlayVideoActivity.java | 147 --------------------- 1 file changed, 147 deletions(-) delete mode 100644 subsonic-android/src/github/daneren2005/dsub/activity/PlayVideoActivity.java (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/PlayVideoActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/PlayVideoActivity.java deleted file mode 100644 index 7a77736e..00000000 --- a/subsonic-android/src/github/daneren2005/dsub/activity/PlayVideoActivity.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - This file is part of Subsonic. - - Subsonic is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Subsonic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Subsonic. If not, see . - - Copyright 2009 (C) Sindre Mehus - */ - -package github.daneren2005.dsub.activity; - -import java.lang.reflect.Method; - -import android.app.Activity; -import android.graphics.Bitmap; -import android.media.AudioManager; -import android.os.Bundle; -import android.util.Log; -import android.view.Window; -import android.webkit.WebView; -import android.webkit.WebViewClient; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import github.daneren2005.dsub.R; -import github.daneren2005.dsub.service.MusicServiceFactory; -import github.daneren2005.dsub.util.Constants; -import github.daneren2005.dsub.util.Util; - -/** - * Plays videos in a web page. - * - * @author Sindre Mehus - */ -public final class PlayVideoActivity extends Activity { - - private static final String TAG = PlayVideoActivity.class.getSimpleName(); - private WebView webView; - - @Override - protected void onCreate(Bundle bundle) { - super.onCreate(bundle); - getWindow().requestFeature(Window.FEATURE_NO_TITLE); - setVolumeControlStream(AudioManager.STREAM_MUSIC); - - setContentView(R.layout.play_video); - - webView = (WebView) findViewById(R.id.play_video_contents); - webView.getSettings().setJavaScriptEnabled(true); - webView.getSettings().setPluginsEnabled(true); - webView.getSettings().setAllowFileAccess(true); - webView.getSettings().setSupportZoom(true); - webView.getSettings().setBuiltInZoomControls(true); - - webView.setWebViewClient(new Client()); - if (bundle != null) { - webView.restoreState(bundle); - } else { - webView.loadUrl(getVideoUrl()); - } - - // Show warning if Flash plugin is not installed. - if (isFlashPluginInstalled()) { - Util.toast(this, R.string.play_video_loading, false); - } else { - Util.toast(this, R.string.play_video_noplugin, false); - } - } - - @Override - protected void onPause() { - super.onPause(); - callHiddenWebViewMethod("onPause"); - } - - @Override - protected void onResume() { - super.onResume(); - callHiddenWebViewMethod("onResume"); - } - - private String getVideoUrl() { - String id = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_ID); - return MusicServiceFactory.getMusicService(this).getVideoUrl(this, id); - } - - @Override - protected void onSaveInstanceState(Bundle state) { - webView.saveState(state); - } - - private void callHiddenWebViewMethod(String name){ - if( webView != null ){ - try { - Method method = WebView.class.getMethod(name); - method.invoke(webView); - } catch (Throwable x) { - Log.e(TAG, "Failed to invoke " + name, x); - } - } - } - - private boolean isFlashPluginInstalled() { - try { - PackageInfo packageInfo = getPackageManager().getPackageInfo("com.adobe.flashplayer", 0); - return packageInfo != null; - } catch (PackageManager.NameNotFoundException x) { - return false; - } - } - - private final class Client extends WebViewClient { - - @Override - public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { - Util.toast(PlayVideoActivity.this, description); - Log.e(TAG, "Error: " + description); - } - - @Override - public void onLoadResource(WebView view, String url) { - super.onLoadResource(view, url); - Log.d(TAG, "onLoadResource: " + url); - } - - @Override - public void onPageStarted(WebView view, String url, Bitmap favicon) { - super.onPageStarted(view, url, favicon); - Log.d(TAG, "onPageStarted: " + url); - } - - @Override - public void onPageFinished(WebView view, String url) { - super.onPageFinished(view, url); - Log.d(TAG, "onPageFinished: " + url); - } - } -} -- cgit v1.2.3 From 64a92b7d8243ac376385c8ed0ba65f84179e4e5e Mon Sep 17 00:00:00 2001 From: owner Date: Fri, 23 Nov 2012 12:38:45 -0800 Subject: Remove cached playlists when adding new playlist --- .../src/github/daneren2005/dsub/service/CachedMusicService.java | 1 + 1 file changed, 1 insertion(+) (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java index 4cd878b5..42fd8e57 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -146,6 +146,7 @@ public class CachedMusicService implements MusicService { @Override public void createPlaylist(String id, String name, List entries, Context context, ProgressListener progressListener) throws Exception { + cachedPlaylists.clear(); musicService.createPlaylist(id, name, entries, context, progressListener); } -- cgit v1.2.3 From 2e3820f52ddf5720053db60b2d9fa251e0089149 Mon Sep 17 00:00:00 2001 From: owner Date: Fri, 23 Nov 2012 13:24:37 -0800 Subject: Added options to remove songs from playlists --- subsonic-android/res/menu/select_song.xml | 4 ++ subsonic-android/res/menu/select_song_context.xml | 4 ++ subsonic-android/res/values/strings.xml | 2 + .../dsub/activity/SelectAlbumActivity.java | 82 +++++++++++++++++++--- .../dsub/service/CachedMusicService.java | 5 ++ .../daneren2005/dsub/service/MusicService.java | 2 + .../dsub/service/OfflineMusicService.java | 5 ++ .../daneren2005/dsub/service/RESTMusicService.java | 19 +++++ 8 files changed, 112 insertions(+), 11 deletions(-) (limited to 'subsonic-android/src') diff --git a/subsonic-android/res/menu/select_song.xml b/subsonic-android/res/menu/select_song.xml index cd49e44f..3a55fee0 100644 --- a/subsonic-android/res/menu/select_song.xml +++ b/subsonic-android/res/menu/select_song.xml @@ -46,6 +46,10 @@ android:id="@+id/menu_add_playlist" android:title="@string/menu.add_playlist"/> + + + + diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index 12e93949..dc02569a 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -52,6 +52,7 @@ Settings Help Add To Playlist + Remove From Playlist Deleted playlist %s Failed to delete playlist %s @@ -145,6 +146,7 @@ Failed to grab list of playlists Added %1$s songs to \"%2$s\" Failed to update \"%s\", please try later. + Removed %1$s songs from \"%2$s\" %1$s %2$s %d kbps diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java index fea1cfd0..891c2edd 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java @@ -34,16 +34,11 @@ import android.widget.*; import com.actionbarsherlock.view.Menu; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.MusicDirectory; -import github.daneren2005.dsub.service.DownloadFile; -import github.daneren2005.dsub.service.MusicService; -import github.daneren2005.dsub.service.MusicServiceFactory; +import github.daneren2005.dsub.service.*; import github.daneren2005.dsub.util.*; import java.io.File; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; public class SelectAlbumActivity extends SubsonicTabActivity { @@ -115,10 +110,17 @@ public class SelectAlbumActivity extends SubsonicTabActivity { inflater.inflate(R.menu.select_album, menu); hideButtons = false; } else { - if(Util.isOffline(this)) + if(Util.isOffline(this)) { inflater.inflate(R.menu.select_song_offline, menu); - else + } + else { inflater.inflate(R.menu.select_song, menu); + + String playlistId = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID); + if(playlistId == null) { + menu.removeItem(R.id.menu_remove_playlist); + } + } } return true; } @@ -157,6 +159,11 @@ public class SelectAlbumActivity extends SubsonicTabActivity { case R.id.menu_add_playlist: addToPlaylist(getSelectedSongs()); return true; + case R.id.menu_remove_playlist: + String playlistId = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID); + String playlistName = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME); + removeFromPlaylist(playlistId, playlistName, getSelectedIndexes()); + return true; case R.id.menu_exit: intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); @@ -226,10 +233,16 @@ public class SelectAlbumActivity extends SubsonicTabActivity { inflater.inflate(R.menu.select_album_context, menu); } else if(!entry.isVideo()) { MenuInflater inflater = getMenuInflater(); - if(Util.isOffline(this)) + if(Util.isOffline(this)) { inflater.inflate(R.menu.select_song_context_offline, menu); - else + } + else { inflater.inflate(R.menu.select_song_context, menu); + String playlistId = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID); + if(playlistId == null) { + menu.removeItem(R.id.song_menu_remove_playlist); + } + } } else { MenuInflater inflater = getMenuInflater(); if(Util.isOffline(this)) @@ -298,6 +311,11 @@ public class SelectAlbumActivity extends SubsonicTabActivity { case R.id.song_menu_play_external: playExternalPlayer(entry); break; + case R.id.song_menu_remove_playlist: + String playlistId = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID); + String playlistName = getIntent().getStringExtra(Constants.INTENT_EXTRA_NAME_PLAYLIST_NAME); + removeFromPlaylist(playlistId, playlistName, Arrays.asList(info.position - 1)); + break; default: return super.onContextItemSelected(menuItem); } @@ -425,6 +443,19 @@ public class SelectAlbumActivity extends SubsonicTabActivity { } return songs; } + + private List getSelectedIndexes() { + List indexes = new ArrayList(); + + int count = entryList.getCount(); + for (int i = 0; i < count; i++) { + if (entryList.isItemChecked(i)) { + indexes.add(i - 1); + } + } + + return indexes; + } private void download(final boolean append, final boolean save, final boolean autoplay, final boolean playNext, final boolean shuffle) { if (getDownloadService() == null) { @@ -651,4 +682,33 @@ public class SelectAlbumActivity extends SubsonicTabActivity { return header; } + + public void removeFromPlaylist(final String id, final String name, final List indexes) { + new LoadingTask(this, true) { + @Override + protected Void doInBackground() throws Throwable { + MusicService musicService = MusicServiceFactory.getMusicService(SelectAlbumActivity.this); + musicService.removeFromPlaylist(id, indexes, SelectAlbumActivity.this, null); + return null; + } + + @Override + protected void done(Void result) { + refresh(); + Util.toast(SelectAlbumActivity.this, getResources().getString(R.string.removed_playlist, indexes.size(), name)); + } + + @Override + protected void error(Throwable error) { + String msg; + if (error instanceof OfflineException || error instanceof ServerTooOldException) { + msg = getErrorMessage(error); + } else { + msg = getResources().getString(R.string.updated_playlist_error, name) + " " + getErrorMessage(error); + } + + Util.toast(SelectAlbumActivity.this, msg, false); + } + }.execute(); + } } diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java index 42fd8e57..c9233d01 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -160,6 +160,11 @@ public class CachedMusicService implements MusicService { musicService.addToPlaylist(id, toAdd, context, progressListener); } + @Override + public void removeFromPlaylist(String id, List toRemove, Context context, ProgressListener progressListener) throws Exception { + musicService.removeFromPlaylist(id, toRemove, context, progressListener); + } + @Override public void updatePlaylist(String id, String name, String comment, Context context, ProgressListener progressListener) throws Exception { musicService.updatePlaylist(id, name, comment, context, progressListener); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java index ebcfe9aa..67e4bed5 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java @@ -65,6 +65,8 @@ public interface MusicService { void addToPlaylist(String id, List toAdd, Context context, ProgressListener progressListener) throws Exception; + void removeFromPlaylist(String id, List toRemove, Context context, ProgressListener progressListener) throws Exception; + void updatePlaylist(String id, String name, String comment, Context context, ProgressListener progressListener) throws Exception; Lyrics getLyrics(String artist, String title, Context context, ProgressListener progressListener) throws Exception; diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java index 135a1e12..ce353740 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -294,6 +294,11 @@ public class OfflineMusicService extends RESTMusicService { throw new OfflineException("Updating playlist not available in offline mode"); } + @Override + public void removeFromPlaylist(String id, List toRemove, Context context, ProgressListener progressListener) throws Exception { + throw new OfflineException("Removing from playlist not available in offline mode"); + } + @Override public void updatePlaylist(String id, String name, String comment, Context context, ProgressListener progressListener) throws Exception { throw new OfflineException("Updating playlist not available in offline mode"); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java index 25bacb61..00e9f2b1 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -422,6 +422,25 @@ public class RESTMusicService implements MusicService { } } + @Override + public void removeFromPlaylist(String id, List toRemove, Context context, ProgressListener progressListener) throws Exception { + checkServerVersion(context, "1.8", "Updating playlists is not supported."); + List names = new ArrayList(); + List values = new ArrayList(); + names.add("playlistId"); + values.add(id); + for(Integer song: toRemove) { + names.add("songIndexToRemove"); + values.add(song); + } + Reader reader = getReader(context, progressListener, "updatePlaylist", null, names, values); + try { + new ErrorParser(context).parse(reader); + } finally { + Util.close(reader); + } + } + @Override public void updatePlaylist(String id, String name, String comment, Context context, ProgressListener progressListener) throws Exception { checkServerVersion(context, "1.8", "Updating playlists is not supported."); -- cgit v1.2.3 From 836141bc69e30848adf049a50a95cf4d81c38cc1 Mon Sep 17 00:00:00 2001 From: owner Date: Sat, 24 Nov 2012 08:27:49 -0800 Subject: Added support for setting genre/year range in services --- .../daneren2005/dsub/service/CachedMusicService.java | 4 ++-- .../github/daneren2005/dsub/service/DownloadService.java | 2 ++ .../daneren2005/dsub/service/DownloadServiceImpl.java | 5 +++++ .../src/github/daneren2005/dsub/service/MusicService.java | 2 +- .../daneren2005/dsub/service/OfflineMusicService.java | 2 +- .../github/daneren2005/dsub/service/RESTMusicService.java | 14 +++++++++++++- .../github/daneren2005/dsub/util/ShufflePlayBuffer.java | 12 +++++++++++- 7 files changed, 35 insertions(+), 6 deletions(-) (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java index c9233d01..fe0a3f19 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java @@ -191,8 +191,8 @@ public class CachedMusicService implements MusicService { } @Override - public MusicDirectory getRandomSongs(int size, String folder, Context context, ProgressListener progressListener) throws Exception { - return musicService.getRandomSongs(size, folder, context, progressListener); + public MusicDirectory getRandomSongs(int size, String folder, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) throws Exception { + return musicService.getRandomSongs(size, folder, genre, startYear, endYear, context, progressListener); } @Override diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java index d11c8285..f68f8db6 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadService.java @@ -38,6 +38,8 @@ public interface DownloadService { void setShufflePlayEnabled(boolean enabled); boolean isShufflePlayEnabled(); + + void setShuffleParams(String genre, String startYear, String endYear); void shuffle(); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index 38b3fe03..aae4829a 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -299,6 +299,11 @@ public class DownloadServiceImpl extends Service implements DownloadService { public synchronized boolean isShufflePlayEnabled() { return shufflePlay; } + + @Override + public void setShuffleParams(String genre, String startYear, String endYear) { + shufflePlayBuffer.setOptions(genre, startYear, endYear); + } @Override public synchronized void shuffle() { diff --git a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java index 67e4bed5..98951853 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java @@ -75,7 +75,7 @@ public interface MusicService { MusicDirectory getAlbumList(String type, int size, int offset, Context context, ProgressListener progressListener) throws Exception; - MusicDirectory getRandomSongs(int size, String folder, Context context, ProgressListener progressListener) throws Exception; + MusicDirectory getRandomSongs(int size, String folder, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) throws Exception; Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, boolean saveToFile, ProgressListener progressListener) throws Exception; diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java index ce353740..a12a169e 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -365,7 +365,7 @@ public class OfflineMusicService extends RESTMusicService { } @Override - public MusicDirectory getRandomSongs(int size, String folder, Context context, ProgressListener progressListener) throws Exception { + public MusicDirectory getRandomSongs(int size, String folder, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) throws Exception { File root = FileUtil.getMusicDirectory(context); List children = new LinkedList(); listFilesRecursively(root, children); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java index 00e9f2b1..75ec6142 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -495,7 +495,7 @@ public class RESTMusicService implements MusicService { } @Override - public MusicDirectory getRandomSongs(int size, String musicFolderId, Context context, ProgressListener progressListener) throws Exception { + public MusicDirectory getRandomSongs(int size, String musicFolderId, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) throws Exception { HttpParams params = new BasicHttpParams(); HttpConnectionParams.setSoTimeout(params, SOCKET_READ_TIMEOUT_GET_RANDOM_SONGS); @@ -509,6 +509,18 @@ public class RESTMusicService implements MusicService { names.add("musicFolderId"); values.add(musicFolderId); } + if(genre != null) { + names.add("genre"); + values.add(genre); + } + if(startYear != null) { + names.add("fromYear"); + values.add(startYear); + } + if(endYear != null) { + names.add("toYear"); + values.add(endYear); + } Reader reader = getReader(context, progressListener, "getRandomSongs", params, names, values); try { diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java b/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java index f30f3d6d..3cc26057 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java @@ -45,6 +45,10 @@ public class ShufflePlayBuffer { private Context context; private int currentServer; private String currentFolder; + + private String genre; + private String startYear; + private String endYear; public ShufflePlayBuffer(Context context) { this.context = context; @@ -88,7 +92,7 @@ public class ShufflePlayBuffer { MusicService service = MusicServiceFactory.getMusicService(context); int n = CAPACITY - buffer.size(); String folder = Util.getSelectedMusicFolderId(context); - MusicDirectory songs = service.getRandomSongs(n, folder, context, null); + MusicDirectory songs = service.getRandomSongs(n, folder, genre, startYear, endYear, context, null); synchronized (buffer) { buffer.addAll(songs.getChildren()); @@ -108,5 +112,11 @@ public class ShufflePlayBuffer { } } } + + public void setOptions(String genre, String startYear, String endYear) { + this.genre = genre; + this.startYear = startYear; + this.endYear = endYear; + } } -- cgit v1.2.3