|
|
|
@ -158,29 +158,11 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
Uri videoUri2 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.speek); |
|
|
|
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)){ // 思必驰
|
|
|
|
@ -240,119 +222,6 @@ 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){ |
|
|
|
@ -620,18 +489,7 @@ 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() { |
|
|
|
@ -741,7 +599,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//-------- 科大讯飞
|
|
|
|
//--------
|
|
|
|
private void initASR(){ |
|
|
|
if(mEngine == null){ |
|
|
|
AICloudASRConfig config = new AICloudASRConfig(); |
|
|
|
@ -754,7 +612,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
aiCloudASRIntent.setResourceType("aihome"); |
|
|
|
aiCloudASRIntent.setEnableNumberConvert(true);//设置启用识别结果汉字数字转阿拉伯数字功能
|
|
|
|
aiCloudASRIntent.setWaitingTimeout(30000); //设置等待识别结果超时时长,默认5000ms
|
|
|
|
aiCloudASRIntent.setNoSpeechTimeOut(2000); |
|
|
|
aiCloudASRIntent.setNoSpeechTimeOut(10000); |
|
|
|
aiCloudASRIntent.setPauseTime(2000); |
|
|
|
mEngine.init(config, new AIASRListenerImpl()); |
|
|
|
} |
|
|
|
|