|
|
|
@ -38,6 +38,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; |
|
|
|
import androidx.recyclerview.widget.RecyclerView; |
|
|
|
|
|
|
|
import com.airbnb.lottie.LottieAnimationView; |
|
|
|
import com.aispeech.gourd.util.LogUtil; |
|
|
|
import com.alibaba.android.arouter.launcher.ARouter; |
|
|
|
import com.bumptech.glide.Glide; |
|
|
|
import com.bumptech.glide.request.RequestOptions; |
|
|
|
@ -155,8 +156,7 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
static final int TYPE_UPDATE_MACTH = 142;//匹配时间是否更新;
|
|
|
|
static final int TYPE_DOWNLOAD_FILE = 143;//下载文件
|
|
|
|
static final int TYPE_GET_NEXT_OTHER_IMG = 144;//下个节目的图片
|
|
|
|
static final int TYPE_STOP_VIDEO_PLAY0 = 145;//暂停播放
|
|
|
|
static final int TYPE_STOP_VIDEO_PLAY1 = 146;//暂停播放
|
|
|
|
|
|
|
|
static final int TYPE_HINT_IMG0 = 147;//隐藏额外图片
|
|
|
|
static final int TYPE_HINT_IMG1 = 148;//隐藏额外图片
|
|
|
|
static final int TYPE_HINT_IMG2 = 149;//隐藏额外图片
|
|
|
|
@ -531,23 +531,8 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
//存在视频组件
|
|
|
|
String localPath = StringUtil.strSplice(Constant.CACHE_PATH, components.getMaterials().get(0).getFileUrl()); |
|
|
|
if(videoViewNumb==0){ |
|
|
|
//第一个videoview
|
|
|
|
if(components.getMaterials().get(0).getDuration()>0){ |
|
|
|
//视频
|
|
|
|
|
|
|
|
if(components.getMaterials().get(0).getPreviewUrl()!=null && !components.getMaterials().get(0).getPreviewUrl().isEmpty()){ |
|
|
|
BitmapUtil.loadImage(downloadaddress, Constant.CACHE_PATH, components.getMaterials().get(0).getPreviewUrl(),binding.videoImg0); |
|
|
|
} |
|
|
|
|
|
|
|
}else { |
|
|
|
//图片
|
|
|
|
if(new File(localPath).exists()){ |
|
|
|
Glide.with(context).load(localPath).into(binding.videoImg0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(!isNextVideo){ |
|
|
|
Log.e("TAG: ","预览设置下个视频"); |
|
|
|
isNextVideo=true; |
|
|
|
if(components.getMaterials().get(0).getDuration()>0){ |
|
|
|
binding.videoView0.setVideoPath(localPath); |
|
|
|
@ -558,28 +543,7 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
//第二个videoview
|
|
|
|
if(components.getMaterials().get(0).getDuration()>0){ |
|
|
|
//视频
|
|
|
|
|
|
|
|
if(components.getMaterials().get(0).getPreviewUrl()!=null && !components.getMaterials().get(0).getPreviewUrl().isEmpty()){ |
|
|
|
BitmapUtil.loadImage(downloadaddress, Constant.CACHE_PATH, components.getMaterials().get(0).getPreviewUrl(),binding.videoImg1); |
|
|
|
} |
|
|
|
// String[] b = localPath.split("\\.");
|
|
|
|
// String imgUrl = b[0]+".jpg";
|
|
|
|
// if(new File(imgUrl).exists()){
|
|
|
|
// binding.videoImg1.setVisibility(View.GONE);
|
|
|
|
// Glide.with(context).load(imgUrl).into(binding.videoImg1);
|
|
|
|
// }
|
|
|
|
}else { |
|
|
|
//图片
|
|
|
|
if(new File(localPath).exists()){ |
|
|
|
Glide.with(context).load(localPath).into(binding.videoImg1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(!isNextVideo){ |
|
|
|
Log.e("TAG: ","预览设置下个视频"); |
|
|
|
isNextVideo=true; |
|
|
|
if(components.getMaterials().get(0).getDuration()>0){ |
|
|
|
binding.videoView0.setVideoPath(localPath); |
|
|
|
@ -650,20 +614,6 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case TYPE_STOP_VIDEO_PLAY0: |
|
|
|
if(binding.videoView0.isPlaying()){ |
|
|
|
binding.videoView0.pause(); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case TYPE_STOP_VIDEO_PLAY1: |
|
|
|
if(binding.videoView1.isPlaying()){ |
|
|
|
binding.videoView1.pause(); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case TYPE_HINT_IMG0: |
|
|
|
binding.otherImg0.setVisibility(View.INVISIBLE); |
|
|
|
break; |
|
|
|
@ -678,9 +628,7 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
break; |
|
|
|
|
|
|
|
case TYPE_UPDATE_MEIDA0://音频播放
|
|
|
|
|
|
|
|
updateMedia(mediaComponents0); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case TYPE_UPDATE_IMAGE0: //图片切换
|
|
|
|
@ -1549,8 +1497,6 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
handler.removeMessages(TYPE_CHANGE_IMG_SHOW14); |
|
|
|
handler.removeMessages(TYPE_CHANGE_IMG_SHOW15); |
|
|
|
handler.removeMessages(TYPE_UPDATE_TEXT4); |
|
|
|
handler.removeMessages(TYPE_STOP_VIDEO_PLAY0); |
|
|
|
handler.removeMessages(TYPE_STOP_VIDEO_PLAY1); |
|
|
|
handler.removeMessages(TYPE_REFRESH_WEBVIEW0); |
|
|
|
handler.removeMessages(TYPE_REFRESH_WEBVIEW1); |
|
|
|
handler.removeMessages(TYPE_REFRESH_WEBVIEW2); |
|
|
|
@ -1848,21 +1794,6 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
startProgram(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 关闭 |
|
|
|
* */ |
|
|
|
public void stopScreen(){ |
|
|
|
if(binding.videoImg0!=null){ |
|
|
|
binding.videoImg0.setImageBitmap(null); |
|
|
|
binding.videoImg0.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
|
|
|
|
if(binding.videoImg1!=null){ |
|
|
|
binding.videoImg1.setImageBitmap(null); |
|
|
|
binding.videoImg1.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//同屏视频
|
|
|
|
public void videoProgramByIndex(int index){ |
|
|
|
if(Constant.isMain || handler==null)return; |
|
|
|
@ -2226,7 +2157,6 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
//视频控件
|
|
|
|
addVideoView(components,videoCount); |
|
|
|
videoCount++; |
|
|
|
|
|
|
|
}else if(components.getTypeCode().equals("image")){ |
|
|
|
//图片控件
|
|
|
|
initImage(components,imageCount); |
|
|
|
@ -2749,9 +2679,7 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
RelativeLayout.LayoutParams lParams = new RelativeLayout.LayoutParams(components.getWidth(), components.getHeight()); |
|
|
|
lParams.setMargins(components.getOffsetX(), components.getOffsetY(), 0, 0); |
|
|
|
if(position==0){ |
|
|
|
|
|
|
|
isNextVideo = true; |
|
|
|
isvideoPlay0 = true; |
|
|
|
binding.videoView0.pause(); |
|
|
|
binding.videoView0.seekTo(0); |
|
|
|
binding.layoutVideo0.setX(components.getOffsetX()); |
|
|
|
@ -2763,12 +2691,11 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
binding.layoutVideo0.setVisibility(View.VISIBLE); |
|
|
|
binding.layoutVideo0.bringToFront(); |
|
|
|
handler.sendEmptyMessage(TYPE_UPDATE_VIDEO0); |
|
|
|
binding.videoImg0.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
binding.videoView0.setOnPreparedListener(new CustomerVideoView.OnPreparedListener() { |
|
|
|
@Override |
|
|
|
public void onPrepared() { |
|
|
|
videoStartPlay(binding.videoView0, binding.videoImg0, videoComponents0, isvideoPlay0); |
|
|
|
videoStartPlay(binding.videoView0, videoComponents0); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 视频播放完成时的操作
|
|
|
|
@ -2793,7 +2720,6 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
|
|
|
|
}else if(position==1){ |
|
|
|
|
|
|
|
isvideoPlay1 = true; |
|
|
|
binding.layoutVideo1.setX(components.getOffsetX()); |
|
|
|
binding.layoutVideo1.setY(components.getOffsetY()); |
|
|
|
ViewGroup.LayoutParams layoutParams = binding.layoutVideo1.getLayoutParams(); |
|
|
|
@ -2810,11 +2736,11 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
|
|
|
|
videoComponents1 = components; |
|
|
|
handler.sendEmptyMessage(TYPE_UPDATE_VIDEO1); |
|
|
|
|
|
|
|
|
|
|
|
binding.videoView1.setOnPreparedListener(new CustomerVideoView.OnPreparedListener() { |
|
|
|
@Override |
|
|
|
public void onPrepared() { |
|
|
|
videoStartPlay(binding.videoView1, binding.videoImg1, videoComponents1,isvideoPlay1); |
|
|
|
videoStartPlay(binding.videoView1, videoComponents1); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
@ -2839,39 +2765,21 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void videoStartPlay(CustomerVideoView vView, ImageView imgView, NewProgramBean.components components, Boolean isPlay){ |
|
|
|
private void videoStartPlay(CustomerVideoView vView, NewProgramBean.components components){ |
|
|
|
vView.setOnInfoListener(new CustomerVideoView.OnInfoListener() { |
|
|
|
@Override |
|
|
|
public void onInfo() { |
|
|
|
vView.clearBackground(); |
|
|
|
imgView.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//视频准备完毕,可以进行播放
|
|
|
|
if( isPlay ){ |
|
|
|
handler.removeMessages(TYPE_STOP_VIDEO_PLAY0); |
|
|
|
handler.removeMessages(TYPE_STOP_VIDEO_PLAY1); |
|
|
|
if(components.getConfig().isPlayAudio()){ |
|
|
|
vView.setVolume(15f); |
|
|
|
}else { |
|
|
|
vView.setVolume(0f); |
|
|
|
} |
|
|
|
vView.start(); |
|
|
|
if(components.getConfig().isPlayAudio()){ |
|
|
|
vView.setVolume(1.0f); |
|
|
|
}else { |
|
|
|
vView.start(); |
|
|
|
vView.setVolume(0f); |
|
|
|
//暂停播放
|
|
|
|
if(vView == binding.videoView0){ |
|
|
|
handler.removeMessages(TYPE_STOP_VIDEO_PLAY0); |
|
|
|
handler.sendEmptyMessageDelayed(TYPE_STOP_VIDEO_PLAY0,5000); |
|
|
|
}else{ |
|
|
|
handler.removeMessages(TYPE_STOP_VIDEO_PLAY1); |
|
|
|
handler.sendEmptyMessageDelayed(TYPE_STOP_VIDEO_PLAY1,5000); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
vView.start(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -2893,6 +2801,7 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
NewProgramBean.materials materials0 = videoComponents.getMaterials().get(videoPlayCount); |
|
|
|
String localPath = StringUtil.strSplice(Constant.CACHE_PATH, materials0.getFileUrl()); |
|
|
|
if (!new File(localPath).exists()) { |
|
|
|
|
|
|
|
FileUtil.downloadFile(downloadaddress + materials0.getFileUrl(), localPath); |
|
|
|
handler.sendEmptyMessageDelayed(TYPE_UPDATE_VIDE,2000); |
|
|
|
return; |
|
|
|
@ -2908,7 +2817,6 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
try { |
|
|
|
if (videoView.isPlaying()) { |
|
|
|
videoView.pause(); |
|
|
|
videoView.stopPlayback(); |
|
|
|
} |
|
|
|
new Handler(Looper.getMainLooper()).postDelayed(() -> { |
|
|
|
try { |
|
|
|
@ -2927,22 +2835,17 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> { |
|
|
|
layoutParams.height = videoComponents.getHeight(); |
|
|
|
layoutParams.width = videoComponents.getWidth(); |
|
|
|
binding.videoView0.setLayoutParams(layoutParams); |
|
|
|
binding.videoImg0.setVisibility(View.GONE); |
|
|
|
|
|
|
|
}else if(TYPE_UPDATE_VIDE==TYPE_UPDATE_VIDEO1){ |
|
|
|
ViewGroup.LayoutParams layoutParams = binding.videoView1.getLayoutParams(); |
|
|
|
layoutParams.height = videoComponents.getHeight(); |
|
|
|
layoutParams.width = videoComponents.getWidth(); |
|
|
|
binding.videoView1.setLayoutParams(layoutParams); |
|
|
|
binding.videoImg1.setVisibility(View.GONE); |
|
|
|
} |
|
|
|
|
|
|
|
handler.sendEmptyMessageDelayed(TYPE_UPDATE_VIDE,videoComponents.getConfig().getTransitionPeriod()*1000); |
|
|
|
Drawable drawable = new BitmapDrawable(localPath); |
|
|
|
videoView.setBackground(drawable); |
|
|
|
// Bitmap bitmap = BitmapFactory.decodeFile(localPath);
|
|
|
|
// WeakReference<Bitmap> weakBitmap = new WeakReference<>(bitmap);
|
|
|
|
// videoView.setBackground(new BitmapDrawable(context.getResources(), weakBitmap.get()));
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|