From 18efc9ecc8c9c22e4d7a6dfac6d3de966e723d37 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 22 Oct 2014 15:59:19 -0700 Subject: #415 Add method to force cutoff when calling next --- src/github/daneren2005/dsub/service/DownloadService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 81289f86..08516cfd 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -917,6 +917,9 @@ public class DownloadService extends Service { } public synchronized void next() { + + } + public synchronized void next(boolean forceCutoff) { // If only one song, just skip within song if(size() == 1) { seekTo(getPlayerPosition() + FAST_FORWARD); @@ -926,7 +929,12 @@ public class DownloadService extends Service { // Delete podcast if fully listened to int position = getPlayerPosition(); int duration = getPlayerDuration(); - boolean cutoff = isPastCutoff(position, duration); + boolean cutoff; + if(forceCutoff) { + cutoff = true; + } else { + cutoff = isPastCutoff(position, duration); + } if(currentPlaying != null && currentPlaying.getSong() instanceof PodcastEpisode) { if(cutoff) { toDelete.add(currentPlaying); -- cgit v1.2.3 From 7c18c3464a158bb7b348688a32260ffd01016409 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 22 Oct 2014 16:00:10 -0700 Subject: #415 When down rating song, force cutoff detection for bookmarks/cache --- src/github/daneren2005/dsub/fragments/NowPlayingFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java index eb4ce5ab..b6daea98 100644 --- a/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/src/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -400,7 +400,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis } } else { // Immediately skip to the next song - downloadService.next(); + downloadService.next(true); // Otherwise set rating to 1 setRating(entry, 1); -- cgit v1.2.3 From 6b6b3bcbcf47de353ff7ad3f82d6c6228a04c9d8 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 22 Oct 2014 16:10:09 -0700 Subject: #415 Don't auto delete bookmarks made with 10 seconds of current position --- src/github/daneren2005/dsub/service/DownloadService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 08516cfd..8d9f6867 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -1890,7 +1890,18 @@ public class DownloadService extends Service { } private boolean isPastCutoff(int position, int duration) { int cutoffPoint = (int) (duration * DELETE_CUTOFF); - return duration > 0 && position > cutoffPoint; + boolean isPastCutoff = duration > 0 && position > cutoffPoint; + + // Check to make sure song isn't within 10 seconds of where it was created + MusicDirectory.Entry entry = currentPlaying.getSong(); + if(entry != null && entry.getBookmark() != null) { + Bookmark bookmark = entry.getBookmark(); + if(position < (bookmark.getPosition() + 10000)) { + isPastCutoff = false; + } + } + + return isPastCutoff; } private void clearCurrentBookmark() { -- cgit v1.2.3 From 666f6bb24019e5b8e74f5754049eda6983b7cdba Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sun, 26 Oct 2014 10:07:28 -0700 Subject: Fix NPE when playing from empty list --- src/github/daneren2005/dsub/service/DownloadService.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 69ed7c7f..a5b647a9 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -1888,6 +1888,10 @@ public class DownloadService extends Service { return isPastCutoff(getPlayerPosition(), getPlayerDuration()); } private boolean isPastCutoff(int position, int duration) { + if(currentPlaying == null) { + return false; + } + int cutoffPoint = (int) (duration * DELETE_CUTOFF); boolean isPastCutoff = duration > 0 && position > cutoffPoint; -- cgit v1.2.3 From 805d1067441c31a3dececb1287115fb99ea1ea4d Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 27 Oct 2014 16:11:45 -0700 Subject: #415 Improve bookmark logic when playing a series of audio books For audio books we want to modify the automatic creation of deletion of bookmarks. An example of what this is supposed to handle: Start in chapter 8 from bookmark, continue to chapter to 9 of 10. At position 8:50 of 10:00. Start playing some music. Current behavior is that this will have deleted a bookmark from 8 and not create one at 9. Now, it will create one at 9 since there is still another chapter to read. --- .../daneren2005/dsub/service/DownloadService.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index a5b647a9..afa91d90 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -575,7 +575,7 @@ public class DownloadService extends Service { // Delete podcast if fully listened to int position = getPlayerPosition(); int duration = getPlayerDuration(); - boolean cutoff = isPastCutoff(position, duration); + boolean cutoff = isPastCutoff(position, duration, true); if(currentPlaying != null && currentPlaying.getSong() instanceof PodcastEpisode) { if(cutoff) { currentPlaying.delete(); @@ -1888,6 +1888,9 @@ public class DownloadService extends Service { return isPastCutoff(getPlayerPosition(), getPlayerDuration()); } private boolean isPastCutoff(int position, int duration) { + return isPastCutoff(position, duration, false); + } + private boolean isPastCutoff(int position, int duration, boolean allowSkipping) { if(currentPlaying == null) { return false; } @@ -1904,6 +1907,18 @@ public class DownloadService extends Service { } } + // Check to make sure we aren't in a series of similar content before deleting bookmark + if(isPastCutoff && allowSkipping) { + // Check to make sure: + // Is an audio book + // Next playing exists and is not a wrap around or a shuffle + // Next playing is from same context as current playing, so not at end of list + if(entry.isAudioBook() && nextPlaying != null && downloadList.indexOf(nextPlaying) != 0 && !shuffleMode && !shuffleRemote + && entry.getParent() != null && entry.getParent().equals(nextPlaying.getSong().getParent())) { + isPastCutoff = false; + } + } + return isPastCutoff; } -- cgit v1.2.3 From 2c1748691df839eb6543c14732e598cc60c3aa89 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 27 Oct 2014 22:05:50 -0700 Subject: Fix typo in isAudioBook --- src/github/daneren2005/dsub/domain/MusicDirectory.java | 2 +- src/github/daneren2005/dsub/service/DownloadService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/domain/MusicDirectory.java b/src/github/daneren2005/dsub/domain/MusicDirectory.java index 79472a89..d0bc173b 100644 --- a/src/github/daneren2005/dsub/domain/MusicDirectory.java +++ b/src/github/daneren2005/dsub/domain/MusicDirectory.java @@ -453,7 +453,7 @@ public class MusicDirectory implements Serializable { public boolean isPodcast() { return this instanceof PodcastEpisode || type == TYPE_PODCAST; } - public boolean isAudiBook() { + public boolean isAudioBook() { return type == TYPE_AUDIO_BOOK; } diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index afa91d90..c2ff73b8 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -1987,7 +1987,7 @@ public class DownloadService extends Service { int duration = getPlayerDuration(); // If song is podcast or long go ahead and auto add a bookmark - if(entry.isPodcast() || entry.isAudiBook() || duration > (10L * 60L * 1000L)) { + if(entry.isPodcast() || entry.isAudioBook() || duration > (10L * 60L * 1000L)) { final Context context = this; final int position = getPlayerPosition(); -- cgit v1.2.3 From 5472ad82e1e236614df060d0fea170d6b9f5e3e5 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 29 Oct 2014 14:37:04 -0700 Subject: Fix new default next() not actually calling anything --- src/github/daneren2005/dsub/service/DownloadService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index c2ff73b8..c7298169 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -916,7 +916,7 @@ public class DownloadService extends Service { } public synchronized void next() { - + next(false); } public synchronized void next(boolean forceCutoff) { // If only one song, just skip within song -- cgit v1.2.3