From d70f0f1216065790f463cc73a791a71de1a5ff1c Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Fri, 23 Oct 2015 17:00:51 -0700 Subject: [PATCH] Stop audio when leaving conversation. Fixes #4290 // FREEBIE --- src/org/thoughtcrime/securesms/ConversationActivity.java | 2 ++ src/org/thoughtcrime/securesms/audio/AudioSlidePlayer.java | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index f61e477e18..663f2cdfa0 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -61,6 +61,7 @@ import com.google.protobuf.ByteString; import org.thoughtcrime.redphone.RedPhone; import org.thoughtcrime.redphone.RedPhoneService; import org.thoughtcrime.securesms.TransportOptions.OnTransportChangedListener; +import org.thoughtcrime.securesms.audio.AudioSlidePlayer; import org.thoughtcrime.securesms.color.MaterialColor; import org.thoughtcrime.securesms.components.AnimatingToggle; import org.thoughtcrime.securesms.components.ComposeText; @@ -280,6 +281,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity MessageNotifier.setVisibleThread(-1L); if (isFinishing()) overridePendingTransition(R.anim.fade_scale_in, R.anim.slide_to_right); quickAttachmentDrawer.onPause(); + AudioSlidePlayer.stopAll(); } @Override diff --git a/src/org/thoughtcrime/securesms/audio/AudioSlidePlayer.java b/src/org/thoughtcrime/securesms/audio/AudioSlidePlayer.java index 416166c145..9e2da7d8fa 100644 --- a/src/org/thoughtcrime/securesms/audio/AudioSlidePlayer.java +++ b/src/org/thoughtcrime/securesms/audio/AudioSlidePlayer.java @@ -133,6 +133,12 @@ public class AudioSlidePlayer { this.audioAttachmentServer = null; } + public synchronized static void stopAll() { + if (playing.isPresent()) { + playing.get().stop(); + } + } + public void setListener(@NonNull Listener listener) { this.listener = new WeakReference<>(listener);