aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/activity/SubsonicActivity.java2
-rw-r--r--src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java10
-rw-r--r--src/github/daneren2005/dsub/service/ChromeCastController.java13
-rw-r--r--src/github/daneren2005/dsub/service/DownloadService.java12
-rw-r--r--src/github/daneren2005/dsub/service/JukeboxController.java10
-rw-r--r--src/github/daneren2005/dsub/service/RemoteController.java3
6 files changed, 40 insertions, 10 deletions
diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
index 154f7f24..646fa295 100644
--- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -350,7 +350,7 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte
boolean isJukebox = getDownloadService() != null && getDownloadService().isRemoteEnabled();
if (isVolumeAdjust && isJukebox) {
- getDownloadService().setRemoteVolume(isVolumeUp);
+ getDownloadService().updateRemoteVolume(isVolumeUp);
return true;
}
return super.onKeyDown(keyCode, event);
diff --git a/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java b/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java
index f4a8bed9..0d2a5ff5 100644
--- a/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java
+++ b/src/github/daneren2005/dsub/provider/JukeboxRouteProvider.java
@@ -115,7 +115,15 @@ public class JukeboxRouteProvider extends MediaRouteProvider {
@Override
public void onUpdateVolume(int delta) {
if(controller != null) {
- controller.setVolume(delta > 0);
+ controller.updateVolume(delta > 0);
+ }
+ broadcastDescriptor();
+ }
+
+ @Override
+ public void onSetVolume(int volume) {
+ if(controller != null) {
+ controller.setVolume(volume);
}
broadcastDescriptor();
}
diff --git a/src/github/daneren2005/dsub/service/ChromeCastController.java b/src/github/daneren2005/dsub/service/ChromeCastController.java
index 5b5a8c6e..7568fe4d 100644
--- a/src/github/daneren2005/dsub/service/ChromeCastController.java
+++ b/src/github/daneren2005/dsub/service/ChromeCastController.java
@@ -200,7 +200,18 @@ public class ChromeCastController extends RemoteController {
}
@Override
- public void setVolume(boolean up) {
+ public void setVolume(int volume) {
+ gain = volume / 10.0;
+
+ getVolumeToast().setVolume((float) gain);
+ try {
+ Cast.CastApi.setVolume(apiClient, gain);
+ } catch(Exception e) {
+ Log.e(TAG, "Failed to the volume");
+ }
+ }
+ @Override
+ public void updateVolume(boolean up) {
double delta = up ? 0.1 : -0.1;
gain += delta;
gain = Math.max(gain, 0.0);
diff --git a/src/github/daneren2005/dsub/service/DownloadService.java b/src/github/daneren2005/dsub/service/DownloadService.java
index 19c7a44a..66295d5e 100644
--- a/src/github/daneren2005/dsub/service/DownloadService.java
+++ b/src/github/daneren2005/dsub/service/DownloadService.java
@@ -30,7 +30,6 @@ import static github.daneren2005.dsub.domain.PlayerState.STOPPED;
import github.daneren2005.dsub.audiofx.AudioEffectsController;
import github.daneren2005.dsub.audiofx.EqualizerController;
-import github.daneren2005.dsub.audiofx.LoudnessEnhancerController;
import github.daneren2005.dsub.audiofx.VisualizerController;
import github.daneren2005.dsub.domain.Bookmark;
import github.daneren2005.dsub.domain.MusicDirectory;
@@ -73,7 +72,6 @@ import android.support.v7.media.MediaRouteSelector;
import android.support.v7.media.MediaRouter;
import android.util.Log;
import android.support.v4.util.LruCache;
-import java.net.URLEncoder;
/**
* @author Sindre Mehus
@@ -1239,11 +1237,11 @@ public class DownloadService extends Service {
mRemoteControl.unregisterRoute(router);
}
- public void setRemoteVolume(boolean up) {
+ public void updateRemoteVolume(boolean up) {
if(remoteState == RemoteControlState.JUKEBOX_SERVER) {
mediaRouter.getSelectedRoute().requestUpdateVolume(up ? 1 : -1);
} else {
- remoteController.setVolume(up);
+ remoteController.updateVolume(up);
}
}
@@ -1534,7 +1532,11 @@ public class DownloadService extends Service {
private void handleError(Exception x) {
Log.w(TAG, "Media player error: " + x, x);
if(mediaPlayer != null) {
- mediaPlayer.reset();
+ try {
+ mediaPlayer.reset();
+ } catch(Exception e) {
+ Log.e(TAG, "Failed to reset player in error handler");
+ }
}
setPlayerState(IDLE);
}
diff --git a/src/github/daneren2005/dsub/service/JukeboxController.java b/src/github/daneren2005/dsub/service/JukeboxController.java
index 09591933..da1538be 100644
--- a/src/github/daneren2005/dsub/service/JukeboxController.java
+++ b/src/github/daneren2005/dsub/service/JukeboxController.java
@@ -124,7 +124,15 @@ public class JukeboxController extends RemoteController {
downloadService.setPlayerState(PlayerState.STARTED);
}
@Override
- public void setVolume(boolean up) {
+ public void setVolume(int volume) {
+ gain = volume / 10.0f;
+
+ getVolumeToast().setVolume(gain);
+ tasks.remove(SetGain.class);
+ tasks.add(new SetGain(gain));
+ }
+ @Override
+ public void updateVolume(boolean up) {
float delta = up ? 0.1f : -0.1f;
gain += delta;
gain = Math.max(gain, 0.0f);
diff --git a/src/github/daneren2005/dsub/service/RemoteController.java b/src/github/daneren2005/dsub/service/RemoteController.java
index 401fc516..d5a4d8df 100644
--- a/src/github/daneren2005/dsub/service/RemoteController.java
+++ b/src/github/daneren2005/dsub/service/RemoteController.java
@@ -46,7 +46,8 @@ public abstract class RemoteController {
public abstract void updatePlaylist();
public abstract void changePosition(int seconds);
public abstract void changeTrack(int index, DownloadFile song);
- public abstract void setVolume(boolean up);
+ public abstract void setVolume(int volume);
+ public abstract void updateVolume(boolean up);
public abstract double getVolume();
public abstract int getRemotePosition();