|
@@ -2,12 +2,23 @@ package com.wdkl.ncs.android.component.nursehome.util;
|
|
|
|
|
|
import android.content.Context;
|
|
|
import android.media.AudioManager;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Looper;
|
|
|
+import android.os.Message;
|
|
|
|
|
|
import com.wdkl.core.voip.AsyncPlayer;
|
|
|
|
|
|
public class RingPlayHelper {
|
|
|
|
|
|
private static AsyncPlayer ringPlayer;
|
|
|
+ private final static Handler handler = new Handler(Looper.getMainLooper()) {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ if (ringPlayer != null) {
|
|
|
+ ringPlayer.stop();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
public static void playRingTone(Context context, int res, boolean loop) {
|
|
|
if (ringPlayer == null) {
|
|
@@ -16,10 +27,13 @@ public class RingPlayHelper {
|
|
|
|
|
|
if (!ringPlayer.isPlay()) {
|
|
|
ringPlayer.play(context, res, loop, AudioManager.STREAM_MUSIC);
|
|
|
+ handler.removeCallbacksAndMessages(null);
|
|
|
+ handler.sendEmptyMessageDelayed(10, 30000);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static void stopRingTone() {
|
|
|
+ handler.removeCallbacksAndMessages(null);
|
|
|
if (ringPlayer != null) {
|
|
|
ringPlayer.stop();
|
|
|
}
|