aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/github')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java28
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java5
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Util.java37
5 files changed, 52 insertions, 23 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java b/app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java
index bc54f486..c2007139 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/ChromeCastController.java
@@ -62,6 +62,8 @@ public class ChromeCastController extends RemoteController {
private boolean error = false;
private boolean ignoreNextPaused = false;
private String sessionId;
+ private boolean isStopping = false;
+ private Runnable afterUpdateComplete = null;
private ServerProxy proxy;
private String rootLocation;
@@ -247,18 +249,38 @@ public class ChromeCastController extends RemoteController {
}
}
- void startSong(DownloadFile currentPlaying, boolean autoStart, int position) {
+ void startSong(final DownloadFile currentPlaying, final boolean autoStart, final int position) {
if(currentPlaying == null) {
try {
- if (mediaPlayer != null && !error) {
- mediaPlayer.stop(apiClient);
+ if (mediaPlayer != null && !error && !isStopping) {
+ isStopping = true;
+ mediaPlayer.stop(apiClient).setResultCallback(new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() {
+ @Override
+ public void onResult(RemoteMediaPlayer.MediaChannelResult mediaChannelResult) {
+ isStopping = false;
+
+ if(afterUpdateComplete != null) {
+ afterUpdateComplete.run();
+ afterUpdateComplete = null;
+ }
+ }
+ });
}
} catch(Exception e) {
// Just means it didn't need to be stopped
}
downloadService.setPlayerState(PlayerState.IDLE);
return;
+ } else if(isStopping) {
+ afterUpdateComplete = new Runnable() {
+ @Override
+ public void run() {
+ startSong(currentPlaying, autoStart, position);
+ }
+ };
+ return;
}
+
downloadService.setPlayerState(PlayerState.PREPARING);
MusicDirectory.Entry song = currentPlaying.getSong();
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
index d35a522c..e21e7c34 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java
@@ -1704,6 +1704,10 @@ public class DownloadService extends Service {
nextPlayingTask.cancel();
nextPlayingTask = null;
}
+
+ if(nextPlayerState != IDLE) {
+ setNextPlayerState(IDLE);
+ }
}
if(remoteState == LOCAL) {
diff --git a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
index 75023ec0..7a2edf79 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
@@ -947,10 +947,9 @@ public class RESTMusicService implements MusicService {
StringBuilder builder = new StringBuilder(getRestUrl(context, "stream"));
builder.append("&id=").append(song.getId());
- // If we are doing mp3 to mp3, just specify raw so that stuff works better
- if("mp3".equals(song.getSuffix()) && (song.getTranscodedSuffix() == null || "mp3".equals(song.getTranscodedSuffix())) && ServerInfo.checkServerVersion(context, "1.9", getInstance(context))) {
+ // Allow user to specify to stream raw formats if available
+ if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_CAST_STREAM_ORIGINAL, true) && ("mp3".equals(song.getSuffix()) || "flac".equals(song.getSuffix()) || "wav".equals(song.getSuffix()) || "aac".equals(song.getSuffix())) && ServerInfo.checkServerVersion(context, "1.9", getInstance(context))) {
builder.append("&format=raw");
- builder.append("&estimateContentLength=true");
} else {
builder.append("&maxBitRate=").append(maxBitrate);
}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Constants.java b/app/src/main/java/github/daneren2005/dsub/util/Constants.java
index 88b87481..9aebef83 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Constants.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Constants.java
@@ -171,6 +171,7 @@ public final class Constants {
public static final String PREFERENCES_KEY_RESUME_PLAY_QUEUE_NEVER = "neverResumePlayQueue";
public static final String PREFERENCES_KEY_BATCH_MODE = "batchMode";
public static final String PREFERENCES_KEY_CAST_GAPLESS_PLAYBACK = "castingGaplessPlayback";
+ public static final String PREFERENCES_KEY_CAST_STREAM_ORIGINAL = "castStreamOriginal";
public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount";
public static final String OFFLINE_SCROBBLE_ID = "scrobbleID";
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java
index be9536ed..435c33c0 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Util.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java
@@ -1245,32 +1245,35 @@ public final class Util {
}
showDetailsDialog(context, context.getResources().getString(title), headerStrings, details);
}
- public static void showDetailsDialog(Context context, String title, List<String> headers, List<String> details) {
+ public static void showDetailsDialog(Context context, String title, List<String> headers, final List<String> details) {
ListView listView = new ListView(context);
listView.setAdapter(new DetailsAdapter(context, R.layout.details_item, headers, details));
listView.setDivider(null);
listView.setScrollbarFadingEnabled(false);
- // Let the user long-click on a row to copy its value to the clipboard
- final Context contextRef = context;
- listView.setOnItemLongClickListener(new ListView.OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView<?> parent, View view, int pos, long id) {
+ // Let the user long-click on a row to copy its value to the clipboard
+ final Context contextRef = context;
+ listView.setOnItemLongClickListener(new ListView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int pos, long id) {
+ TextView nameView = (TextView) view.findViewById(R.id.detail_name);
+ TextView detailsView = (TextView) view.findViewById(R.id.detail_value);
+ if(nameView == null || detailsView == null) {
+ return false;
+ }
- TextView nameView = (TextView) view.findViewById(R.id.detail_name);
- TextView detailsView = (TextView) view.findViewById(R.id.detail_value);
- CharSequence name = nameView.getText();
- CharSequence value = detailsView.getText();
+ CharSequence name = nameView.getText();
+ CharSequence value = detailsView.getText();
- ClipboardManager clipboard = (ClipboardManager) contextRef.getSystemService(Context.CLIPBOARD_SERVICE);
- ClipData clip = ClipData.newPlainText(name, value);
- clipboard.setPrimaryClip(clip);
+ ClipboardManager clipboard = (ClipboardManager) contextRef.getSystemService(Context.CLIPBOARD_SERVICE);
+ ClipData clip = ClipData.newPlainText(name, value);
+ clipboard.setPrimaryClip(clip);
- toast(contextRef, "Copied " + name + " to clipboard");
+ toast(contextRef, "Copied " + name + " to clipboard");
- return true;
- }
- });
+ return true;
+ }
+ });
new AlertDialog.Builder(context)
// .setIcon(android.R.drawable.ic_dialog_info)