|
|
@ -1,5 +1,6 @@ |
|
|
package qianmu.container.activity.H5; |
|
|
package qianmu.container.activity.H5; |
|
|
|
|
|
|
|
|
|
|
|
import android.animation.Animator; |
|
|
import android.annotation.SuppressLint; |
|
|
import android.annotation.SuppressLint; |
|
|
import android.app.ActivityManager; |
|
|
import android.app.ActivityManager; |
|
|
import android.content.Context; |
|
|
import android.content.Context; |
|
|
@ -287,12 +288,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
binding.toVideo.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onCompletion(MediaPlayer mp) { |
|
|
|
|
|
changeVideo("bg"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
binding.toVideo.setOnCompletionListener( mp -> changeVideo("bg")); |
|
|
} |
|
|
} |
|
|
//小红帽回 back
|
|
|
//小红帽回 back
|
|
|
private void loadingBackVideo(){ |
|
|
private void loadingBackVideo(){ |
|
|
@ -310,12 +306,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
return true; // 返回true表示已处理,不会弹出系统默认提示
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
binding.backVideo.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onCompletion(MediaPlayer mp) { |
|
|
|
|
|
changeVideo("bg"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
binding.backVideo.setOnCompletionListener( mp -> changeVideo("bg")); |
|
|
} |
|
|
} |
|
|
//彩蛋背景视频
|
|
|
//彩蛋背景视频
|
|
|
private void loadingbgVideo1(){ |
|
|
private void loadingbgVideo1(){ |
|
|
@ -385,7 +376,6 @@ public class WebViewActivity extends BaseActivity { |
|
|
public void changeVideo(String type){ |
|
|
public void changeVideo(String type){ |
|
|
LoggerUtil.e("changeVideo", type); |
|
|
LoggerUtil.e("changeVideo", type); |
|
|
VideoView nextVideo; |
|
|
VideoView nextVideo; |
|
|
currentVideo.clearAnimation(); |
|
|
|
|
|
switch(type.trim()){ |
|
|
switch(type.trim()){ |
|
|
case "back" : |
|
|
case "back" : |
|
|
if(currentVideo == binding.backVideo){ |
|
|
if(currentVideo == binding.backVideo){ |
|
|
@ -429,36 +419,53 @@ public class WebViewActivity extends BaseActivity { |
|
|
default: |
|
|
default: |
|
|
nextVideo = "".equals(videoAfter) ? binding.bgVideo : binding.bgVideo1; |
|
|
nextVideo = "".equals(videoAfter) ? binding.bgVideo : binding.bgVideo1; |
|
|
} |
|
|
} |
|
|
|
|
|
currentVideo.clearAnimation(); |
|
|
|
|
|
nextVideo.clearAnimation(); |
|
|
|
|
|
|
|
|
// 新视频淡入动画
|
|
|
|
|
|
AlphaAnimation fadeIn = new AlphaAnimation(0.3f, 1f); |
|
|
|
|
|
fadeIn.setDuration(300); |
|
|
|
|
|
fadeIn.setFillAfter(true); |
|
|
|
|
|
// 旧视频淡出动画
|
|
|
|
|
|
AlphaAnimation fadeOut = new AlphaAnimation(1f, 0.5f); |
|
|
|
|
|
fadeOut.setDuration(150); |
|
|
|
|
|
fadeOut.setFillAfter(true); |
|
|
|
|
|
fadeOut.setAnimationListener(new Animation.AnimationListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationStart(Animation animation) {} |
|
|
|
|
|
|
|
|
// 旧视频淡出
|
|
|
|
|
|
currentVideo.animate() |
|
|
|
|
|
.alpha(0.5f) |
|
|
|
|
|
.setDuration(300) |
|
|
|
|
|
.setListener(new Animator.AnimatorListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationStart(Animator animation) { |
|
|
|
|
|
currentVideo.pause(); |
|
|
|
|
|
} |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationEnd(Animator animation) { |
|
|
|
|
|
currentVideo.setVisibility(View.GONE); |
|
|
|
|
|
currentVideo.setAlpha(1f); // 恢复初始状态,以备下次使用
|
|
|
|
|
|
} |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationCancel(Animator animation) {} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationEnd(Animation animation) { |
|
|
|
|
|
currentVideo.setVisibility(View.GONE); |
|
|
|
|
|
currentVideo.clearAnimation(); |
|
|
|
|
|
currentVideo = nextVideo; |
|
|
|
|
|
if (!currentVideo.isPlaying()) { |
|
|
|
|
|
currentVideo.start(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationRepeat(Animation animation) {} |
|
|
|
|
|
}); |
|
|
|
|
|
// 执行切换
|
|
|
|
|
|
currentVideo.pause(); |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationRepeat(Animator animation) {} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 新视频淡入
|
|
|
|
|
|
nextVideo.setAlpha(0.3f); // 先设置为完全透明
|
|
|
nextVideo.setVisibility(View.VISIBLE); |
|
|
nextVideo.setVisibility(View.VISIBLE); |
|
|
nextVideo.startAnimation(fadeIn); |
|
|
|
|
|
currentVideo.startAnimation(fadeOut); |
|
|
|
|
|
|
|
|
nextVideo.animate() |
|
|
|
|
|
.alpha(1f) |
|
|
|
|
|
.setDuration(500) |
|
|
|
|
|
.setListener(new Animator.AnimatorListener() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationStart(Animator animation) { |
|
|
|
|
|
if (!nextVideo.isPlaying()) { |
|
|
|
|
|
nextVideo.start(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationEnd(Animator animation) { |
|
|
|
|
|
currentVideo = nextVideo; |
|
|
|
|
|
currentVideo.start(); |
|
|
|
|
|
} |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationCancel(Animator animation) {} |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onAnimationRepeat(Animator animation) {} |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|