Browse Source

fix: 节目切换图片覆盖问题,视频默认拉伸铺满

master
高志龙 1 month ago
parent
commit
774aadc001
  1. 5
      app/build.gradle
  2. 1
      app/src/main/java/qianmu/container/activity/H5/WebViewActivity.java
  3. 15
      app/src/main/java/qianmu/container/activity/program/MyPresentation.java
  4. 29
      app/src/main/java/qianmu/container/activity/program/ViewScreenSaver.java
  5. 4
      app/src/main/java/qianmu/container/app/Constant.java
  6. 1
      app/src/main/java/qianmu/container/util/FileUtil.java
  7. 38
      app/src/main/java/qianmu/container/view/CustomerVideoView.java

5
app/build.gradle

@ -12,7 +12,7 @@ android {
minSdkVersion 24 minSdkVersion 24
targetSdkVersion 30 targetSdkVersion 30
versionCode 6 versionCode 6
versionName "V2.0.8.21"
versionName "V2.0.8.23"
// 2.0.8.2 // 2.0.8.2
// 2.0.8.3 mac修改 // 2.0.8.3 mac修改
// V2.0.8.5 // V2.0.8.5
@ -21,7 +21,8 @@ android {
//V2.0.8.14 5 //V2.0.8.14 5
//V2.0.8.15 //V2.0.8.15
//V2.0.8.20 SDK的mac获取和APP更新 //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" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro' consumerProguardFiles 'consumer-rules.pro'

1
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_START_SERVER = 4;//重新启动web服务
static final int TYPE_SHENG_HTML_MAG = 5;//返回接口请求值给h5 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://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#/"; //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; int time = 0;
String interfaceRequestData=""; String interfaceRequestData="";

15
app/src/main/java/qianmu/container/activity/program/MyPresentation.java

@ -1714,15 +1714,20 @@ class MyPresentation extends Presentation {
if( videoView2.isPlaying()){ if( videoView2.isPlaying()){
videoView2.pause(); videoView2.pause();
} }
videoView3.setZOrderOnTop(false);
videoView3.setZOrderMediaOverlay(false);
//videoView3.setZOrderOnTop(false);
//videoView3.setZOrderMediaOverlay(false);
videoView3.setVisibility(View.GONE); videoView3.setVisibility(View.GONE);
layoutVideo3.setVisibility(View.GONE); layoutVideo3.setVisibility(View.GONE);
if( videoView3.isPlaying()){ if( videoView3.isPlaying()){
videoView3.pause(); videoView3.pause();
} }
if(videoView2!=null){
videoView2.stopPlayback();
}
if(videoView3!=null){
videoView3.stopPlayback();
}
}catch (Exception e){ }catch (Exception e){
LoggerUtil.e("(双面屏)deleteView()清除视频报错",e.getMessage()); LoggerUtil.e("(双面屏)deleteView()清除视频报错",e.getMessage());
} }
@ -2664,8 +2669,8 @@ class MyPresentation extends Presentation {
layoutParams.width = components.getWidth(); layoutParams.width = components.getWidth();
videoView3.pause(); videoView3.pause();
videoView3.seekTo(0); videoView3.seekTo(0);
videoView3.setZOrderOnTop(true);
videoView3.setZOrderMediaOverlay(true);
//videoView3.setZOrderOnTop(true);
//videoView3.setZOrderMediaOverlay(true);
videoView3.setVisibility(View.VISIBLE); videoView3.setVisibility(View.VISIBLE);
layoutVideo3.setVisibility(View.VISIBLE); layoutVideo3.setVisibility(View.VISIBLE);
layoutVideo3.bringToFront(); layoutVideo3.bringToFront();

29
app/src/main/java/qianmu/container/activity/program/ViewScreenSaver.java

@ -609,7 +609,7 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> {
case TYPE_UPDATE_VIDEO1: //视频切换 case TYPE_UPDATE_VIDEO1: //视频切换
updateVideo(videoComponents1,videoPlayCount1,binding.videoView1,TYPE_UPDATE_VIDEO1); updateVideo(videoComponents1,videoPlayCount1,binding.videoView1,TYPE_UPDATE_VIDEO1);
break; break;
case TYPE_HINT_IMG0: case TYPE_HINT_IMG0:
@ -1560,15 +1560,20 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> {
} }
binding.layoutVideo0.setBackground(null); 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.videoView1.setVisibility(View.GONE);
binding.layoutVideo1.setVisibility(View.GONE); binding.layoutVideo1.setVisibility(View.GONE);
binding.layoutVideo1.setBackground(null);
if( binding.videoView1.isPlaying()){ if( binding.videoView1.isPlaying()){
binding.videoView1.pause(); binding.videoView1.pause();
} }
if(binding.videoView0!=null){
binding.videoView0.stopPlayback();
}
if(binding.videoView1!=null){
binding.videoView1.stopPlayback();
}
}catch (Exception e){ }catch (Exception e){
LoggerUtil.e("deleteView()清除视频报错",e.getMessage()); LoggerUtil.e("deleteView()清除视频报错",e.getMessage());
} }
@ -2105,7 +2110,7 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> {
public void createView( NewProgramBean.schedule schedule ,int position){ public void createView( NewProgramBean.schedule schedule ,int position){
nextimg= position ; nextimg= position ;
NewProgramBean.programs programme = schedule.getPrograms().get(position); NewProgramBean.programs programme = schedule.getPrograms().get(position);
//获取节目时长
String[] split = programme.getDuration().split(":"); String[] split = programme.getDuration().split(":");
int duration = Integer.parseInt(split[0])*3600*1000+Integer.parseInt(split[1])*60*1000+Integer.parseInt(split[2])*1000; 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<ViewScreenSaverBinding> {
//获取下个节目的图片 //获取下个节目的图片
handler.sendEmptyMessageDelayed(TYPE_GET_NEXT_OTHER_IMG,5000); handler.sendEmptyMessageDelayed(TYPE_GET_NEXT_OTHER_IMG,5000);
} }
@ -2685,6 +2689,7 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> {
lParams.setMargins(components.getOffsetX(), components.getOffsetY(), 0, 0); lParams.setMargins(components.getOffsetX(), components.getOffsetY(), 0, 0);
if(position==0){ if(position==0){
isNextVideo = true; isNextVideo = true;
isvideoPlay0 = true;
binding.videoView0.pause(); binding.videoView0.pause();
binding.videoView0.seekTo(0); binding.videoView0.seekTo(0);
binding.layoutVideo0.setX(components.getOffsetX()); binding.layoutVideo0.setX(components.getOffsetX());
@ -2725,7 +2730,7 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> {
}); });
}else if(position==1){ }else if(position==1){
isvideoPlay1= true;
binding.layoutVideo1.setX(components.getOffsetX()); binding.layoutVideo1.setX(components.getOffsetX());
binding.layoutVideo1.setY(components.getOffsetY()); binding.layoutVideo1.setY(components.getOffsetY());
ViewGroup.LayoutParams layoutParams = binding.layoutVideo1.getLayoutParams(); ViewGroup.LayoutParams layoutParams = binding.layoutVideo1.getLayoutParams();
@ -2733,11 +2738,12 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> {
layoutParams.width = components.getWidth(); layoutParams.width = components.getWidth();
binding.videoView1.pause(); binding.videoView1.pause();
binding.videoView1.seekTo(0); binding.videoView1.seekTo(0);
binding.videoView1.setZOrderOnTop(true);
binding.videoView1.setZOrderMediaOverlay(true);
binding.layoutVideo1.setVisibility(View.VISIBLE); binding.layoutVideo1.setVisibility(View.VISIBLE);
binding.layoutVideo1.bringToFront(); binding.layoutVideo1.bringToFront();
//binding.videoView1.setZOrderOnTop(true);
//binding.videoView1.setZOrderMediaOverlay(true);
binding.videoView1.setVisibility(View.VISIBLE);
binding.videoImg1.setVisibility(View.VISIBLE); binding.videoImg1.setVisibility(View.VISIBLE);
videoComponents1 = components; videoComponents1 = components;
@ -2780,6 +2786,7 @@ public class ViewScreenSaver extends ViewBase<ViewScreenSaverBinding> {
}); });
//视频准备完毕,可以进行播放 //视频准备完毕,可以进行播放
Log.e("TAG: ", String.valueOf(isvideoPlay0)+" "+String.valueOf(isvideoPlay1));
if(components.getConfig().isPlayAudio()){ if(components.getConfig().isPlayAudio()){
vView.setVolume(1.0f); vView.setVolume(1.0f);
}else { }else {

4
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 screenType = "HDMI"; // 欣威视通3399设备为假关机 HDMI连接:可以用来判断是否为关机状态 LVDS连接:只能用定时关机时间来判断
public static String mqttState = ""; // 屏幕连接方式 public static String mqttState = ""; // 屏幕连接方式
public static String TTSHome="sbc"; // sbc-思必驰 kdxf-科大讯飞 (有语音的项目需要配置) 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 = "xwst"; //设备板子型号 xwst(欣威视通3399)
// public static String androidBoardType = "xwst2"; //设备板子型号 xwst2(欣威视通3588、T982、3576) // public static String androidBoardType = "xwst2"; //设备板子型号 xwst2(欣威视通3588、T982、3576)
// public static String androidBoardType = "zc"; //设备板子型号 zc(卓策主板——王府井喜悦、杨浦中心医院) // public static String androidBoardType = "zc"; //设备板子型号 zc(卓策主板——王府井喜悦、杨浦中心医院)

1
app/src/main/java/qianmu/container/util/FileUtil.java

@ -18,6 +18,7 @@ import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileReader; import java.io.FileReader;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;

38
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.Player;
import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.ui.StyledPlayerView; import com.google.android.exoplayer2.ui.StyledPlayerView;
public class CustomerVideoView extends FrameLayout { public class CustomerVideoView extends FrameLayout {
@ -67,7 +68,8 @@ public class CustomerVideoView extends FrameLayout {
playerView.setShutterBackgroundColor(Color.TRANSPARENT); playerView.setShutterBackgroundColor(Color.TRANSPARENT);
playerView.setUseArtwork(false); playerView.setUseArtwork(false);
playerView.setDefaultArtwork(null); playerView.setDefaultArtwork(null);
// 增加拉伸铺满
playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
replaceSurfaceWithTextureView(); replaceSurfaceWithTextureView();
} }
@ -103,13 +105,21 @@ public class CustomerVideoView extends FrameLayout {
} }
private void initializePlayer() { private void initializePlayer() {
// 创建 ExoPlayer 实例
player = new SimpleExoPlayer.Builder(getContext()) player = new SimpleExoPlayer.Builder(getContext())
.setTrackSelector(new DefaultTrackSelector(getContext())) .setTrackSelector(new DefaultTrackSelector(getContext()))
.build(); .build();
player.setPlayWhenReady(false); player.setPlayWhenReady(false);
// 设置播放器到 PlayerView
playerView.setPlayer(player); playerView.setPlayer(player);
setupPlayerListeners(); setupPlayerListeners();
// 拉伸铺满
playerView.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FILL);
// 默认设置(可以根据需要调整)
playerView.setUseController(false); playerView.setUseController(false);
// 默认设置 Surface 在底部
// setZOrderOnTop(false);
//setZOrderMediaOverlay(false);
} }
private void setupPlayerListeners() { private void setupPlayerListeners() {
@ -192,9 +202,6 @@ public class CustomerVideoView extends FrameLayout {
playerView.setVisibility(INVISIBLE); playerView.setVisibility(INVISIBLE);
} }
public void setZOrderOnTop(boolean onTop) {}
public void setZOrderMediaOverlay(boolean isMediaOverlay) {}
@Override @Override
public void setVisibility(int visibility) { public void setVisibility(int visibility) {
super.setVisibility(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 start() { if (player != null) player.play(); }
public void pause() { if (player != null) player.pause(); } public void pause() { if (player != null) player.pause(); }
public void stopPlayback() { if (player != null) player.stop(); } public void stopPlayback() { if (player != null) player.stop(); }

Loading…
Cancel
Save