Browse Source

fix: 视频播放处理

master
高志龙 3 months ago
parent
commit
e59a33b1c7
  1. 6
      app/build.gradle
  2. 2
      app/src/main/AndroidManifest.xml
  3. 5
      app/src/main/java/qianmu/container/activity/H5/UpdateFileActivity.java
  4. 6
      app/src/main/java/qianmu/container/activity/H5/WebViewActivity.java
  5. 91
      app/src/main/java/qianmu/container/activity/program/MyPresentation.java
  6. 25
      app/src/main/java/qianmu/container/activity/program/ScreenSaverActivity.java
  7. 117
      app/src/main/java/qianmu/container/activity/program/ViewScreenSaver.java
  8. 19
      app/src/main/java/qianmu/container/app/MyApplication.java
  9. 41
      app/src/main/java/qianmu/container/mqtt/MQTTService.java
  10. 15
      app/src/main/java/qianmu/container/util/SignWayUtil.java
  11. 15
      app/src/main/res/layout/presentation.xml

6
app/build.gradle

@ -12,7 +12,7 @@ android {
minSdkVersion 24
targetSdkVersion 30
versionCode 6
versionName "V2.0.8.17"
versionName "V2.0.8.18"
// 2.0.8.2
// 2.0.8.3 mac修改
// V2.0.8.5
@ -142,8 +142,8 @@ dependencies {
implementation 'cn.hutool:hutool-all:5.8.26'
//
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.3'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.3'
//releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.3'
//
// debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'

2
app/src/main/AndroidManifest.xml

@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<!--录音 录制声音通过手机或耳机的麦克-->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!--开机自动允许 允许程序开机自动运行-->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!--改变WiFi状态 改变WiFi状态-->
@ -88,6 +89,7 @@
android:name=".activity.program.ScreenSaverActivity"
android:configChanges="touchscreen|keyboard|keyboardHidden|navigation"
android:launchMode="singleTask"
android:hardwareAccelerated="true"
android:screenOrientation="nosensor" />
<activity

5
app/src/main/java/qianmu/container/activity/H5/UpdateFileActivity.java

@ -187,7 +187,10 @@ public class UpdateFileActivity extends BaseActivity {
getOfflineDataByInterface();
}
//获取AI资源
H5Data.queryAiServeList( () -> totalQueryCount++, () -> queryResponseCount++ ,bigFiles);
LoggerUtil.e("语音授权: ", String.valueOf(MyApplication.getInstance().duiliteConfig));
if(MyApplication.getInstance().duiliteConfig){ // 语音授权完成
H5Data.queryAiServeList( () -> totalQueryCount++, () -> queryResponseCount++ ,bigFiles);
}
if("指路机".equals(deviceType)){
DeviceData.getBackgroundMusic( () -> totalQueryCount++, () -> queryResponseCount++ ,bigFiles);

6
app/src/main/java/qianmu/container/activity/H5/WebViewActivity.java

@ -112,7 +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.1.196:5501/index.html";
//static String HtmlUrl = "http://192.168.0.100:5173/";
int time = 0;
String interfaceRequestData="";
private VideoView currentVideo; //当前
@ -193,8 +193,7 @@ public class WebViewActivity extends BaseActivity {
binding = DataBindingUtil.setContentView(this, R.layout.activity_webview);
String jsonString = FileUtil.readLocalJsonForStorage(this, StringUtil.strSplice(Constant.CACHE_PATH3,"/JSON/getChatManVideo.json"));
if(!StringUtil.isEmpty(jsonString)){ //是AI
LoggerUtil.e("getChatManVideo:","有数字人视频");
if(!StringUtil.isEmpty(jsonString) && MyApplication.getInstance().duiliteConfig){ //是AI
// 设置背景透明度
binding.web.setBackgroundColor(Color.TRANSPARENT);
isChatMan = true;
@ -258,7 +257,6 @@ public class WebViewActivity extends BaseActivity {
}
}
//设置密码
initPass();
try{

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

@ -507,27 +507,6 @@ class MyPresentation extends Presentation {
//存在视频组件
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(),videoImg2);
}
// String[] b = localPath.split("\\.");
// String imgUrl = b[0]+".jpg";
// if(new File(imgUrl).exists()){
// binding.videoImg0.setVisibility(View.GONE);
// Glide.with(context).load(imgUrl).into(binding.videoImg0)
// }
}else {
//图片
if(new File(localPath).exists()){
Glide.with(context).load(localPath).into(videoImg2);
}
}
if(!isNextVideo){
Log.e("(双面屏)TAG","预览设置下个视频");
isNextVideo=true;
@ -541,25 +520,6 @@ class MyPresentation extends Presentation {
}
}
}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(),videoImg3);
}
// 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(videoImg3);
}
}
if(!isNextVideo){
Log.e("(双面屏)TAG","预览设置下个视频");
@ -1339,8 +1299,6 @@ class MyPresentation extends Presentation {
ImageView otherImg14;
ImageView otherImg15;
RelativeLayout relativeLayoutMax;
ImageView videoImg2;
ImageView videoImg3;
ImageView img0;
ImageView img1;
ImageView img2;
@ -1400,8 +1358,6 @@ class MyPresentation extends Presentation {
layoutTime4 = findViewById(R.id.layout_time4);
layoutVideo2 = findViewById(R.id.layout_video2);
layoutVideo3 = findViewById(R.id.layout_video3);
videoImg2 = findViewById(R.id.videoImg2);
videoImg3 = findViewById(R.id.videoImg3);
layoutImg0 = findViewById(R.id.layout_img0);
layoutImg1 = findViewById(R.id.layout_img1);
layoutImg2 = findViewById(R.id.layout_img2);
@ -1531,9 +1487,7 @@ class MyPresentation extends Presentation {
videoPlayCount0 = 0;
videoPlayCount1 = 0;
startVideoTime=0;
isvideoPlay0=false;
isvideoPlay1=false;
//图片切换
imagePlayCount0 = 0;
imagePlayCount1 = 0;
@ -2650,9 +2604,7 @@ class MyPresentation extends Presentation {
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;
videoView2.pause();
videoView2.seekTo(0);
layoutVideo2.setX(components.getOffsetX());
@ -2665,11 +2617,10 @@ class MyPresentation extends Presentation {
layoutVideo2.setVisibility(View.VISIBLE);
layoutVideo2.bringToFront();
handler.sendEmptyMessage(TYPE_UPDATE_VIDEO0);
videoImg2.setVisibility(View.VISIBLE);
videoView2.setOnPreparedListener(new CustomerVideoView.OnPreparedListener() {
@Override
public void onPrepared() {
videoStartPlay(videoView2, videoImg2, videoComponents0, isvideoPlay0);
videoStartPlay(videoView2, videoComponents0);
}
});
@ -2697,7 +2648,6 @@ class MyPresentation extends Presentation {
}else if(position==1){
isvideoPlay1 = true;
layoutVideo3.setX(components.getOffsetX());
layoutVideo3.setY(components.getOffsetY());
ViewGroup.LayoutParams layoutParams = layoutVideo3.getLayoutParams();
@ -2711,15 +2661,13 @@ class MyPresentation extends Presentation {
layoutVideo3.setVisibility(View.VISIBLE);
layoutVideo3.bringToFront();
videoImg3.setVisibility(View.VISIBLE);
videoComponents1 = components;
handler.sendEmptyMessage(TYPE_UPDATE_VIDEO1);
videoView3.setOnPreparedListener(new CustomerVideoView.OnPreparedListener() {
@Override
public void onPrepared() {
videoStartPlay(videoView3, videoImg3, videoComponents1, isvideoPlay1);
videoStartPlay(videoView3, videoComponents1);
}
});
@ -2743,38 +2691,25 @@ class MyPresentation extends Presentation {
}
}
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);
vView.clearBackground();
}
});
//视频准备完毕,可以进行播放
Log.e("(双面屏)TAG","准备好视频,开始播放");
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();
handler.removeMessages(TYPE_STOP_VIDEO_PLAY0);
handler.removeMessages(TYPE_STOP_VIDEO_PLAY1);
if(components.getConfig().isPlayAudio()){
vView.setVolume(1.0f);
}else {
vView.start();
vView.setVolume(0f);
//暂停播放
if(vView == videoView2){
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();
}
/**
* 更新video
@ -2811,7 +2746,7 @@ class MyPresentation extends Presentation {
handler.sendEmptyMessageDelayed(TYPE_UPDATE_VIDE,materials0.getDuration()*1000);
try {
if (videoView.isPlaying()) {
videoView.stopPlayback();
videoView.pause();
}
new Handler(Looper.getMainLooper()).postDelayed(() -> {
try {
@ -2838,8 +2773,6 @@ class MyPresentation extends Presentation {
videoView3.setLayoutParams(layoutParams);
}
videoImg2.setVisibility(View.GONE);
videoImg3.setVisibility(View.GONE);
handler.sendEmptyMessageDelayed(TYPE_UPDATE_VIDE,videoComponents.getConfig().getTransitionPeriod()*1000);
Drawable drawable = new BitmapDrawable(localPath);
videoView.setBackground(drawable);

25
app/src/main/java/qianmu/container/activity/program/ScreenSaverActivity.java

@ -100,7 +100,6 @@ public class ScreenSaverActivity extends BaseActivity {
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case TYPE_HINT_PASSWORD:
@ -344,11 +343,11 @@ public class ScreenSaverActivity extends BaseActivity {
LoggerUtil.e("ScreenSaverActivity", "诺瓦设备截屏");
Screenshot(message.getData());
} else if (Constant.NOVA_SCREEN_POWER_ON.equals(message.getCode())) {
LoggerUtil.e("ScreenSaverActivity", "诺瓦设备开屏");
screenPower("OPEN");
//LoggerUtil.e("ScreenSaverActivity", "诺瓦设备开屏");
//screenPower("OPEN");
} else if (Constant.NOVA_SCREEN_POWER_CLOSE.equals(message.getCode())) {
LoggerUtil.e("ScreenSaverActivity", "诺瓦设备关屏");
screenPower("CLOSE");
//LoggerUtil.e("ScreenSaverActivity", "诺瓦设备关屏");
//screenPower("CLOSE");
}
}
@ -447,11 +446,9 @@ public class ScreenSaverActivity extends BaseActivity {
@Override
public void dataCallBack(int code, String data) {
LoggerUtil.e("QHT: 搜索:", "code:" + code + ",data:" + data);
if (code == 0) {
NovaDeviceBean novaDeviceBean = new Gson().fromJson(data, NovaDeviceBean.class);
sn = novaDeviceBean.getSn();
login("");
}
NovaDeviceBean novaDeviceBean = new Gson().fromJson(data, NovaDeviceBean.class);
sn = novaDeviceBean.getSn();
login("");
}
});
}
@ -535,6 +532,14 @@ public class ScreenSaverActivity extends BaseActivity {
@Override
public void dataCallBack(int code, String data) {
LoggerUtil.e("QHT: 开关屏:", "code:" + code + ",data:" + data);
if("CLOSE".equals(state)){
MyApplication.getInstance().stopService(new Intent(MyApplication.getInstance(),MQTTService.class));
}else{
MyApplication.getInstance().startService(new Intent(MyApplication.getInstance(),MQTTService.class));
}
if(code == 65350){
login(state);
}
}
});
}

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

@ -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()));
}
}

19
app/src/main/java/qianmu/container/app/MyApplication.java

@ -84,11 +84,15 @@ public class MyApplication extends Application {
return myApplication;
}
@Override
public void onCreate() {
super.onCreate();
myApplication = this;
try {
Thread.sleep(6000);
} catch (InterruptedException e) {
e.printStackTrace();
}
initARouter();
initOkGo();
SocketServerManager.startSocketServer();
@ -116,19 +120,24 @@ public class MyApplication extends Application {
@Override
public void onActivityPaused(Activity activity) {
}
@Override
public void onActivityStopped(Activity activity) {
if (mCurrentActivity == activity) {
mCurrentActivity = null;
}
}
@Override
public void onActivityStopped(Activity activity) {}
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {}
@Override
public void onActivityDestroyed(Activity activity) { }
public void onActivityDestroyed(Activity activity) {
if (mCurrentActivity == activity) {
mCurrentActivity = null;
}
}
});
}

41
app/src/main/java/qianmu/container/mqtt/MQTTService.java

@ -150,7 +150,7 @@ public class MQTTService extends Service {
userName= DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_CODE);
if(Constant.tywx){
passWord= AesUtil.md5(DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_MAC, SignWayUtil.getEthMacAddress()));
Log.e("MQTTService","passWord:"+passWord);
LoggerUtil.e("MQTTService","passWord:"+passWord);
}else {
passWord= MqttData.getMqttToken().getPassword();
}
@ -337,7 +337,6 @@ public class MQTTService extends Service {
}
connectionLostTime = time;
LoggerUtil.e(TAG, " 失去连接: 时间:"+connectionLostTime+",次数:"+connectionLostNumb);
// LoggerUtil.e(TAG, " 失去连接 ");
}
};
@ -705,24 +704,26 @@ public class MQTTService extends Service {
}else{
screenshotFuture = singleThreadExecutor.submit(() -> {
View decorView = MyApplication.getInstance().getCurrentActivity().getWindow().getDecorView();
decorView.setDrawingCacheEnabled(true);
decorView.buildDrawingCache();
Bitmap bmp = decorView.getDrawingCache();
Rect frame = new Rect();
decorView.getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
Bitmap screenBitmap = Bitmap.createBitmap(bmp, 0, statusBarHeight, decorView.getWidth(), decorView.getHeight() - statusBarHeight);
decorView.setDrawingCacheEnabled(false);
//保存
try (FileOutputStream fos = new FileOutputStream(file)) {
screenBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
} catch (IOException e) {
e.printStackTrace();
}
if(new File(path).exists()){
LoggerUtil.e("screenShot","截屏完成");
return true;
if(decorView != null){
decorView.setDrawingCacheEnabled(true);
decorView.buildDrawingCache();
Bitmap bmp = decorView.getDrawingCache();
Rect frame = new Rect();
decorView.getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
Bitmap screenBitmap = Bitmap.createBitmap(bmp, 0, statusBarHeight, decorView.getWidth(), decorView.getHeight() - statusBarHeight);
decorView.setDrawingCacheEnabled(false);
//保存
try (FileOutputStream fos = new FileOutputStream(file)) {
screenBitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
} catch (IOException e) {
e.printStackTrace();
}
if(new File(path).exists()){
LoggerUtil.e("screenShot","截屏完成");
return true;
}
}
return false;
});

15
app/src/main/java/qianmu/container/util/SignWayUtil.java

@ -390,12 +390,6 @@ public class SignWayUtil {
zcapi zcApi=new zcapi();
zcApi.getContext(MyApplication.getInstance());
return zcApi.getEthMacAddress("eth0");
}else if(Constant.androidBoardType.equals("nova")){
String mac = DeviceUtil.getLanMac();
if(StringUtil.isEmpty(mac)){
mac = DeviceUtil.getMacFromHardware();
}
return mac;
}else if(Constant.androidBoardType.equals("huidu")){
HuiduTech helper = new HuiduTech(MyApplication.getInstance());
@ -407,9 +401,12 @@ public class SignWayUtil {
LoggerUtil.e("getEthMacAddress", "wifimac:" + helper.getWifiMac());
return helper.getWifiMac();
}
}
else {
return DeviceUtil.getMacFromHardware();
}else {
String mac = DeviceUtil.getLanMac();
if(StringUtil.isEmpty(mac)){
mac = DeviceUtil.getMacFromHardware();
}
return mac;
}
} catch (Throwable t) {

15
app/src/main/res/layout/presentation.xml

@ -30,12 +30,7 @@
android:layout_height="match_parent"
android:id="@+id/videoView2"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:visibility="gone"
android:id="@+id/videoImg2"/>
</RelativeLayout>
@ -46,18 +41,12 @@
android:gravity="center"
android:visibility="gone">
<qianmu.container.view.CustomerVideoView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/videoView3"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:visibility="gone"
android:id="@+id/videoImg3"/>
</RelativeLayout>

Loading…
Cancel
Save