|
@@ -1,37 +1,36 @@
|
|
|
package com.ch.jedge.tvmufis;
|
|
|
|
|
|
+import android.content.ComponentName;
|
|
|
import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
import android.media.AudioManager;
|
|
|
-import android.media.MediaPlayer;
|
|
|
+
|
|
|
+import android.net.Uri;
|
|
|
+import android.os.Bundle;
|
|
|
import android.util.Log;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
+
|
|
|
+import androidx.core.content.FileProvider;
|
|
|
+
|
|
|
import com.ch.jedge.llm.filter.glm.service.TVMufisService;
|
|
|
import com.changhong.qlib.QData;
|
|
|
import com.changhong.qlib.intf.QIData;
|
|
|
import com.changhong.tvos.common.*;
|
|
|
import com.changhong.tvos.common.exception.IllegalValueException;
|
|
|
-import com.changhong.tvos.common.exception.SourceNotFoundException;
|
|
|
import com.changhong.tvos.common.exception.TVManagerNotInitException;
|
|
|
import com.changhong.tvos.model.ChOsType;
|
|
|
-import com.changhong.tvos.model.EnumInputSource;
|
|
|
-import com.changhong.tvos.model.EnumResource;
|
|
|
|
|
|
import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
public class JeageTVBridge {
|
|
|
|
|
|
private static JeageTVBridge bridge = null;
|
|
|
private TVMufisService tvMufisService;
|
|
|
|
|
|
- private ISourceManager srcm;
|
|
|
- private MediaPlayerListenner mPlayerListerner;
|
|
|
- private MediaPlayer mplayer;
|
|
|
-
|
|
|
private JeageTVBridge(){
|
|
|
|
|
|
}
|
|
@@ -172,57 +171,82 @@ public class JeageTVBridge {
|
|
|
|
|
|
|
|
|
|
|
|
- public void TVplayVideo(String name) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- String file = "/storage/8688-F2B5/vedio/视频2.mp4";
|
|
|
-
|
|
|
- TVManager tvm = TVManager.getInstance(tvMufisService);
|
|
|
- try {
|
|
|
+ public void TVplayUSBVideo(String name) {
|
|
|
+ List<HashMap<String, String>> mapList = USBFileManager.GetNeedFile(tvMufisService, "video");
|
|
|
+ if (mapList.isEmpty())
|
|
|
+ return;
|
|
|
|
|
|
- srcm = tvm.getSourceManager();
|
|
|
- srcm.requestResource(EnumResource.CH_RESOURCE_MMP, "player");
|
|
|
- mPlayerListerner = new MediaPlayerListenner();
|
|
|
- srcm.registerResourceListener(mPlayerListerner);
|
|
|
- if(mplayer != null) {
|
|
|
- mplayer.reset();
|
|
|
+ String file = "";
|
|
|
+ if(name.isEmpty())
|
|
|
+ file = mapList.get(0).get("path");
|
|
|
+ else {
|
|
|
+ for(HashMap<String, String>hmap : mapList){
|
|
|
+ String fname = hmap.get("name");
|
|
|
+ if(name.equals(fname)) {
|
|
|
+ file = hmap.get("path");
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
- mplayer = new MediaPlayer();
|
|
|
-
|
|
|
- mplayer.setDataSource(file);
|
|
|
- mplayer.prepare();
|
|
|
- mplayer.start();
|
|
|
- } catch (TVManagerNotInitException | IOException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
}
|
|
|
+
|
|
|
+ if(file.isEmpty())
|
|
|
+ return;
|
|
|
+
|
|
|
+ Intent intent = new Intent();
|
|
|
+ ComponentName comp = new ComponentName("com.changhong.mmp.fileexplorer", "com.changhong.mmp.videoplayer.ChangHongVideoPlayerActivity");
|
|
|
+ intent.setComponent(comp);
|
|
|
+ ArrayList<Map<String, Object>> videoPlayNodeList = new ArrayList<Map<String, Object>>();
|
|
|
+
|
|
|
+ HashMap<String, Object> movieNode = new HashMap<String, Object>();
|
|
|
+ movieNode.put("title", name);
|
|
|
+ movieNode.put("cn", 1);
|
|
|
+ String[] str = new String[]{file};
|
|
|
+ movieNode.put("playUrls", str);
|
|
|
+ videoPlayNodeList.add(movieNode);
|
|
|
+
|
|
|
+ Bundle mData = new Bundle();
|
|
|
+ mData.putInt("playSourceType", 0);
|
|
|
+ mData.putInt("curPos", 0);
|
|
|
+ intent.putExtra("movieNode", videoPlayNodeList);
|
|
|
+ intent.putExtras(mData);
|
|
|
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
|
+ tvMufisService.startActivity(intent);
|
|
|
}
|
|
|
- class MediaPlayerListenner implements IResourceManager.IResourceListener {
|
|
|
- @Override
|
|
|
- public void onResourceLose() {
|
|
|
- if(mplayer != null){
|
|
|
- mplayer.stop();
|
|
|
- mplayer.release();
|
|
|
- mplayer = null;
|
|
|
+
|
|
|
+ public void TVinstallUSBApp(String name) {
|
|
|
+ List<HashMap<String, String>> mapList = USBFileManager.GetNeedFile(tvMufisService, "app");
|
|
|
+ if (mapList.isEmpty())
|
|
|
+ return;
|
|
|
+
|
|
|
+ String file = "";
|
|
|
+ if(name.isEmpty())
|
|
|
+ file = mapList.get(0).get("path");
|
|
|
+ else {
|
|
|
+ for(HashMap<String, String>hmap : mapList){
|
|
|
+ String fname = hmap.get("name");
|
|
|
+ if(name.equals(fname)) {
|
|
|
+ file = hmap.get("path");
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- srcm.unRegisterResourceListener(mPlayerListerner);
|
|
|
}
|
|
|
+
|
|
|
+ if(file.isEmpty())
|
|
|
+ return;
|
|
|
+
|
|
|
+ Uri uri = FileProvider.getUriForFile(tvMufisService,"com.ch.jedge.llm.filter.glm.FileProvider", new File(file));
|
|
|
+
|
|
|
+ Intent intent = new Intent();
|
|
|
+ intent.setAction(Intent.ACTION_INSTALL_PACKAGE);
|
|
|
+
|
|
|
+ intent.setDataAndType(uri, "application/vnd.android.package-archive");
|
|
|
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
|
|
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
|
+ intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
|
|
|
+ |Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
|
|
+
|
|
|
+ intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE,true);
|
|
|
+ tvMufisService.startActivity(intent);
|
|
|
}
|
|
|
}
|