|
|
@@ -10,6 +10,7 @@ import android.content.pm.PackageManager;
|
|
|
import android.content.pm.ResolveInfo;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.icu.text.SimpleDateFormat;
|
|
|
+import android.media.MediaPlayer;
|
|
|
import android.net.Uri;
|
|
|
import android.os.Build;
|
|
|
import android.os.Bundle;
|
|
|
@@ -40,6 +41,7 @@ import com.just.agentweb.WebViewClient;
|
|
|
import com.qingdaofushan.home.activity.NfcActivity;
|
|
|
import com.qingdaofushan.home.event.EventData;
|
|
|
import com.qingdaofushan.home.R;
|
|
|
+import com.qingdaofushan.home.event.EventMp3;
|
|
|
import com.tencent.trtc.videocall.TrtcEvent;
|
|
|
import com.qingdaofushan.home.utils.ToastUtil;
|
|
|
|
|
|
@@ -66,6 +68,7 @@ import java.util.Locale;
|
|
|
*/
|
|
|
public class WebViewActivity extends NfcActivity {
|
|
|
|
|
|
+ private MediaPlayer mMediaPlayer = null;//媒体播放器
|
|
|
LinearLayout linearLayout;
|
|
|
protected AgentWeb mAgentWeb;
|
|
|
private String url;
|
|
|
@@ -107,6 +110,54 @@ public class WebViewActivity extends NfcActivity {
|
|
|
readNfc();
|
|
|
}
|
|
|
|
|
|
+ public void playjieting() {
|
|
|
+ mMediaPlayer = MediaPlayer.create(this, R.raw.jieting);//加载res/raw的happyis.mp3文件
|
|
|
+ mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
|
|
+ @Override
|
|
|
+ public void onCompletion(MediaPlayer mediaPlayer) {
|
|
|
+ if(mMediaPlayer!=null){
|
|
|
+ mMediaPlayer.start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mMediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onError(MediaPlayer mediaPlayer, int i, int i1) {
|
|
|
+ mediaPlayer.seekTo(0);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mMediaPlayer.start();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void playhujiao() {
|
|
|
+ mMediaPlayer = MediaPlayer.create(this, R.raw.hujiao);//加载res/raw的happyis.mp3文件
|
|
|
+ mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
|
|
+ @Override
|
|
|
+ public void onCompletion(MediaPlayer mediaPlayer) {
|
|
|
+ if(mMediaPlayer!=null){
|
|
|
+ mMediaPlayer.start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mMediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onError(MediaPlayer mediaPlayer, int i, int i1) {
|
|
|
+ mediaPlayer.seekTo(0);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mMediaPlayer.start();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void stophujiao() {
|
|
|
+ if (mMediaPlayer != null) {
|
|
|
+ mMediaPlayer.stop();
|
|
|
+ mMediaPlayer = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void readNfc() {
|
|
|
String s = null;
|
|
|
try {
|
|
|
@@ -353,6 +404,17 @@ public class WebViewActivity extends NfcActivity {
|
|
|
uploadMessageAboveL = null;
|
|
|
}
|
|
|
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
+ public void evemp3(EventMp3 eventData) {
|
|
|
+ if (eventData.getCode() == 1) {
|
|
|
+ playhujiao();
|
|
|
+ } else if (eventData.getCode() == 2) {
|
|
|
+ playjieting();
|
|
|
+ } else if (eventData.getCode() == 3) {
|
|
|
+ stophujiao();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
public void stopServiceEvent(EventData eventData) {
|
|
|
if (eventData.getCode() == 1) {
|