This commit is contained in:
2022-07-02 22:31:46 +02:00
parent 37ed83810a
commit 0d82e3650c

View File

@@ -238,8 +238,7 @@ public class MediaPlayerService extends Service implements MediaPlayer.OnComplet
@Override
public void onCallStateChanged(int state, String incomingNumber) {
switch (state) {
//if at least one call exists or the phone is ringing
//pause the MediaPlayer
//A la sonnerie suspendre la lecture
case TelephonyManager.CALL_STATE_OFFHOOK:
case TelephonyManager.CALL_STATE_RINGING:
if (mediaPlayer != null) {
@@ -248,7 +247,7 @@ public class MediaPlayerService extends Service implements MediaPlayer.OnComplet
}
break;
case TelephonyManager.CALL_STATE_IDLE:
// Phone idle. Start playing.
// Fin de communication, reprendre lecture
if (mediaPlayer != null) {
if (ongoingCall) {
ongoingCall = false;
@@ -259,8 +258,7 @@ public class MediaPlayerService extends Service implements MediaPlayer.OnComplet
}
}
};
// Register the listener with the telephony manager
// Listen for changes to the device call state.
//Surveillance état tel
telephonyManager.listen(phoneStateListener,
PhoneStateListener.LISTEN_CALL_STATE);
}