From f95fb5ec6054f73772dd71610aa3ddb77264155b Mon Sep 17 00:00:00 2001 From: Ankit Patial Date: Tue, 5 Jul 2016 12:17:40 +0530 Subject: [PATCH 1/2] interrupt resume play check. --- .../RNStreamingKitManagerModule.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/leblaaanc/RNStreamingKitManager/RNStreamingKitManagerModule.java b/android/src/main/java/com/leblaaanc/RNStreamingKitManager/RNStreamingKitManagerModule.java index 735a703..52813f3 100644 --- a/android/src/main/java/com/leblaaanc/RNStreamingKitManager/RNStreamingKitManagerModule.java +++ b/android/src/main/java/com/leblaaanc/RNStreamingKitManager/RNStreamingKitManagerModule.java @@ -47,9 +47,9 @@ public class RNStreamingKitManagerModule extends ReactContextBaseJavaModule impl int _seekToTime = 0; volatile boolean _isPaused; + volatile boolean _isInterrupted; volatile boolean _isBuffering; AudioManager _audioManager; -; public RNStreamingKitManagerModule(ReactApplicationContext reactContext) { super(reactContext); @@ -265,13 +265,21 @@ public void onAudioFocusChange(int focusChange) { switch (focusChange) { case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: Log.d(NAME, "==> Audio Session Interruption case AUDIOFOCUS_LOSS_TRANSIENT."); - pause(); - notifyAudioInterruption("interruptStart"); + + if (isMusicPlaying()) { + _isInterrupted = true; + pause(); + notifyAudioInterruption("interruptStart"); + } + break; case AudioManager.AUDIOFOCUS_GAIN: Log.d(NAME, "==> Audio Session Interruption case AUDIOFOCUS_GAIN."); - resume(); - notifyAudioInterruption("interruptEnd"); + if (_isInterrupted) { + _isInterrupted = false; + resume(); + notifyAudioInterruption("interruptEnd"); + } break; case AudioManager.AUDIOFOCUS_LOSS: //_audioManager.abandonAudioFocus(afChangeListener); From e82bf4b3397799a044be35dbe329b8f70e80b4fb Mon Sep 17 00:00:00 2001 From: Ankit Patial Date: Tue, 5 Jul 2016 12:20:00 +0530 Subject: [PATCH 2/2] variable name change --- .../RNStreamingKitManagerModule.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/leblaaanc/RNStreamingKitManager/RNStreamingKitManagerModule.java b/android/src/main/java/com/leblaaanc/RNStreamingKitManager/RNStreamingKitManagerModule.java index 52813f3..1992705 100644 --- a/android/src/main/java/com/leblaaanc/RNStreamingKitManager/RNStreamingKitManagerModule.java +++ b/android/src/main/java/com/leblaaanc/RNStreamingKitManager/RNStreamingKitManagerModule.java @@ -47,7 +47,7 @@ public class RNStreamingKitManagerModule extends ReactContextBaseJavaModule impl int _seekToTime = 0; volatile boolean _isPaused; - volatile boolean _isInterrupted; + volatile boolean _wasInterrupted; volatile boolean _isBuffering; AudioManager _audioManager; @@ -267,7 +267,7 @@ public void onAudioFocusChange(int focusChange) { Log.d(NAME, "==> Audio Session Interruption case AUDIOFOCUS_LOSS_TRANSIENT."); if (isMusicPlaying()) { - _isInterrupted = true; + _wasInterrupted = true; pause(); notifyAudioInterruption("interruptStart"); } @@ -275,8 +275,8 @@ public void onAudioFocusChange(int focusChange) { break; case AudioManager.AUDIOFOCUS_GAIN: Log.d(NAME, "==> Audio Session Interruption case AUDIOFOCUS_GAIN."); - if (_isInterrupted) { - _isInterrupted = false; + if (_wasInterrupted) { + _wasInterrupted = false; resume(); notifyAudioInterruption("interruptEnd"); }