简介
本文将介绍如何使用TV助手sdk开发Android应用
jar文件为:tvhelper-sdk.jar
sdk初始化
先在Application的onCreate方法中初始化sdk
示例代码:
TvSdk.getInstance().init(getApplicationContext());
sdk提供的方法
- 绑定机顶盒
- 获取已绑定机顶盒列表
- 解除绑定
- 遥控器按键
- 语音识别
- 甩屏
方法介绍
bind(绑定机顶盒)
参数说明:String 机顶盒账号,String 手机号,String 机顶盒省份编号,String 手机省份编号,TvResponseListener 回调)
示例代码:
TvSdk.getInstance().bind(iptvId_b, userId, iptvCarrierId,
mobileCarrierId, new TvResponseListener() {
@Override
public void onBind(final int arg0) {
// TODO Auto-generated method stub
Log.d(TAG, "buttonBind onBind" + arg0);
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this,
"onBind :" + arg0,
Toast.LENGTH_LONG).show();
}
});
}
@Override
public void onFailure(String arg0) {
// TODO Auto-generated method stub
Log.d(TAG, "buttonBind onFailure" + arg0);
}
@Override
public void onSuccess(List<RelateSubscriberInfo> arg0) {
// TODO Auto-generated method stub
Log.d(TAG, "buttonBind onSuccess" + arg0);
}
});
getBindList(获取已绑定机顶盒列表)
参数说明:String 手机号,String 手机省份编号,TvResponseListener 返回列表回调监听
示例代码:
TvSdk.getInstance().getBindList(userId, mobileCarrierId,
new TvResponseListener() {
@Override
public void onBind(int arg0) {
// TODO Auto-generated method stub
Log.d(TAG, "onBind = " + arg0);
}
@Override
public void onFailure(String arg0) {
// TODO Auto-generated method stub
Log.d(TAG, "onFailure = " + arg0);
}
@Override
public void onSuccess(List<RelateSubscriberInfo> arg0) {
// TODO Auto-generated method stub
Log.d(TAG, "onSuccess = " + arg0);
}
});
unBind(解除绑定)
参数说明:String 机顶盒账号,String 手机号,String 机顶盒省份编号,String 手机省份编号
TvResponseListener 回调
示例代码:
TvSdk.getInstance().unBind(userId, iptvId,null);
keyUp(遥控器向上按键)
参数说明:String 手机号,String 机顶盒账号,
TvResponseListener 回调
示例代码:
TvSdk.getInstance().keyUp(userId, iptvId,null);
startRecognition(开始录音,进行语音识别)
参数说明:String 手机号,String 机顶盒账号, String 机顶盒省份编号
示例代码:
TvSdk.getInstance().startRecognition(userId, iptvId, "237");
stopRecognition(结束录音和语音识别)
示例代码:
TvSdk.getInstance().stopRecognition();
playMovieOnTV(电影甩屏)
参数说明:String 手机号,String 机顶盒账号, String 电影id,TvManager.TvResponseListener 回调
示例代码:
TvSdk.getInstance().playMovieOnTV(userId, iptvId,"V9659xxxxxxxx", null);
playSerialOnTV(剧集甩屏)
参数说明:String 手机号,String 机顶盒账号, String 剧集json,TvManager.TvResponseListener 回调
示例代码:
JSONObject obj = new JSONObject();
try {
obj.put("showType", "3");
obj.put("packageId", "V9659xxxxxxx");
obj.put("position", 1);
obj.put("voice", true);
obj.put("howBack", 0);
} catch (JSONException e) {
e.printStackTrace();
}
TvSdk.getInstance().playSerialOnTV(userId, iptvId, obj.toString(),null);