[Android] Phone Call : modify and move incoming call behaviour
Alexandre Perraud
git at videolan.org
Wed Sep 17 15:45:39 CEST 2014
vlc-ports/android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Thu Sep 11 19:40:20 2014 +0200| [6712eab3a9216fdd677b2ac262a874518ce7aa16] | committer: Jean-Baptiste Kempf
Phone Call : modify and move incoming call behaviour
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=6712eab3a9216fdd677b2ac262a874518ce7aa16
---
vlc-android/src/org/videolan/vlc/PhoneStateReceiver.java | 7 ++-----
vlc-android/src/org/videolan/vlc/VLCApplication.java | 1 +
vlc-android/src/org/videolan/vlc/audio/AudioService.java | 9 +++++++++
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/PhoneStateReceiver.java b/vlc-android/src/org/videolan/vlc/PhoneStateReceiver.java
index 4d2a239..b95a0a8 100644
--- a/vlc-android/src/org/videolan/vlc/PhoneStateReceiver.java
+++ b/vlc-android/src/org/videolan/vlc/PhoneStateReceiver.java
@@ -20,8 +20,6 @@
package org.videolan.vlc;
-import org.videolan.libvlc.LibVLC;
-
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -35,10 +33,9 @@ public class PhoneStateReceiver extends BroadcastReceiver {
if (state.equals(TelephonyManager.EXTRA_STATE_RINGING) ||
state.equals(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
+ Intent newIntent = new Intent(VLCApplication.INCOMING_CALL_INTENT);
+ VLCApplication.getAppContext().sendBroadcast(newIntent);
- LibVLC libVLC = LibVLC.getExistingInstance();
- if (libVLC != null && libVLC.isPlaying())
- libVLC.pause();
}
}
diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index 3c0cfd0..fc3aca3 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -37,6 +37,7 @@ public class VLCApplication extends Application {
private static VLCApplication instance;
public final static String SLEEP_INTENT = "org.videolan.vlc.SleepIntent";
+ public final static String INCOMING_CALL_INTENT = "org.videolan.vlc.IncomingCallIntent";
@Override
public void onCreate() {
diff --git a/vlc-android/src/org/videolan/vlc/audio/AudioService.java b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
index 4ae263a..cb2c313 100644
--- a/vlc-android/src/org/videolan/vlc/audio/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/audio/AudioService.java
@@ -185,6 +185,7 @@ public class AudioService extends Service {
filter.addAction(Intent.ACTION_HEADSET_PLUG);
filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
filter.addAction(VLCApplication.SLEEP_INTENT);
+ filter.addAction(VLCApplication.INCOMING_CALL_INTENT);
registerReceiver(serviceReceiver, filter);
final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
@@ -337,6 +338,14 @@ public class AudioService extends Service {
return;
}
+ /*
+ * Incoming Call : Pause if VLC is playing audio or video.
+ */
+ if (action.equalsIgnoreCase(VLCApplication.INCOMING_CALL_INTENT)) {
+ if (mLibVLC.isPlaying())
+ pause();
+ }
+
// skip all headsets events if there is a call
TelephonyManager telManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (telManager != null && telManager.getCallState() != TelephonyManager.CALL_STATE_IDLE)
More information about the Android
mailing list