From 774aadc0013e9b89d2708378877c947c10f53050 Mon Sep 17 00:00:00 2001 From: gaozl Date: Wed, 29 Apr 2026 14:18:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=8A=82=E7=9B=AE=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=A6=86=E7=9B=96=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E9=BB=98=E8=AE=A4=E6=8B=89=E4=BC=B8=E9=93=BA?= =?UTF-8?q?=E6=BB=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 5 ++- .../activity/H5/WebViewActivity.java | 1 + .../activity/program/MyPresentation.java | 15 +++++--- .../activity/program/ViewScreenSaver.java | 29 ++++++++------ .../java/qianmu/container/app/Constant.java | 4 +- .../java/qianmu/container/util/FileUtil.java | 1 + .../container/view/CustomerVideoView.java | 38 +++++++++++++++++-- 7 files changed, 69 insertions(+), 24 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a210d17..8b5b475 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,7 +12,7 @@ android { minSdkVersion 24 targetSdkVersion 30 versionCode 6 - versionName "V2.0.8.21" + versionName "V2.0.8.23" // 2.0.8.2 修改网络连接证书设置、定时开关机设置 // 2.0.8.3 获取mac修改 // V2.0.8.5 同屏优化 @@ -21,7 +21,8 @@ android { //V2.0.8.14 和义大道开机5分钟后重启应用 //V2.0.8.15 增加数字人视频模型 //V2.0.8.20 修改无SDK的mac获取和APP更新 - //V2.0.8.21 删除ai背景视频切换代码 + //V2.0.8.22 删除ai背景视频切换代码 + //V2.0.8.23 节目切换图片覆盖问题 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles 'consumer-rules.pro' diff --git a/app/src/main/java/qianmu/container/activity/H5/WebViewActivity.java b/app/src/main/java/qianmu/container/activity/H5/WebViewActivity.java index 1b52be9..7f32ae5 100644 --- a/app/src/main/java/qianmu/container/activity/H5/WebViewActivity.java +++ b/app/src/main/java/qianmu/container/activity/H5/WebViewActivity.java @@ -112,6 +112,7 @@ public class WebViewActivity extends BaseActivity { static final int TYPE_START_SERVER = 4;//重新启动web服务 static final int TYPE_SHENG_HTML_MAG = 5;//返回接口请求值给h5 static String HtmlUrl = "http://127.0.0.1:8080/index.html";//webServer服务地址 + //static String HtmlUrl = "http://192.168.0.106:5173/";//webServer服务地址 //static String HtmlUrl = "https://iot.1000my.com/api/application-unzip-path/v1/static/77b853bf-a43a-47ba-bc0c-0160229b6ca2/index.html?projectCode=project-ce-k6xi8vq_deqrszdepga&code=Sn9tXh8jMLd4GjfiVdInl#/"; int time = 0; String interfaceRequestData=""; diff --git a/app/src/main/java/qianmu/container/activity/program/MyPresentation.java b/app/src/main/java/qianmu/container/activity/program/MyPresentation.java index 60f2585..36a6edc 100644 --- a/app/src/main/java/qianmu/container/activity/program/MyPresentation.java +++ b/app/src/main/java/qianmu/container/activity/program/MyPresentation.java @@ -1714,15 +1714,20 @@ class MyPresentation extends Presentation { if( videoView2.isPlaying()){ videoView2.pause(); } - videoView3.setZOrderOnTop(false); - videoView3.setZOrderMediaOverlay(false); + //videoView3.setZOrderOnTop(false); + //videoView3.setZOrderMediaOverlay(false); videoView3.setVisibility(View.GONE); layoutVideo3.setVisibility(View.GONE); if( videoView3.isPlaying()){ videoView3.pause(); } - + if(videoView2!=null){ + videoView2.stopPlayback(); + } + if(videoView3!=null){ + videoView3.stopPlayback(); + } }catch (Exception e){ LoggerUtil.e("(双面屏)deleteView()清除视频报错",e.getMessage()); } @@ -2664,8 +2669,8 @@ class MyPresentation extends Presentation { layoutParams.width = components.getWidth(); videoView3.pause(); videoView3.seekTo(0); - videoView3.setZOrderOnTop(true); - videoView3.setZOrderMediaOverlay(true); + //videoView3.setZOrderOnTop(true); + //videoView3.setZOrderMediaOverlay(true); videoView3.setVisibility(View.VISIBLE); layoutVideo3.setVisibility(View.VISIBLE); layoutVideo3.bringToFront(); diff --git a/app/src/main/java/qianmu/container/activity/program/ViewScreenSaver.java b/app/src/main/java/qianmu/container/activity/program/ViewScreenSaver.java index afc988d..9a488c5 100644 --- a/app/src/main/java/qianmu/container/activity/program/ViewScreenSaver.java +++ b/app/src/main/java/qianmu/container/activity/program/ViewScreenSaver.java @@ -609,7 +609,7 @@ public class ViewScreenSaver extends ViewBase { case TYPE_UPDATE_VIDEO1: //视频切换 updateVideo(videoComponents1,videoPlayCount1,binding.videoView1,TYPE_UPDATE_VIDEO1); - + break; case TYPE_HINT_IMG0: @@ -1560,15 +1560,20 @@ public class ViewScreenSaver extends ViewBase { } binding.layoutVideo0.setBackground(null); - binding.videoView1.setZOrderOnTop(false); - binding.videoView1.setZOrderMediaOverlay(false); + //binding.videoView1.setZOrderOnTop(false); + //binding.videoView1.setZOrderMediaOverlay(false); binding.videoView1.setVisibility(View.GONE); binding.layoutVideo1.setVisibility(View.GONE); - + binding.layoutVideo1.setBackground(null); if( binding.videoView1.isPlaying()){ binding.videoView1.pause(); } - + if(binding.videoView0!=null){ + binding.videoView0.stopPlayback(); + } + if(binding.videoView1!=null){ + binding.videoView1.stopPlayback(); + } }catch (Exception e){ LoggerUtil.e("deleteView()清除视频报错",e.getMessage()); } @@ -2105,7 +2110,7 @@ public class ViewScreenSaver extends ViewBase { public void createView( NewProgramBean.schedule schedule ,int position){ nextimg= position ; NewProgramBean.programs programme = schedule.getPrograms().get(position); - + //获取节目时长 String[] split = programme.getDuration().split(":"); int duration = Integer.parseInt(split[0])*3600*1000+Integer.parseInt(split[1])*60*1000+Integer.parseInt(split[2])*1000; //只有一个的时候不会从新创建 @@ -2250,7 +2255,6 @@ public class ViewScreenSaver extends ViewBase { //获取下个节目的图片 handler.sendEmptyMessageDelayed(TYPE_GET_NEXT_OTHER_IMG,5000); - } @@ -2685,6 +2689,7 @@ public class ViewScreenSaver extends ViewBase { 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()); @@ -2725,7 +2730,7 @@ public class ViewScreenSaver extends ViewBase { }); }else if(position==1){ - + isvideoPlay1= true; binding.layoutVideo1.setX(components.getOffsetX()); binding.layoutVideo1.setY(components.getOffsetY()); ViewGroup.LayoutParams layoutParams = binding.layoutVideo1.getLayoutParams(); @@ -2733,11 +2738,12 @@ public class ViewScreenSaver extends ViewBase { layoutParams.width = components.getWidth(); binding.videoView1.pause(); binding.videoView1.seekTo(0); - binding.videoView1.setZOrderOnTop(true); - binding.videoView1.setZOrderMediaOverlay(true); binding.layoutVideo1.setVisibility(View.VISIBLE); binding.layoutVideo1.bringToFront(); - + //binding.videoView1.setZOrderOnTop(true); + //binding.videoView1.setZOrderMediaOverlay(true); + binding.videoView1.setVisibility(View.VISIBLE); + binding.videoImg1.setVisibility(View.VISIBLE); videoComponents1 = components; @@ -2780,6 +2786,7 @@ public class ViewScreenSaver extends ViewBase { }); //视频准备完毕,可以进行播放 + Log.e("TAG: ", String.valueOf(isvideoPlay0)+" "+String.valueOf(isvideoPlay1)); if(components.getConfig().isPlayAudio()){ vView.setVolume(1.0f); }else { diff --git a/app/src/main/java/qianmu/container/app/Constant.java b/app/src/main/java/qianmu/container/app/Constant.java index 9054e23..ca91b73 100644 --- a/app/src/main/java/qianmu/container/app/Constant.java +++ b/app/src/main/java/qianmu/container/app/Constant.java @@ -22,8 +22,8 @@ public class Constant { public static String screenType = "HDMI"; // 欣威视通3399设备为假关机 HDMI连接:可以用来判断是否为关机状态 LVDS连接:只能用定时关机时间来判断 public static String mqttState = ""; // 屏幕连接方式 public static String TTSHome="sbc"; // sbc-思必驰 kdxf-科大讯飞 (有语音的项目需要配置) - public static String androidBoardType = ""; //设备板子型号 无固定版 - // public static String androidBoardType = "ys"; // 设备板子型号 ys(亿晟) 北京颐堤港定制touch + // public static String androidBoardType = ""; //设备板子型号 无固定版 + public static String androidBoardType = "ys"; // 设备板子型号 ys(亿晟) 北京颐堤港定制touch // public static String androidBoardType = "xwst"; //设备板子型号 xwst(欣威视通3399) // public static String androidBoardType = "xwst2"; //设备板子型号 xwst2(欣威视通3588、T982、3576) // public static String androidBoardType = "zc"; //设备板子型号 zc(卓策主板——王府井喜悦、杨浦中心医院) diff --git a/app/src/main/java/qianmu/container/util/FileUtil.java b/app/src/main/java/qianmu/container/util/FileUtil.java index 71cae97..a68e3a1 100644 --- a/app/src/main/java/qianmu/container/util/FileUtil.java +++ b/app/src/main/java/qianmu/container/util/FileUtil.java @@ -18,6 +18,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; diff --git a/app/src/main/java/qianmu/container/view/CustomerVideoView.java b/app/src/main/java/qianmu/container/view/CustomerVideoView.java index a668b14..8f642c6 100644 --- a/app/src/main/java/qianmu/container/view/CustomerVideoView.java +++ b/app/src/main/java/qianmu/container/view/CustomerVideoView.java @@ -21,6 +21,7 @@ import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; +import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.StyledPlayerView; public class CustomerVideoView extends FrameLayout { @@ -67,7 +68,8 @@ public class CustomerVideoView extends FrameLayout { playerView.setShutterBackgroundColor(Color.TRANSPARENT); playerView.setUseArtwork(false); playerView.setDefaultArtwork(null); - + // 增加拉伸铺满 + playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL); replaceSurfaceWithTextureView(); } @@ -103,13 +105,21 @@ public class CustomerVideoView extends FrameLayout { } private void initializePlayer() { + // 创建 ExoPlayer 实例 player = new SimpleExoPlayer.Builder(getContext()) .setTrackSelector(new DefaultTrackSelector(getContext())) .build(); player.setPlayWhenReady(false); + // 设置播放器到 PlayerView playerView.setPlayer(player); setupPlayerListeners(); + // 拉伸铺满 + playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL); + // 默认设置(可以根据需要调整) playerView.setUseController(false); + // 默认设置 Surface 在底部 + // setZOrderOnTop(false); + //setZOrderMediaOverlay(false); } private void setupPlayerListeners() { @@ -192,9 +202,6 @@ public class CustomerVideoView extends FrameLayout { playerView.setVisibility(INVISIBLE); } - public void setZOrderOnTop(boolean onTop) {} - public void setZOrderMediaOverlay(boolean isMediaOverlay) {} - @Override public void setVisibility(int visibility) { super.setVisibility(visibility); @@ -211,6 +218,29 @@ public class CustomerVideoView extends FrameLayout { } } + // 2. setZOrderOnTop - 设置 Surface 是否在最顶层 + public void setZOrderOnTop(boolean onTop) { + if (playerView != null) { + // 获取 PlayerView 内部的 SurfaceView + View videoSurfaceView = playerView.getVideoSurfaceView(); + if (videoSurfaceView instanceof SurfaceView) { + SurfaceView surfaceView = (SurfaceView) videoSurfaceView; + surfaceView.setZOrderOnTop(onTop); + } + } + } + + // 3. setZOrderMediaOverlay - 设置 Surface 作为媒体叠加层 + public void setZOrderMediaOverlay(boolean isMediaOverlay) { + if (playerView != null) { + View videoSurfaceView = playerView.getVideoSurfaceView(); + if (videoSurfaceView instanceof SurfaceView) { + SurfaceView surfaceView = (SurfaceView) videoSurfaceView; + surfaceView.setZOrderMediaOverlay(isMediaOverlay); + } + } + } + public void start() { if (player != null) player.play(); } public void pause() { if (player != null) player.pause(); } public void stopPlayback() { if (player != null) player.stop(); }