From 35c3356f1b63457fc7072d60e8ba01e0aba3ec28 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Tue, 8 Jul 2014 19:28:15 -0700 Subject: Close drawer if open on back press --- src/github/daneren2005/dsub/activity/SubsonicActivity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 395a347e..92775f3e 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -494,7 +494,10 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte } public boolean onBackPressedSupport() { - if(backStack.size() > 0) { + if(drawerOpen) { + drawer.closeDrawers(); + return false; + } else if(backStack.size() > 0) { removeCurrent(); return false; } else { -- cgit v1.2.3 From 6a7aaafd33695307a2ac268642a967c1c9b45161 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 9 Jul 2014 08:26:23 -0700 Subject: If no songs, use simple grid view to allow recycling The UnscrollableGridView inflates every single view at the same time, which causes major performance issues on larger lists. IF there are no songs, just use the simple GridView which inflates and recycles them properly. --- .../daneren2005/dsub/fragments/SelectDirectoryFragment.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index d40f8fad..aa8293f9 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -662,7 +662,16 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter // Needs to be added here, GB crashes if you to try to remove the header view before adapter is set if(addAlbumHeader) { - entryList.addHeaderView(albumList); + if(showHeader) { + entryList.addHeaderView(albumList); + } else { + ViewGroup rootGroup = (ViewGroup) rootView.findViewById(R.id.select_album_layout); + albumList = (GridView) inflater.inflate(R.layout.grid_view, rootGroup, false); + rootGroup.removeView(entryList); + rootGroup.addView(albumList); + + setupScrollList(albumList); + } addAlbumHeader = false; } -- cgit v1.2.3 From a7ca15ba720681947dd3ed8507941e89db7c042a Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 9 Jul 2014 08:31:17 -0700 Subject: Only resume playing if still in PAUSED_TEMP state If during the call, the audio_noisy broadcast is received, don't want to resume playing since it will then be in the PAUSED state. --- .../daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 76c9abeb..18502846 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -332,7 +332,9 @@ public class DownloadServiceLifecycleSupport { case TelephonyManager.CALL_STATE_IDLE: if (resumeAfterCall) { resumeAfterCall = false; - downloadService.start(); + if(downloadService.getPlayerState() == PlayerState.PAUSED_TEMP) { + downloadService.start(); + } } break; default: -- cgit v1.2.3 From 9e44860e3758f9d736c63934897a5d61e4fa9e17 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 9 Jul 2014 08:34:33 -0700 Subject: Pausing while in PAUSED_TEMP needs to set playerState --- src/github/daneren2005/dsub/service/DownloadService.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index f28c38dc..901d0578 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -934,6 +934,8 @@ public class DownloadService extends Service { mediaPlayer.pause(); } setPlayerState(temp ? PAUSED_TEMP : PAUSED); + } else if(playerState == PAUSED_TEMP) { + setPlayerState(temp ? PAUSED_TEMP : PAUSED); } } catch (Exception x) { handleError(x); -- cgit v1.2.3 From b2c79de472485c9579789289d599c9d42f575564 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 9 Jul 2014 08:37:54 -0700 Subject: Fix issue with recycling between movies and songs --- src/github/daneren2005/dsub/view/SongView.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/view/SongView.java b/src/github/daneren2005/dsub/view/SongView.java index 3e423877..e6156ceb 100644 --- a/src/github/daneren2005/dsub/view/SongView.java +++ b/src/github/daneren2005/dsub/view/SongView.java @@ -48,6 +48,7 @@ public class SongView extends UpdateView implements Checkable { private TextView durationTextView; private TextView statusTextView; private ImageView statusImageView; + private View bottomRowView; private DownloadService downloadService; private long revision = -1; @@ -80,6 +81,7 @@ public class SongView extends UpdateView implements Checkable { v.showContextMenu(); } }); + bottomRowView = findViewById(R.id.song_bottom); } public void setObjectImpl(Object obj1, Object obj2) { @@ -120,8 +122,9 @@ public class SongView extends UpdateView implements Checkable { } durationTextView.setText(Util.formatDuration(song.getDuration())); + bottomRowView.setVisibility(View.VISIBLE); } else { - findViewById(R.id.song_bottom).setVisibility(View.GONE); + bottomRowView.setVisibility(View.GONE); statusTextView.setText(Util.formatDuration(song.getDuration())); } -- cgit v1.2.3 From 103e8d074f6b6ef6c57cb5a2a2b38a7630926a3a Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 9 Jul 2014 09:48:25 -0700 Subject: #375 Use standard expanded view with x for persistent notifications There isn't enough room to add a x to the small version, so still needs to show the reconstructed version. For the expanded view use the standard notification layout, but show the x for closing the app. --- src/github/daneren2005/dsub/util/Notifications.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/util/Notifications.java b/src/github/daneren2005/dsub/util/Notifications.java index de4129e9..142fffcb 100644 --- a/src/github/daneren2005/dsub/util/Notifications.java +++ b/src/github/daneren2005/dsub/util/Notifications.java @@ -65,13 +65,13 @@ public final class Notifications { boolean remote = downloadService.isRemoteEnabled(); if (Build.VERSION.SDK_INT>= Build.VERSION_CODES.JELLY_BEAN){ RemoteViews expandedContentView = new RemoteViews(context.getPackageName(), R.layout.notification_expanded); - setupViews(expandedContentView,context,song, playing, remote); + setupViews(expandedContentView ,context, song, true, playing, remote); notification.bigContentView = expandedContentView; notification.priority = Notification.PRIORITY_HIGH; } RemoteViews smallContentView = new RemoteViews(context.getPackageName(), R.layout.notification); - setupViews(smallContentView, context, song, playing, remote); + setupViews(smallContentView, context, song, false, playing, remote); notification.contentView = smallContentView; Intent notificationIntent = new Intent(context, SubsonicFragmentActivity.class); @@ -103,7 +103,7 @@ public final class Notifications { DSubWidgetProvider.notifyInstances(context, downloadService, playing); } - private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean playing, boolean remote){ + private static void setupViews(RemoteViews rv, Context context, MusicDirectory.Entry song, boolean expanded, boolean playing, boolean remote){ // Use the same text for the ticker and the expanded notification String title = song.getTitle(); @@ -141,7 +141,8 @@ public final class Notifications { rv.setTextColor(R.id.notification_artist, colors.getSecond()); } - if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PERSISTENT_NOTIFICATION, false)) { + boolean persistent = Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PERSISTENT_NOTIFICATION, false); + if(persistent && !expanded) { rv.setImageViewResource(R.id.control_previous, playing ? R.drawable.notification_pause : R.drawable.notification_play); rv.setImageViewResource(R.id.control_pause, R.drawable.notification_next); rv.setImageViewResource(R.id.control_next, R.drawable.notification_close); @@ -150,7 +151,7 @@ public final class Notifications { // Create actions for media buttons PendingIntent pendingIntent; int previous = 0, pause = 0, next = 0, close = 0; - if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PERSISTENT_NOTIFICATION, false)) { + if(persistent && !expanded) { pause = R.id.control_previous; next = R.id.control_pause; close = R.id.control_next; @@ -160,7 +161,7 @@ public final class Notifications { next = R.id.control_next; } - if(remote && close == 0) { + if((remote || persistent) && close == 0) { close = R.id.notification_close; rv.setViewVisibility(close, View.VISIBLE); } -- cgit v1.2.3 From ea1204acc79201c9b366f982207e34e0ab3d1236 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 9 Jul 2014 22:03:54 -0700 Subject: Fix new simple grid views not being clickable --- .../dsub/fragments/SelectDirectoryFragment.java | 52 ++++++++++++---------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index aa8293f9..fea3d44c 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -164,28 +164,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter setupScrollList(albumList); } - albumList.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - MusicDirectory.Entry entry = (MusicDirectory.Entry) parent.getItemAtPosition(position); - SubsonicFragment fragment = new SelectDirectoryFragment(); - Bundle args = new Bundle(); - args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getId()); - args.putString(Constants.INTENT_EXTRA_NAME_NAME, entry.getTitle()); - if ("newest".equals(albumListType)) { - args.putBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS, true); - } - if(entry.getArtist() == null && entry.getParent() == null) { - args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true); - } - fragment.setArguments(args); - - replaceFragment(fragment, true); - } - }); - registerForContextMenu(entryList); - registerForContextMenu(albumList); + setupAlbumList(); if(entries == null) { if(primaryFragment || secondaryFragment) { @@ -662,15 +642,16 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter // Needs to be added here, GB crashes if you to try to remove the header view before adapter is set if(addAlbumHeader) { - if(showHeader) { + if(entries.size() > 0) { entryList.addHeaderView(albumList); } else { ViewGroup rootGroup = (ViewGroup) rootView.findViewById(R.id.select_album_layout); - albumList = (GridView) inflater.inflate(R.layout.grid_view, rootGroup, false); + albumList = (GridView) context.getLayoutInflater().inflate(R.layout.grid_view, rootGroup, false); rootGroup.removeView(entryList); rootGroup.addView(albumList); setupScrollList(albumList); + setupAlbumList(); } addAlbumHeader = false; } @@ -727,6 +708,31 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter } } + private void setupAlbumList() { + albumList.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + MusicDirectory.Entry entry = (MusicDirectory.Entry) parent.getItemAtPosition(position); + SubsonicFragment fragment = new SelectDirectoryFragment(); + Bundle args = new Bundle(); + args.putString(Constants.INTENT_EXTRA_NAME_ID, entry.getId()); + args.putString(Constants.INTENT_EXTRA_NAME_NAME, entry.getTitle()); + if ("newest".equals(albumListType)) { + args.putBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS, true); + } + if(entry.getArtist() == null && entry.getParent() == null) { + args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true); + } + fragment.setArguments(args); + + replaceFragment(fragment, true); + } + }); + + registerForContextMenu(entryList); + registerForContextMenu(albumList); + } + private void playNow(final boolean shuffle, final boolean append) { playNow(shuffle, append, false); } -- cgit v1.2.3 From 109c35a36ed0d382664f7a57c83914137f701caf Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 9 Jul 2014 22:06:52 -0700 Subject: #375 Fix expanded persistent notification not toggling play/pause display --- src/github/daneren2005/dsub/util/Notifications.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/util/Notifications.java b/src/github/daneren2005/dsub/util/Notifications.java index 142fffcb..75c69d9e 100644 --- a/src/github/daneren2005/dsub/util/Notifications.java +++ b/src/github/daneren2005/dsub/util/Notifications.java @@ -142,10 +142,14 @@ public final class Notifications { } boolean persistent = Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_PERSISTENT_NOTIFICATION, false); - if(persistent && !expanded) { - rv.setImageViewResource(R.id.control_previous, playing ? R.drawable.notification_pause : R.drawable.notification_play); - rv.setImageViewResource(R.id.control_pause, R.drawable.notification_next); - rv.setImageViewResource(R.id.control_next, R.drawable.notification_close); + if(persistent) { + if(expanded) { + rv.setImageViewResource(R.id.control_pause, playing ? R.drawable.notification_pause : R.drawable.notification_play); + } else { + rv.setImageViewResource(R.id.control_previous, playing ? R.drawable.notification_pause : R.drawable.notification_play); + rv.setImageViewResource(R.id.control_pause, R.drawable.notification_next); + rv.setImageViewResource(R.id.control_next, R.drawable.notification_close); + } } // Create actions for media buttons -- cgit v1.2.3 From 45c668b341c92130c1060492676285ec26487575 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 10 Jul 2014 15:56:44 -0700 Subject: Add a byYear option to do sort without byYear --- .../daneren2005/dsub/domain/MusicDirectory.java | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/domain/MusicDirectory.java b/src/github/daneren2005/dsub/domain/MusicDirectory.java index c284ba00..363a1540 100644 --- a/src/github/daneren2005/dsub/domain/MusicDirectory.java +++ b/src/github/daneren2005/dsub/domain/MusicDirectory.java @@ -422,23 +422,31 @@ public class MusicDirectory implements Serializable { } public static class EntryComparator implements Comparator { + private boolean byYear; + + public EntryComparator(boolean byYear) { + this.byYear = byYear; + } + public int compare(Entry lhs, Entry rhs) { if(lhs.isDirectory() && !rhs.isDirectory()) { return -1; } else if(!lhs.isDirectory() && rhs.isDirectory()) { return 1; } else if(lhs.isDirectory() && rhs.isDirectory()) { - Integer lhsYear = lhs.getYear(); - Integer rhsYear = rhs.getYear(); - if(lhsYear != null && rhsYear != null) { - return lhsYear.compareTo(rhsYear); - } else if(lhsYear != null) { - return -1; - } else if(rhsYear != null) { - return 1; - } else { - return lhs.getTitle().compareToIgnoreCase(rhs.getTitle()); + if(byYear) { + Integer lhsYear = lhs.getYear(); + Integer rhsYear = rhs.getYear(); + if(lhsYear != null && rhsYear != null) { + return lhsYear.compareTo(rhsYear); + } else if(lhsYear != null) { + return -1; + } else if(rhsYear != null) { + return 1; + } } + + return lhs.getTitle().compareToIgnoreCase(rhs.getTitle()); } Integer lhsDisc = lhs.getDiscNumber(); @@ -466,8 +474,11 @@ public class MusicDirectory implements Serializable { } public static void sort(List entries) { + sort(entries, true); + } + public static void sort(List entries, boolean byYear) { try { - Collections.sort(entries, new EntryComparator()); + Collections.sort(entries, new EntryComparator(byYear)); } catch (Exception e) { Log.w(TAG, "Failed to sort MusicDirectory"); } -- cgit v1.2.3 From 458c60d6915ba46b788b2e96bcc3df9f56988d3c Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 10 Jul 2014 20:20:33 -0700 Subject: Change sort option to be sort by year or by alphabetical --- res/values/strings.xml | 4 ++-- src/github/daneren2005/dsub/domain/MusicDirectory.java | 4 ++-- src/github/daneren2005/dsub/service/OfflineMusicService.java | 2 +- src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/res/values/strings.xml b/res/values/strings.xml index 89492cd7..77f18ea9 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -284,8 +284,8 @@ Hide as many UI elements as Android will allow Display Track # Display Track # in front of songs if one exists - Custom Sort - Override default server sorting to sort by disc number and by year. + Sort By Year + Sort albums by year, or by alphabetical Open To Library Open directly to the library screen instead of opening to home. Network diff --git a/src/github/daneren2005/dsub/domain/MusicDirectory.java b/src/github/daneren2005/dsub/domain/MusicDirectory.java index 363a1540..492726f9 100644 --- a/src/github/daneren2005/dsub/domain/MusicDirectory.java +++ b/src/github/daneren2005/dsub/domain/MusicDirectory.java @@ -102,8 +102,8 @@ public class MusicDirectory implements Serializable { return children.size(); } - public void sortChildren() { - EntryComparator.sort(children); + public void sortChildren(boolean byYear) { + EntryComparator.sort(children, byYear); } public static class Entry implements Serializable { diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java index a92e41d1..04955cc3 100644 --- a/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -134,7 +134,7 @@ public class OfflineMusicService extends RESTMusicService { result.addChild(createEntry(context, file, name, true, isPodcast)); } } - result.sortChildren(); + result.sortChildren(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_CUSTOM_SORT_ENABLED, true)); return result; } diff --git a/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java b/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java index e705c54d..95ee1744 100644 --- a/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java +++ b/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java @@ -97,8 +97,8 @@ public class MusicDirectoryParser extends MusicDirectoryEntryParser { validate(); // Only apply sorting on server version 4.7 and greater, where disc is supported - if(Util.checkServerVersion(context, "1.8.0") && Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_CUSTOM_SORT_ENABLED, true)) { - dir.sortChildren(); + if(Util.checkServerVersion(context, "1.8.0")) { + dir.sortChildren(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_CUSTOM_SORT_ENABLED, true)); } return dir; -- cgit v1.2.3 From 2b11caece9c49406099fc192fda4215171ef0f58 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Fri, 11 Jul 2014 19:48:57 -0700 Subject: Fix issue with going to repeat song mode not removing nextPlaying setup --- .../daneren2005/dsub/service/DownloadService.java | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 901d0578..44c22009 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -700,6 +700,7 @@ public class DownloadService extends Service { nextPlayingTask = new CheckCompletionTask(nextPlaying); nextPlayingTask.execute(); } else { + resetNext(); nextPlaying = null; } } @@ -996,6 +997,21 @@ public class DownloadService extends Service { } } + public synchronized void resetNext() { + if(nextMediaPlayer != null) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + mediaPlayer.setNextMediaPlayer(null); + nextSetup = false; + } + + nextMediaPlayer.setOnCompletionListener(null); + nextMediaPlayer.setOnErrorListener(null); + nextMediaPlayer.reset(); + nextMediaPlayer.release(); + nextMediaPlayer = null; + } + } + public int getPlayerPosition() { try { if (playerState == IDLE || playerState == DOWNLOADING || playerState == PREPARING) { @@ -1397,13 +1413,7 @@ public class DownloadService extends Service { private synchronized void setupNext(final DownloadFile downloadFile) { try { final File file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteFile() : downloadFile.getPartialFile(); - if(nextMediaPlayer != null) { - nextMediaPlayer.setOnCompletionListener(null); - nextMediaPlayer.setOnErrorListener(null); - nextMediaPlayer.reset(); - nextMediaPlayer.release(); - nextMediaPlayer = null; - } + resetNext(); // Exit when using remote controllers if(remoteState != RemoteControlState.LOCAL) { -- cgit v1.2.3 From 9ac927c4c812149802fccdeb42dd66573c2c5281 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 12 Jul 2014 13:18:50 -0700 Subject: Fix crash when starting with nothing in list --- .../daneren2005/dsub/service/DownloadService.java | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java index 44c22009..f458379d 100644 --- a/src/github/daneren2005/dsub/service/DownloadService.java +++ b/src/github/daneren2005/dsub/service/DownloadService.java @@ -998,17 +998,21 @@ public class DownloadService extends Service { } public synchronized void resetNext() { - if(nextMediaPlayer != null) { - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - mediaPlayer.setNextMediaPlayer(null); - nextSetup = false; - } + try { + if (nextMediaPlayer != null) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && nextSetup) { + mediaPlayer.setNextMediaPlayer(null); + nextSetup = false; + } - nextMediaPlayer.setOnCompletionListener(null); - nextMediaPlayer.setOnErrorListener(null); - nextMediaPlayer.reset(); - nextMediaPlayer.release(); - nextMediaPlayer = null; + nextMediaPlayer.setOnCompletionListener(null); + nextMediaPlayer.setOnErrorListener(null); + nextMediaPlayer.reset(); + nextMediaPlayer.release(); + nextMediaPlayer = null; + } + } catch (Exception e) { + Log.w(TAG, "Failed to reset next media player"); } } -- cgit v1.2.3