|
@@ -1,16 +1,37 @@
|
|
|
package com.ch.jedge.tvmufis;
|
|
|
|
|
|
+import android.content.Context;
|
|
|
+import android.media.AudioManager;
|
|
|
+import android.media.MediaPlayer;
|
|
|
+import android.util.Log;
|
|
|
+
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
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.HashMap;
|
|
|
+import java.util.List;
|
|
|
|
|
|
public class JeageTVBridge {
|
|
|
|
|
|
private static JeageTVBridge bridge = null;
|
|
|
private TVMufisService tvMufisService;
|
|
|
|
|
|
+ private ISourceManager srcm;
|
|
|
+ private MediaPlayerListenner mPlayerListerner;
|
|
|
+ private MediaPlayer mplayer;
|
|
|
+
|
|
|
private JeageTVBridge(){
|
|
|
|
|
|
}
|
|
@@ -59,4 +80,143 @@ public class JeageTVBridge {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public void TVsetVolume(int volume) {
|
|
|
+ if((volume<0)||(volume>100))
|
|
|
+ return;
|
|
|
+
|
|
|
+ AudioManager am = (AudioManager) tvMufisService.getSystemService(Context.AUDIO_SERVICE);
|
|
|
+// int volume = am.getStreamVolume(AudioManager.STREAM_MUSIC);
|
|
|
+// Log.d("TESTWWW", "getVolume 1");
|
|
|
+ am.setStreamVolume(AudioManager.STREAM_MUSIC, volume, AudioManager.FLAG_SHOW_UI);
|
|
|
+// volume = am.getStreamVolume(AudioManager.STREAM_MUSIC);
|
|
|
+// Log.d("TESTWWW", "getVolume 2");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void TVsetBrightness(int value) {
|
|
|
+ if((value<0)||(value>100))
|
|
|
+ return;
|
|
|
+
|
|
|
+ TVManager tvm = TVManager.getInstance(tvMufisService);
|
|
|
+ try {
|
|
|
+ PictureManager pm = tvm.getPictureManager();
|
|
|
+// pm.setBrightness(value);
|
|
|
+ pm.setBackLight(value);
|
|
|
+ } catch (TVManagerNotInitException | IllegalValueException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void TVsetSoundMode(String mode) {
|
|
|
+ TVManager tvm = TVManager.getInstance(tvMufisService);
|
|
|
+ boolean ret = false;
|
|
|
+ try {
|
|
|
+ SoundManager sm = tvm.getSoundManager();
|
|
|
+ if("标准".equals(mode))
|
|
|
+ ret = sm.setSoundMode(ChOsType.ENUMSoundMode.CH_SOUND_MODE_STANDARD);
|
|
|
+ else if("剧场".equals(mode))
|
|
|
+ ret = sm.setSoundMode(ChOsType.ENUMSoundMode.CH_SOUND_MODE_UMAX);
|
|
|
+ else if("音乐".equals(mode))
|
|
|
+ ret = sm.setSoundMode(ChOsType.ENUMSoundMode.CH_SOUND_MODE_MUSIC);
|
|
|
+ else if("新闻".equals(mode))
|
|
|
+ ret = sm.setSoundMode(ChOsType.ENUMSoundMode.CH_SOUND_MODE_NEWS);
|
|
|
+
|
|
|
+ Log.d("TTTTTT", "ret is "+ret);
|
|
|
+ } catch (TVManagerNotInitException | IllegalValueException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void TVsetPictureMode(String mode) {
|
|
|
+ TVManager tvm = TVManager.getInstance(tvMufisService);
|
|
|
+ boolean ret = false;
|
|
|
+ try {
|
|
|
+ PictureManager pm = tvm.getPictureManager();
|
|
|
+ if("标准".equals(mode))
|
|
|
+ ret = pm.setPictureMode(ChOsType.ENUMPictureMode.E_PICTURE_MODE_STANDARD);
|
|
|
+ else if("柔和".equals(mode))
|
|
|
+ ret = pm.setPictureMode(ChOsType.ENUMPictureMode.E_PICTURE_MODE_READING);
|
|
|
+ else if("亮丽".equals(mode))
|
|
|
+ ret = pm.setPictureMode(ChOsType.ENUMPictureMode.E_PICTURE_MODE_DOLBY_VIVID);
|
|
|
+
|
|
|
+ Log.d("TTTTTT", "ret is "+ret);
|
|
|
+ } catch (TVManagerNotInitException | IllegalValueException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// public void TVsetInputSource(String source) {
|
|
|
+// TVManager tvm = TVManager.getInstance(tvMufisService);
|
|
|
+// boolean ret = false;
|
|
|
+// try {
|
|
|
+//// ISourceManager sm = tvm.getSourceManager();
|
|
|
+// ITVPlayer itvPlayer = tvm.getTVPlayer();
|
|
|
+// if("HDMI".equals(source)||"HDMI1".equals(source))
|
|
|
+// ret = itvPlayer.startInputSource(EnumInputSource.E_INPUT_SOURCE_HDMI, -1);
|
|
|
+//// sm.selectInputSource(EnumInputSource.E_INPUT_SOURCE_HDMI);
|
|
|
+// else if("HDMI2".equals(source))
|
|
|
+// ret = itvPlayer.startInputSource(EnumInputSource.E_INPUT_SOURCE_HDMI2, -1);
|
|
|
+//// sm.selectInputSource(EnumInputSource.E_INPUT_SOURCE_HDMI2);
|
|
|
+// else if("HDMI3".equals(source))
|
|
|
+// ret = itvPlayer.startInputSource(EnumInputSource.E_INPUT_SOURCE_HDMI3, -1);
|
|
|
+//// sm.selectInputSource(EnumInputSource.E_INPUT_SOURCE_HDMI3);
|
|
|
+// else if("HDMI4".equals(source))
|
|
|
+// ret = itvPlayer.startInputSource(EnumInputSource.E_INPUT_SOURCE_HDMI4, -1);
|
|
|
+//// sm.selectInputSource(EnumInputSource.E_INPUT_SOURCE_HDMI4);
|
|
|
+//
|
|
|
+// Log.d("TTTTTT", "ret is "+ret);
|
|
|
+// } catch (TVManagerNotInitException e) {
|
|
|
+// throw new RuntimeException(e);
|
|
|
+// }
|
|
|
+// }
|
|
|
+ public void TVplayVideo(String name) {
|
|
|
+// List<HashMap<String, String>> mapList = USBFileManager.GetVideoFile(tvMufisService);
|
|
|
+// 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;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(file.isEmpty())
|
|
|
+// return;
|
|
|
+// String file = "/storage/8688-F2B5/vedio/视频2.mp4";
|
|
|
+ String file = "/sdcard/Movies/5.mp4";
|
|
|
+ TVManager tvm = TVManager.getInstance(tvMufisService);
|
|
|
+ try {
|
|
|
+
|
|
|
+ srcm = tvm.getSourceManager();
|
|
|
+ srcm.requestResource(EnumResource.CH_RESOURCE_MMP, "player");
|
|
|
+ mPlayerListerner = new MediaPlayerListenner();
|
|
|
+ srcm.registerResourceListener(mPlayerListerner);
|
|
|
+ if(mplayer != null) {
|
|
|
+ mplayer.reset();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ mplayer = new MediaPlayer();
|
|
|
+
|
|
|
+ mplayer.setDataSource(file);
|
|
|
+ mplayer.prepare();
|
|
|
+ mplayer.start();
|
|
|
+ } catch (TVManagerNotInitException | IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ class MediaPlayerListenner implements IResourceManager.IResourceListener {
|
|
|
+ @Override
|
|
|
+ public void onResourceLose() {
|
|
|
+ if(mplayer != null){
|
|
|
+ mplayer.stop();
|
|
|
+ mplayer.release();
|
|
|
+ mplayer = null;
|
|
|
+ }
|
|
|
+ srcm.unRegisterResourceListener(mPlayerListerner);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|