aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-05-02 13:34:54 -0700
committerdaneren2005 <daneren2005@gmail.com>2013-05-02 13:34:54 -0700
commit4cce0da4f6a5b201a90c09db00086a6e5a601e6e (patch)
tree511b07247598b92820f69bf86a5fc7a89738868c /subsonic-android/src
parentca8b3539a6401c63e81f1fd666ba85e5dfc24350 (diff)
downloaddsub-4cce0da4f6a5b201a90c09db00086a6e5a601e6e.tar.gz
dsub-4cce0da4f6a5b201a90c09db00086a6e5a601e6e.tar.bz2
dsub-4cce0da4f6a5b201a90c09db00086a6e5a601e6e.zip
Put in conditional use of getAudioSessionId for Froyo and lower
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java30
1 files changed, 21 insertions, 9 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index bdd1d4e1..2c6a1059 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -157,10 +157,14 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
});
- Intent i = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
- i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mediaPlayer.getAudioSessionId());
- i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
- sendBroadcast(i);
+ try {
+ Intent i = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
+ i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mediaPlayer.getAudioSessionId());
+ i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
+ sendBroadcast(i);
+ } catch(Exception e) {
+ // Froyo or lower
+ }
mediaPlayerLooper = Looper.myLooper();
mediaPlayerHandler = new Handler(mediaPlayerLooper);
@@ -216,10 +220,14 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
lifecycleSupport.onDestroy();
- Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
- i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mediaPlayer.getAudioSessionId());
- i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
- sendBroadcast(i);
+ try {
+ Intent i = new Intent(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
+ i.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, mediaPlayer.getAudioSessionId());
+ i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
+ sendBroadcast(i);
+ } catch(Exception e) {
+ // Froyo or lower
+ }
mediaPlayer.release();
if(nextMediaPlayer != null) {
@@ -1068,7 +1076,11 @@ public class DownloadServiceImpl extends Service implements DownloadService {
}
nextMediaPlayer = new MediaPlayer();
nextMediaPlayer.setWakeMode(DownloadServiceImpl.this, PowerManager.PARTIAL_WAKE_LOCK);
- nextMediaPlayer.setAudioSessionId(mediaPlayer.getAudioSessionId());
+ try {
+ nextMediaPlayer.setAudioSessionId(mediaPlayer.getAudioSessionId());
+ } catch(Exception e) {
+ nextMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
+ }
nextMediaPlayer.setDataSource(file.getPath());
setNextPlayerState(PREPARING);