|
|
|
@ -101,8 +101,8 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
static final int TYPE_GO_SAVESCREEN = 300;//导视通知跳转屏保
|
|
|
|
static final int TYPE_HINT_PASSWORD = 3;//隐藏密码输入框
|
|
|
|
static final int TYPE_START_SERVER = 4;//重新启动web服务
|
|
|
|
static String HtmlUrl = "http://127.0.0.1:8080/index.html";//webServer服务地址 http://192.168.1.218:5173/
|
|
|
|
//static String HtmlUrl = "http://192.168.1.196:5173/";
|
|
|
|
//static String HtmlUrl = "http://127.0.0.1:8080/index.html";//webServer服务地址 http://192.168.1.218:5173/
|
|
|
|
static String HtmlUrl = "http://192.168.1.196:5173/"; |
|
|
|
int time = 0; |
|
|
|
private VideoView currentVideo; |
|
|
|
private SocketClient localSocketClient; |
|
|
|
@ -110,7 +110,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
// 语音听写对象
|
|
|
|
private ASR mAsr; |
|
|
|
private boolean isrun = false; // 是否正在听写
|
|
|
|
private boolean isdws = false; // 是否可以修正
|
|
|
|
private String videoAfter = ""; |
|
|
|
private String language = "zh_cn"; |
|
|
|
private TTSUtil ttsUtil; |
|
|
|
|
|
|
|
@ -170,18 +170,40 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
// 设置背景透明度
|
|
|
|
binding.web.setBackgroundColor(0); |
|
|
|
binding.web.getBackground().setAlpha(0); |
|
|
|
|
|
|
|
//初始化视频列表
|
|
|
|
Uri videoUri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.bg); |
|
|
|
videoMap.put("hat_bg",videoUri); |
|
|
|
//小红帽背景
|
|
|
|
videoMap.put("hat_bg", videoUri); |
|
|
|
//小红帽打招呼
|
|
|
|
Uri videoUri1 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.hello); |
|
|
|
videoMap.put("hat_hello",videoUri1); |
|
|
|
videoMap.put("hat_hello", videoUri1); |
|
|
|
//小红帽讲话
|
|
|
|
Uri videoUri2 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.speek); |
|
|
|
videoMap.put("hat_speek",videoUri2); |
|
|
|
|
|
|
|
loadingbgVideo(true); |
|
|
|
videoMap.put("hat_speek", videoUri2); |
|
|
|
|
|
|
|
//小红帽变身贵妇
|
|
|
|
Uri videoUri3 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.hatto); |
|
|
|
videoMap.put("hat_to", videoUri3); |
|
|
|
//贵妇变身小红帽
|
|
|
|
Uri videoUri4 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.hatback); |
|
|
|
videoMap.put("hat_back", videoUri4); |
|
|
|
//贵妇背景
|
|
|
|
Uri videoUri5 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.bg1); |
|
|
|
videoMap.put("hat_bg1", videoUri5); |
|
|
|
Uri videoUri6 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.hello1); |
|
|
|
videoMap.put("hat_hello1", videoUri6); |
|
|
|
Uri videoUri7 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.speek1); |
|
|
|
videoMap.put("hat_speek1", videoUri7); |
|
|
|
|
|
|
|
loadingbgVideo(); |
|
|
|
currentVideo = binding.bgVideo; |
|
|
|
loadingHelloVideo(); |
|
|
|
loadingSpeekVideo(); |
|
|
|
loadingToVideo(); |
|
|
|
loadingBackVideo(); |
|
|
|
loadingbgVideo1(); |
|
|
|
loadingHelloVideo1(); |
|
|
|
loadingSpeekVideo1(); |
|
|
|
//设置密码
|
|
|
|
initPass(); |
|
|
|
if("sbc".equals(Constant.TTSFac)){ // 思必驰
|
|
|
|
@ -192,7 +214,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
ttsUtil.initTts(); |
|
|
|
} |
|
|
|
} |
|
|
|
private void loadingbgVideo(Boolean isplay){ |
|
|
|
private void loadingbgVideo(){ |
|
|
|
binding.bgVideo.setVideoURI(videoMap.get("hat_bg")); |
|
|
|
binding.bgVideo.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |
|
|
|
@Override |
|
|
|
@ -243,6 +265,119 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
//小红帽变 to
|
|
|
|
private void loadingToVideo(){ |
|
|
|
binding.toVideo.setVideoURI(videoMap.get("hat_to")); |
|
|
|
binding.toVideo.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |
|
|
|
@Override |
|
|
|
public void onPrepared(MediaPlayer mp) { |
|
|
|
binding.toVideo.start(); |
|
|
|
} |
|
|
|
}); |
|
|
|
binding.toVideo.setOnErrorListener(new MediaPlayer.OnErrorListener() { |
|
|
|
@Override |
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra) { |
|
|
|
LoggerUtil.e("changeVideo: ","toVideo 播放失败"); |
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
|
} |
|
|
|
}); |
|
|
|
binding.toVideo.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { |
|
|
|
@Override |
|
|
|
public void onCompletion(MediaPlayer mp) { |
|
|
|
changeVideo("bg"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
//小红帽回 back
|
|
|
|
private void loadingBackVideo(){ |
|
|
|
binding.backVideo.setVideoURI(videoMap.get("hat_back")); |
|
|
|
binding.backVideo.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |
|
|
|
@Override |
|
|
|
public void onPrepared(MediaPlayer mp) { |
|
|
|
binding.backVideo.start(); |
|
|
|
} |
|
|
|
}); |
|
|
|
binding.backVideo.setOnErrorListener(new MediaPlayer.OnErrorListener() { |
|
|
|
@Override |
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra) { |
|
|
|
LoggerUtil.e("changeVideo: ","backVideo 播放失败"); |
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
|
} |
|
|
|
}); |
|
|
|
binding.backVideo.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { |
|
|
|
@Override |
|
|
|
public void onCompletion(MediaPlayer mp) { |
|
|
|
changeVideo("bg"); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
//彩蛋背景视频
|
|
|
|
private void loadingbgVideo1(){ |
|
|
|
binding.bgVideo1.setVideoURI(videoMap.get("hat_bg1")); |
|
|
|
binding.bgVideo1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |
|
|
|
@Override |
|
|
|
public void onPrepared(MediaPlayer mp) { |
|
|
|
mp.setLooping(true); // 可选:设置循环播
|
|
|
|
binding.bgVideo1.start(); |
|
|
|
} |
|
|
|
}); |
|
|
|
binding.bgVideo1.setOnErrorListener(new MediaPlayer.OnErrorListener() { |
|
|
|
@Override |
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra) { |
|
|
|
LoggerUtil.e("changeVideo: ","backVideo 播放失败"); |
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
//彩蛋hello视频
|
|
|
|
private void loadingHelloVideo1(){ |
|
|
|
binding.helloVideo1.setVideoURI(videoMap.get("hat_hello1")); |
|
|
|
binding.helloVideo1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |
|
|
|
@Override |
|
|
|
public void onPrepared(MediaPlayer mp) { |
|
|
|
mp.setLooping(true); // 可选:设置循环播
|
|
|
|
binding.helloVideo1.start(); |
|
|
|
} |
|
|
|
}); |
|
|
|
binding.helloVideo1.setOnErrorListener(new MediaPlayer.OnErrorListener() { |
|
|
|
@Override |
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra) { |
|
|
|
LoggerUtil.e("changeVideo: ","helloVideo1 播放失败"); |
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
//彩蛋Speek视频
|
|
|
|
private void loadingSpeekVideo1(){ |
|
|
|
binding.speekVideo1.setVideoURI(videoMap.get("hat_speek1")); |
|
|
|
binding.speekVideo1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |
|
|
|
@Override |
|
|
|
public void onPrepared(MediaPlayer mp) { |
|
|
|
mp.setLooping(true); |
|
|
|
binding.speekVideo1.start(); |
|
|
|
} |
|
|
|
}); |
|
|
|
binding.speekVideo1.setOnErrorListener(new MediaPlayer.OnErrorListener() { |
|
|
|
@Override |
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra) { |
|
|
|
LoggerUtil.e("changeVideo: ","speekVideo1 播放失败"); |
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
//切换视频状态
|
|
|
|
private void changeVideoAfter(){ |
|
|
|
try{ |
|
|
|
if("".equals(videoAfter)){ //新状态正常
|
|
|
|
changeVideo("back"); |
|
|
|
}else{ //新状态彩蛋
|
|
|
|
changeVideo("to"); |
|
|
|
} |
|
|
|
}catch (Exception e){ |
|
|
|
LoggerUtil.e("ERROR: ",e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//切换视频
|
|
|
|
public void changeVideo(String type){ |
|
|
|
@ -485,6 +620,18 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
handler.removeMessages(TYPE_REFURBISH_WEBVIEW); |
|
|
|
handler.sendEmptyMessageDelayed(TYPE_REFURBISH_WEBVIEW,3000); |
|
|
|
} |
|
|
|
// h5调用android:彩蛋
|
|
|
|
@JavascriptInterface |
|
|
|
public void changeVideoState(String txt) { |
|
|
|
LoggerUtil.e(TAG,"JS调用了Android的方法:changeVideoState()"); |
|
|
|
videoAfter = txt; |
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
changeVideoAfter(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
// h5调用android:开始识别语音
|
|
|
|
@JavascriptInterface |
|
|
|
public void startRecord() { |
|
|
|
@ -814,7 +961,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
}); |
|
|
|
localSocketClient.setOnErrorListener((ex) -> { |
|
|
|
LoggerUtil.e("LocSocCliManager", "onError"); |
|
|
|
SignWayUtil.reboot(); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
//销毁当前的客户端
|
|
|
|
|