diff options
Diffstat (limited to 'core/src/main')
4 files changed, 45 insertions, 7 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index 9ca05d1f7..729ea9e7a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -142,6 +142,11 @@ public class PlaybackService extends Service { public static final int NOTIFICATION_TYPE_PLAYBACK_SPEED_CHANGE = 8; /** + * Ability to set the playback speed has changed + */ + public static final int NOTIFICATION_TYPE_SET_SPEED_ABILITY_CHANGED = 9; + + /** * Returned by getPositionSafe() or getDurationSafe() if the playbackService * is in an invalid state. */ @@ -512,8 +517,11 @@ public class PlaybackService extends Service { @Override public void playbackSpeedChanged(float s) { - sendNotificationBroadcast( - NOTIFICATION_TYPE_PLAYBACK_SPEED_CHANGE, 0); + sendNotificationBroadcast(NOTIFICATION_TYPE_PLAYBACK_SPEED_CHANGE, 0); + } + + public void setSpeedAbilityChanged() { + sendNotificationBroadcast(NOTIFICATION_TYPE_SET_SPEED_ABILITY_CHANGED, 0); } @Override diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java index 3ab26eb22..aa51840a7 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java @@ -25,6 +25,8 @@ import android.view.WindowManager; import com.bumptech.glide.Glide; +import org.antennapod.audio.MediaPlayer; + import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.LinkedBlockingDeque; @@ -1016,6 +1018,8 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre void playbackSpeedChanged(float s); + void setSpeedAbilityChanged(); + void onBufferingUpdate(int percent); boolean onMediaPlayerInfo(int code); @@ -1036,6 +1040,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre ((AudioPlayer) mp) .setOnBufferingUpdateListener(audioBufferingUpdateListener); ((AudioPlayer) mp).setOnInfoListener(audioInfoListener); + ((AudioPlayer) mp).setOnSpeedAdjustmentAvailableChangedListener(audioSetSpeedAbilityListener); } else { ((VideoPlayer) mp) .setOnCompletionListener(videoCompletionListener); @@ -1050,7 +1055,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre return mp; } - private final org.antennapod.audio.MediaPlayer.OnCompletionListener audioCompletionListener = + private final MediaPlayer.OnCompletionListener audioCompletionListener = mp -> genericOnCompletion(); private final android.media.MediaPlayer.OnCompletionListener videoCompletionListener = @@ -1060,7 +1065,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre endPlayback(false); } - private final org.antennapod.audio.MediaPlayer.OnBufferingUpdateListener audioBufferingUpdateListener = + private final MediaPlayer.OnBufferingUpdateListener audioBufferingUpdateListener = (mp, percent) -> genericOnBufferingUpdate(percent); private final android.media.MediaPlayer.OnBufferingUpdateListener videoBufferingUpdateListener = @@ -1070,7 +1075,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre callback.onBufferingUpdate(percent); } - private final org.antennapod.audio.MediaPlayer.OnInfoListener audioInfoListener = + private final MediaPlayer.OnInfoListener audioInfoListener = (mp, what, extra) -> genericInfoListener(what); private final android.media.MediaPlayer.OnInfoListener videoInfoListener = @@ -1080,7 +1085,16 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre return callback.onMediaPlayerInfo(what); } - private final org.antennapod.audio.MediaPlayer.OnErrorListener audioErrorListener = + private final MediaPlayer.OnSpeedAdjustmentAvailableChangedListener + audioSetSpeedAbilityListener = new MediaPlayer.OnSpeedAdjustmentAvailableChangedListener() { + @Override + public void onSpeedAdjustmentAvailableChanged(MediaPlayer arg0, boolean speedAdjustmentAvailable) { + callback.setSpeedAbilityChanged(); + } + }; + + + private final MediaPlayer.OnErrorListener audioErrorListener = (mp, what, extra) -> { if(mp.canFallback()) { mp.fallback(); @@ -1096,7 +1110,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre return callback.onMediaPlayerError(inObj, what, extra); } - private final org.antennapod.audio.MediaPlayer.OnSeekCompleteListener audioSeekCompleteListener = + private final MediaPlayer.OnSeekCompleteListener audioSeekCompleteListener = mp -> genericSeekCompleteListener(); private final android.media.MediaPlayer.OnSeekCompleteListener videoSeekCompleteListener = diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/AudioPlayer.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/AudioPlayer.java index f0850e6df..846733882 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/AudioPlayer.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/AudioPlayer.java @@ -1,8 +1,11 @@ package de.danoeh.antennapod.core.util.playback; import android.content.Context; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; import android.util.Log; import android.view.SurfaceHolder; + import org.antennapod.audio.MediaPlayer; import de.danoeh.antennapod.core.preferences.UserPreferences; @@ -12,8 +15,17 @@ public class AudioPlayer extends MediaPlayer implements IPlayer { public AudioPlayer(Context context) { super(context); + PreferenceManager.getDefaultSharedPreferences(context) + .registerOnSharedPreferenceChangeListener(sonicListener); } + private final SharedPreferences.OnSharedPreferenceChangeListener sonicListener = + (sharedPreferences, key) -> { + if (key.equals(UserPreferences.PREF_SONIC)) { + checkMpi(); + } + }; + @Override public void setScreenOnWhilePlaying(boolean screenOn) { Log.e(TAG, "Setting screen on while playing not supported in Audio Player"); diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java index 0ad286093..1409ffe09 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java @@ -336,6 +336,8 @@ public abstract class PlaybackController { case PlaybackService.NOTIFICATION_TYPE_PLAYBACK_SPEED_CHANGE: onPlaybackSpeedChange(); break; + case PlaybackService.NOTIFICATION_TYPE_SET_SPEED_ABILITY_CHANGED: + onSetSpeedAbilityChanged(); } } @@ -362,6 +364,8 @@ public abstract class PlaybackController { public void onPlaybackSpeedChange() {} + public void onSetSpeedAbilityChanged() {} + public void onShutdownNotification() {} /** |