|
|
|
@ -108,11 +108,11 @@ 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:5500/index.html";
|
|
|
|
//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:5500/index.html"; |
|
|
|
int time = 0; |
|
|
|
private VideoView currentVideo; |
|
|
|
private VideoView targetVideo; // 当前正在切换的目标视频
|
|
|
|
private VideoView proVideo; // 当前正在切换的目标视频
|
|
|
|
private SocketClient localSocketClient; |
|
|
|
private Map<String, Uri> videoMap = new HashMap<>(); |
|
|
|
private SoundPool soundPool; |
|
|
|
@ -215,6 +215,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
|
|
|
|
loadingbgVideo(); |
|
|
|
currentVideo = binding.bgVideo; |
|
|
|
proVideo = binding.bgVideo; |
|
|
|
loadingHelloVideo(); |
|
|
|
loadingSpeekVideo(); |
|
|
|
// loadingToVideo();
|
|
|
|
@ -409,8 +410,8 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
public void changeVideo(String type){ |
|
|
|
LoggerUtil.e("changeVideo", type); |
|
|
|
VideoView nextVideo; |
|
|
|
currentVideo.setAlpha(1.0f); |
|
|
|
currentVideo.setVisibility(View.VISIBLE); |
|
|
|
proVideo.clearAnimation(); |
|
|
|
currentVideo.clearAnimation(); |
|
|
|
switch(type.trim()){ |
|
|
|
// case "back" :
|
|
|
|
// if(currentVideo == binding.backVideo){
|
|
|
|
@ -460,86 +461,39 @@ public class WebViewActivity extends BaseActivity { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
currentVideo.clearAnimation(); |
|
|
|
nextVideo.clearAnimation(); |
|
|
|
LoggerUtil.e("切换视频", type.trim()); |
|
|
|
|
|
|
|
// 如果上一个切换还没完成,立即停止上一个目标视频
|
|
|
|
if (targetVideo != null && targetVideo != nextVideo) { |
|
|
|
try { |
|
|
|
if (targetVideo.isPlaying()) { |
|
|
|
targetVideo.pause(); |
|
|
|
targetVideo.stopPlayback(); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
LoggerUtil.e("changeVideo", "停止上一个目标视频失败", e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 记录新的目标视频
|
|
|
|
targetVideo = nextVideo; |
|
|
|
|
|
|
|
// 立即停止当前视频
|
|
|
|
VideoView farVideo = currentVideo; |
|
|
|
try { |
|
|
|
if (farVideo.isPlaying()) { |
|
|
|
farVideo.pause(); |
|
|
|
farVideo.stopPlayback(); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
LoggerUtil.e("changeVideo", "停止当前视频失败", e); |
|
|
|
} |
|
|
|
// 开始淡入动画
|
|
|
|
farVideo.animate() |
|
|
|
.alpha(0.3f) |
|
|
|
.setDuration(100) |
|
|
|
proVideo = currentVideo; |
|
|
|
proVideo.animate() |
|
|
|
.alpha(0.5f) |
|
|
|
.setDuration(240) |
|
|
|
.setListener(new AnimatorListenerAdapter() { |
|
|
|
@Override |
|
|
|
public void onAnimationEnd(Animator animation) { |
|
|
|
farVideo.setVisibility(View.GONE); |
|
|
|
farVideo.setAlpha(1f); |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void onAnimationCancel(Animator animation) { |
|
|
|
farVideo.setVisibility(View.GONE); |
|
|
|
farVideo.setAlpha(1f); |
|
|
|
super.onAnimationEnd(animation); |
|
|
|
proVideo.pause(); |
|
|
|
proVideo.setVisibility(View.GONE); |
|
|
|
proVideo.setAlpha(1.0f); |
|
|
|
} |
|
|
|
}) |
|
|
|
.setInterpolator(new AccelerateDecelerateInterpolator()) |
|
|
|
.start(); |
|
|
|
|
|
|
|
// 更新当前视频引用
|
|
|
|
currentVideo = nextVideo; |
|
|
|
|
|
|
|
// 准备新视频
|
|
|
|
nextVideo.setAlpha(0.5f); |
|
|
|
nextVideo.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
// 确保视频已经准备好
|
|
|
|
if (!nextVideo.isPlaying()) { |
|
|
|
try { |
|
|
|
nextVideo.seekTo(0); |
|
|
|
nextVideo.start(); |
|
|
|
} catch (Exception e) { |
|
|
|
LoggerUtil.e("changeVideo", "启动新视频失败", e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
currentVideo = nextVideo; |
|
|
|
// 开始淡入动画
|
|
|
|
nextVideo.animate() |
|
|
|
.alpha(1f) |
|
|
|
.setDuration(300) // 缩短动画时间,让切换更迅速
|
|
|
|
currentVideo.animate() |
|
|
|
.alpha(1.0f) |
|
|
|
.setDuration(300) |
|
|
|
.setListener(new AnimatorListenerAdapter() { |
|
|
|
@Override |
|
|
|
public void onAnimationEnd(Animator animation) { |
|
|
|
targetVideo = null; |
|
|
|
} |
|
|
|
@Override |
|
|
|
public void onAnimationCancel(Animator animation) { |
|
|
|
targetVideo = null; |
|
|
|
super.onAnimationEnd(animation); |
|
|
|
//currentVideo.seekTo(0);
|
|
|
|
currentVideo.start(); |
|
|
|
currentVideo.setAlpha(1.0f); |
|
|
|
LoggerUtil.e("切换视频:","动画播放完成"); |
|
|
|
} |
|
|
|
}) |
|
|
|
.setInterpolator(new AccelerateDecelerateInterpolator()) |
|
|
|
.start(); |
|
|
|
} |
|
|
|
|
|
|
|
|