|
|
@ -94,6 +94,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
private String oldString=""; |
|
|
private String oldString=""; |
|
|
private Map<String, Uri> videoMap = new HashMap<>(); |
|
|
private Map<String, Uri> videoMap = new HashMap<>(); |
|
|
private String videoAfter=""; |
|
|
private String videoAfter=""; |
|
|
|
|
|
private int indexVideo = 1; |
|
|
|
|
|
|
|
|
Handler handler = new Handler() { |
|
|
Handler handler = new Handler() { |
|
|
@SuppressLint("HandlerLeak") |
|
|
@SuppressLint("HandlerLeak") |
|
|
@ -176,6 +177,20 @@ public class WebViewActivity extends BaseActivity { |
|
|
Uri videoUri7 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.speek1); |
|
|
Uri videoUri7 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.speek1); |
|
|
videoMap.put("hat_speek1", videoUri7); |
|
|
videoMap.put("hat_speek1", videoUri7); |
|
|
|
|
|
|
|
|
|
|
|
//小红帽变身贵妇
|
|
|
|
|
|
Uri videoUri8 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.hatto2); |
|
|
|
|
|
videoMap.put("hat_to2", videoUri8); |
|
|
|
|
|
//贵妇变身小红帽
|
|
|
|
|
|
Uri videoUri9 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.hatback2); |
|
|
|
|
|
videoMap.put("hat_back2", videoUri9); |
|
|
|
|
|
//贵妇背景
|
|
|
|
|
|
Uri videoUri10 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.bg2); |
|
|
|
|
|
videoMap.put("hat_bg2", videoUri10); |
|
|
|
|
|
Uri videoUri11 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.hello2); |
|
|
|
|
|
videoMap.put("hat_hello2", videoUri11); |
|
|
|
|
|
Uri videoUri12 = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.speek2); |
|
|
|
|
|
videoMap.put("hat_speek2", videoUri12); |
|
|
|
|
|
|
|
|
soundPool = new SoundPool.Builder() |
|
|
soundPool = new SoundPool.Builder() |
|
|
.setMaxStreams(2) |
|
|
.setMaxStreams(2) |
|
|
.build(); |
|
|
.build(); |
|
|
@ -189,6 +204,13 @@ public class WebViewActivity extends BaseActivity { |
|
|
loadingbgVideo1(); |
|
|
loadingbgVideo1(); |
|
|
loadingHelloVideo1(); |
|
|
loadingHelloVideo1(); |
|
|
loadingSpeekVideo1(); |
|
|
loadingSpeekVideo1(); |
|
|
|
|
|
|
|
|
|
|
|
loadingToVideo2(); |
|
|
|
|
|
loadingBackVideo2(); |
|
|
|
|
|
loadingbgVideo2(); |
|
|
|
|
|
loadingHelloVideo2(); |
|
|
|
|
|
loadingSpeekVideo2(); |
|
|
|
|
|
|
|
|
//设置密码
|
|
|
//设置密码
|
|
|
initPass(); |
|
|
initPass(); |
|
|
initASR(); |
|
|
initASR(); |
|
|
@ -357,14 +379,119 @@ public class WebViewActivity extends BaseActivity { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
/////////////////////
|
|
|
|
|
|
//小红帽变 to
|
|
|
|
|
|
private void loadingToVideo2(){ |
|
|
|
|
|
binding.toVideo2.setVideoURI(videoMap.get("hat_to2")); |
|
|
|
|
|
binding.toVideo2.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onPrepared(MediaPlayer mp) { |
|
|
|
|
|
binding.toVideo2.start(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
binding.toVideo2.setOnErrorListener(new MediaPlayer.OnErrorListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra) { |
|
|
|
|
|
LoggerUtil.e("changeVideo: ","toVideo 播放失败"); |
|
|
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
binding.toVideo2.setOnCompletionListener( mp -> changeVideo("bg")); |
|
|
|
|
|
} |
|
|
|
|
|
//小红帽回 back
|
|
|
|
|
|
private void loadingBackVideo2(){ |
|
|
|
|
|
binding.backVideo2.setVideoURI(videoMap.get("hat_back2")); |
|
|
|
|
|
binding.backVideo2.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onPrepared(MediaPlayer mp) { |
|
|
|
|
|
binding.backVideo2.start(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
binding.backVideo2.setOnErrorListener(new MediaPlayer.OnErrorListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra) { |
|
|
|
|
|
LoggerUtil.e("changeVideo: ","backVideo2 播放失败"); |
|
|
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
binding.backVideo2.setOnCompletionListener( mp -> { |
|
|
|
|
|
changeVideo("bg"); |
|
|
|
|
|
stopMusic(); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
//彩蛋背景视频
|
|
|
|
|
|
private void loadingbgVideo2(){ |
|
|
|
|
|
binding.bgVideo2.setVideoURI(videoMap.get("hat_bg2")); |
|
|
|
|
|
binding.bgVideo2.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onPrepared(MediaPlayer mp) { |
|
|
|
|
|
mp.setLooping(true); // 可选:设置循环播
|
|
|
|
|
|
binding.bgVideo2.start(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
binding.bgVideo2.setOnErrorListener(new MediaPlayer.OnErrorListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra) { |
|
|
|
|
|
LoggerUtil.e("changeVideo: ","bgVideo2 播放失败"); |
|
|
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
//彩蛋hello视频
|
|
|
|
|
|
private void loadingHelloVideo2(){ |
|
|
|
|
|
binding.helloVideo2.setVideoURI(videoMap.get("hat_hello2")); |
|
|
|
|
|
binding.helloVideo2.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onPrepared(MediaPlayer mp) { |
|
|
|
|
|
mp.setLooping(true); // 可选:设置循环播
|
|
|
|
|
|
binding.helloVideo2.start(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
binding.helloVideo2.setOnErrorListener(new MediaPlayer.OnErrorListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra) { |
|
|
|
|
|
LoggerUtil.e("changeVideo: ","helloVideo2 播放失败"); |
|
|
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
//彩蛋Speek视频
|
|
|
|
|
|
private void loadingSpeekVideo2(){ |
|
|
|
|
|
binding.speekVideo2.setVideoURI(videoMap.get("hat_speek2")); |
|
|
|
|
|
binding.speekVideo2.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onPrepared(MediaPlayer mp) { |
|
|
|
|
|
mp.setLooping(true); |
|
|
|
|
|
binding.speekVideo2.start(); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
binding.speekVideo2.setOnErrorListener(new MediaPlayer.OnErrorListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean onError(MediaPlayer mp, int what, int extra) { |
|
|
|
|
|
LoggerUtil.e("changeVideo: ","speekVideo2 播放失败"); |
|
|
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//切换视频状态
|
|
|
//切换视频状态
|
|
|
private void changeVideoAfter(){ |
|
|
private void changeVideoAfter(){ |
|
|
if("".equals(videoAfter)){ //新状态正常
|
|
|
if("".equals(videoAfter)){ //新状态正常
|
|
|
changeVideo("back"); |
|
|
|
|
|
|
|
|
if(indexVideo ==1){ |
|
|
|
|
|
indexVideo = 2; |
|
|
|
|
|
changeVideo("back"); |
|
|
|
|
|
}else{ |
|
|
|
|
|
indexVideo = 1; |
|
|
|
|
|
changeVideo("back2"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
}else{ //新状态彩蛋
|
|
|
}else{ //新状态彩蛋
|
|
|
changeVideo("to"); |
|
|
|
|
|
playMusic(); |
|
|
|
|
|
|
|
|
if(indexVideo ==1){ |
|
|
|
|
|
changeVideo("to"); |
|
|
|
|
|
playMusic(); |
|
|
|
|
|
}else{ |
|
|
|
|
|
changeVideo("to2"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -385,6 +512,18 @@ public class WebViewActivity extends BaseActivity { |
|
|
} |
|
|
} |
|
|
nextVideo = binding.toVideo; |
|
|
nextVideo = binding.toVideo; |
|
|
break; |
|
|
break; |
|
|
|
|
|
case "back2" : |
|
|
|
|
|
if(currentVideo == binding.backVideo2){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
nextVideo = binding.backVideo2; |
|
|
|
|
|
break; |
|
|
|
|
|
case "to2" : |
|
|
|
|
|
if(currentVideo == binding.toVideo2){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
nextVideo = binding.toVideo2; |
|
|
|
|
|
break; |
|
|
case "bg" : |
|
|
case "bg" : |
|
|
if(currentVideo == binding.bgVideo && "".equals(videoAfter)){ |
|
|
if(currentVideo == binding.bgVideo && "".equals(videoAfter)){ |
|
|
return; |
|
|
return; |
|
|
@ -392,7 +531,10 @@ public class WebViewActivity extends BaseActivity { |
|
|
if(currentVideo == binding.bgVideo1 && "1".equals(videoAfter)){ |
|
|
if(currentVideo == binding.bgVideo1 && "1".equals(videoAfter)){ |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
nextVideo = "".equals(videoAfter) ? binding.bgVideo : binding.bgVideo1; |
|
|
|
|
|
|
|
|
if(currentVideo == binding.bgVideo2 && "1".equals(videoAfter) && indexVideo==2){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
nextVideo = "".equals(videoAfter) ? binding.bgVideo : (indexVideo==1? binding.bgVideo1: binding.bgVideo2); |
|
|
break; |
|
|
break; |
|
|
case "answer" : |
|
|
case "answer" : |
|
|
if(currentVideo == binding.speekVideo && "".equals(videoAfter)){ |
|
|
if(currentVideo == binding.speekVideo && "".equals(videoAfter)){ |
|
|
@ -401,7 +543,10 @@ public class WebViewActivity extends BaseActivity { |
|
|
if(currentVideo == binding.speekVideo1 && "1".equals(videoAfter)){ |
|
|
if(currentVideo == binding.speekVideo1 && "1".equals(videoAfter)){ |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
nextVideo = "".equals(videoAfter) ? binding.speekVideo : binding.speekVideo1; |
|
|
|
|
|
|
|
|
if(currentVideo == binding.speekVideo2 && "1".equals(videoAfter) && indexVideo==2){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
nextVideo = "".equals(videoAfter) ? binding.speekVideo : (indexVideo==1? binding.speekVideo1: binding.speekVideo2); |
|
|
break; |
|
|
break; |
|
|
case "hello" : |
|
|
case "hello" : |
|
|
if(currentVideo == binding.helloVideo && "".equals(videoAfter)){ |
|
|
if(currentVideo == binding.helloVideo && "".equals(videoAfter)){ |
|
|
@ -410,10 +555,13 @@ public class WebViewActivity extends BaseActivity { |
|
|
if(currentVideo == binding.helloVideo1 && "1".equals(videoAfter)){ |
|
|
if(currentVideo == binding.helloVideo1 && "1".equals(videoAfter)){ |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
nextVideo = "".equals(videoAfter) ? binding.helloVideo : binding.helloVideo1; |
|
|
|
|
|
|
|
|
if(currentVideo == binding.helloVideo2 && "1".equals(videoAfter) && indexVideo==2){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
nextVideo = "".equals(videoAfter) ? binding.helloVideo : (indexVideo==1? binding.helloVideo1: binding.helloVideo2); |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
nextVideo = "".equals(videoAfter) ? binding.bgVideo : binding.bgVideo1; |
|
|
|
|
|
|
|
|
nextVideo = "".equals(videoAfter) ? binding.bgVideo : (indexVideo==1? binding.bgVideo1: binding.bgVideo2); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
currentVideo.clearAnimation(); |
|
|
currentVideo.clearAnimation(); |
|
|
|