Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
apk_product
/
ForFun
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
10304d19
...
10304d19c9b0edad679f904710c43707a09215db
authored
2020-04-14 11:21:19 +0800
by
金学艇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改了埋点SDK和福建移动获取视频播放链接
1 parent
f1daf1da
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
371 additions
and
93 deletions
assets/Script/videoDetail.js
assets/resources/data_template/main_recommend.json
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/common/CommonUtils.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/common/HttpClientUtil.java
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/common/TopdrawSDKWrapper.java
assets/Script/videoDetail.js
View file @
10304d1
...
...
@@ -183,7 +183,12 @@ cc.Class({
this
.
checkCollect
();
this
.
getGatherDetailList
();
//获取剧集列表
this
.
getPlayURLAndPlay
();
// this.getPlayURLAndPlay();//先改为从java获取
if
(
cc
.
sys
.
isNative
)
{
jsb
.
reflection
.
callStaticMethod
(
"org/cocos2dx/javascript/common/TopdrawSDKWrapper"
,
"getPlayUrl"
,
"(Ljava/lang/String;)V"
,
"getPlayURLAndPlay"
);
}
}
else
{
cc
.
log
(
"Business Error:Get checkPfbReadyAndInitPage..."
+
oJSONResult
.
description
);
}
...
...
@@ -215,12 +220,14 @@ cc.Class({
}
},
getPlayURLAndPlay
:
function
()
{
getPlayURLAndPlay
:
function
(
playUrl
)
{
try
{
cc
.
log
(
"videoDetail.js -> getPlayURLAndPlay | "
+
playUrl
);
this
.
_ComOperation
.
initPlayer
(
64
,
56
,
564
,
317
,
true
,
true
);
//这里采用左右边距对应android坐标 fix jerry
// this._ComOperation.initPlayer(0, 0, Common.SCREEN_WIDTH, Common.SCREEN_HEIGHT, true, true); //测试
let
options
=
{};
options
.
playurl
=
this
.
_oInit
.
url
;
// options.playurl = this._oInit.url;
options
.
playurl
=
playUrl
;
this
.
_ComOperation
.
setURL
(
options
);
//测试播放地址
}
catch
(
error
)
{
if
(
cc
.
sys
.
isNative
)
{
...
...
assets/resources/data_template/main_recommend.json
View file @
10304d1
...
...
@@ -325,6 +325,7 @@
"name"
:
"记忆翻牌"
,
"imageURL"
:
"upload/image/main/记忆翻牌172-228.png"
,
"title_visible"
:
1
,
"tvlink2"
:
"{
\"
click
\"
:[{
\"
action
\"
:
\"
ChangeScene
\"
,
\"
parameters
\"
:{
\"
sceneName
\"
:
\"
sceneGameDetail
\"
,
\"
packageName
\"
:
\"
com.orbbec.basketball
\"
}}]}"
,
"tvlink"
:
"{
\"
click
\"
:[{
\"
action
\"
:
\"
ChangeScene
\"
,
\"
parameters
\"
:{
\"
sceneName
\"
:
\"
sceneGameDetail
\"
,
\"
packageName
\"
:
\"
com.topdraw.xhx.fanpai
\"
}}]}"
,
"code"
:
"highScore_57aea4b3-7716-4224-bc77-43272c35ee32"
}
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml
View file @
10304d1
...
...
@@ -57,9 +57,10 @@
android:value=
"EastCity"
/>
<!-- 移动埋点SDK -->
<!-- 上线前需要找福建移动验证下是否替换这个正式版的key 9d382a618ebf48a106d4101356a4e5f9-->
<meta-data
android:name=
"CMCC.APPKEY"
android:value=
"1
3e71c3ecc4d4b96f1b5b0e5141bd3e6
"
/>
android:value=
"1
9d1e5ac0d304dc3c82481aecebdc84d
"
/>
<!-- 未来NewTV -->
<meta-data
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java
View file @
10304d1
...
...
@@ -24,8 +24,10 @@
****************************************************************************/
package
org
.
cocos2dx
.
javascript
;
import
org.cocos2dx.javascript.common.HttpClientUtil
;
import
org.cocos2dx.javascript.common.OBiPluginLoader
;
import
org.cocos2dx.javascript.common.PluginLoader
;
import
org.cocos2dx.javascript.component.NativeLogReporterNewTV
;
import
org.cocos2dx.javascript.component.NewTVSDK
;
import
org.cocos2dx.lib.Cocos2dxActivity
;
import
org.cocos2dx.lib.Cocos2dxGLSurfaceView
;
...
...
@@ -77,6 +79,8 @@ import org.cocos2dx.javascript.component.CocosMediaPlayer;
import
org.cocos2dx.javascript.common.CommonUtils
;
import
org.cocos2dx.javascript.common.MelodyApplication
;
import
org.cocos2dx.javascript.common.TopdrawSDKWrapper
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
public
class
AppActivity
extends
Cocos2dxActivity
{
private
static
String
TAG
=
"AppActivity"
;
...
...
@@ -138,6 +142,7 @@ public class AppActivity extends Cocos2dxActivity {
new
Handler
().
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
//这里重新替换了春哥的SDK,所以可能执行不到
relativeLayout
.
setVisibility
(
View
.
GONE
);
}
},
3
*
1000
);
//延迟3秒执行
...
...
@@ -185,11 +190,12 @@ public class AppActivity extends Cocos2dxActivity {
TOPDRAW_APPID
=
appInfo
.
metaData
.
getString
(
"TOPDRAW.APPID"
);
TOPDRAW_APPSECRET
=
appInfo
.
metaData
.
getString
(
"TOPDRAW.APPSECRET"
);
TOPDRAW_REFER_PATH
=
TOPDRAW_PLATFORM_SERVER
+
"/Platform/Logout"
;
TopdrawSDK
.
init
(
getApplicationContext
(),
TOPDRAW_PLATFORM
,
TOPDRAW_PLATFORM_SERVER
,
TOPDRAW_APPID
,
TOPDRAW_APPSECRET
,
initListener
);
//
TopdrawSDK.init(getApplicationContext(), TOPDRAW_PLATFORM, TOPDRAW_PLATFORM_SERVER, TOPDRAW_APPID, TOPDRAW_APPSECRET, initListener);
//移动埋点
APP_KEY
=
appInfo
.
metaData
.
getString
(
"CMCC.APPKEY"
);
APP_NAME
=
getString
(
R
.
string
.
app_name
);
APP_TYPE
=
"游戏"
;
//init NewTV
NewTVSDK
.
getInstence
(
this
).
init
();
//注意防止loading图片覆盖掉开机广告 fix jerry
...
...
@@ -226,6 +232,7 @@ public class AppActivity extends Cocos2dxActivity {
SDKWrapper
.
getInstance
().
onResume
();
mRLSingleColor
.
setVisibility
(
View
.
GONE
);
mOBiLayout
.
setVisibility
(
View
.
GONE
);
relativeLayout
.
setVisibility
(
View
.
GONE
);
}
@Override
...
...
@@ -238,17 +245,37 @@ public class AppActivity extends Cocos2dxActivity {
}
@Override
protected
void
onStop
()
{
Log
.
d
(
"AppActivity"
,
"onStop()...."
);
super
.
onStop
();
SDKWrapper
.
getInstance
().
onStop
();
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
//未来SDK退出
NativeLogReporterNewTV
nlp
=
NativeLogReporterNewTV
.
getInstance
(
this
,
null
);
nlp
.
report
(
88
,
"1"
);
unregisterReceiver
(
receiver
);
SDKWrapper
.
getInstance
().
onDestroy
();
if
(
baminSDKInited
)
{
//埋点SDK退出
HashMap
<
Object
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"APP_NAME"
,
APP_NAME
);
params
.
put
(
"APP_TYPE"
,
APP_TYPE
);
params
.
put
(
"USER_LOGIN"
,
"0"
);
params
.
put
(
"USER_ID"
,
USER_ID
);
params
.
put
(
"USER_ORDER"
,
NativeSystem
.
isAuthenticated
?
"已订购"
:
"未订购"
);
// SDKUtil.getInstance().ky_trackCustom(params);
// SDKUtil.getInstance().ky_userSignOut(USER_ID);
}
TopdrawSDK
.
destory
(
this
,
null
,
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
s
,
Object
o
)
{
Log
.
d
(
TAG
,
"destory "
+
i
+
" "
+
s
);
try
{
if
(
baminSDKInited
)
{
SDKUtil
.
getInstance
().
ky_quit
();
SDKUtil
.
getInstance
().
ky_quit
();
//这里考虑延迟几秒销毁,否则无法触发
}
System
.
exit
(
0
);
}
catch
(
Throwable
t
)
{
...
...
@@ -277,13 +304,6 @@ public class AppActivity extends Cocos2dxActivity {
}
@Override
protected
void
onStop
()
{
Log
.
d
(
"AppActivity"
,
"onStop()...."
);
super
.
onStop
();
SDKWrapper
.
getInstance
().
onStop
();
}
@Override
public
void
onBackPressed
()
{
SDKWrapper
.
getInstance
().
onBackPressed
();
super
.
onBackPressed
();
...
...
@@ -398,7 +418,7 @@ public class AppActivity extends Cocos2dxActivity {
if
(
0
==
result
)
{
MelodyApplication
.
sdk
=
(
ITopdrawSDK
)
obj
;
USER_ID
=
MelodyApplication
.
sdk
.
getOssUserID
();
Log
.
d
(
TAG
,
"
获取token..."
+
MelodyApplication
.
sdk
.
getToken
());
Log
.
d
(
TAG
,
"
USER_ID..."
+
MelodyApplication
.
sdk
.
getOssUserID
());
//15280011369
CookieManager
.
getInstance
().
setCookie
(
TOPDRAW_PLATFORM_SERVER
,
"appId="
+
TOPDRAW_APPID
);
CookieManager
.
getInstance
().
setCookie
(
TOPDRAW_PLATFORM_SERVER
,
"userId="
+
MelodyApplication
.
sdk
.
getUserID
());
...
...
@@ -417,34 +437,35 @@ public class AppActivity extends Cocos2dxActivity {
//局方埋点
try
{
SDKUtil
.
isOpenLog
=
true
;
int
sdkResult
=
SDKUtil
.
getInstance
().
ky_initWithAppKey
(
AppActivity
.
this
,
APP_KEY
,
// Log.d(TAG, "埋点APP_KEY: " + APP_KEY);
int
sdkResult
=
SDKUtil
.
getInstance
().
ky_initWithAppKey
(
AppActivity
.
this
,
APP_KEY
,
//埋点SDK初始化
getPackageManager
().
getPackageInfo
(
getPackageName
(),
0
).
versionName
);
Log
.
d
(
TAG
,
"sdkResult..."
+
sdkResult
);
baminSDKInited
=
(
sdkResult
==
0
);
Log
.
d
(
TAG
,
"埋点数据:"
+
baminSDKInited
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"appId"
,
TOPDRAW_APPID
);
params
.
put
(
"userId"
,
MelodyApplication
.
sdk
.
getUserID
());
MelodyApplication
.
sdk
.
auth
(
AppActivity
.
this
,
MelodyApplication
.
sdk
.
getToken
(),
params
,
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
s
,
Object
o
)
{
if
(
10
==
i
)
{
NativeSystem
.
isAuthenticated
=
true
;
}
else
{
NativeSystem
.
isAuthenticated
=
false
;
}
if
(
baminSDKInited
)
{
HashMap
<
Object
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"APP_NAME"
,
APP_NAME
);
params
.
put
(
"APP_TYPE"
,
APP_TYPE
);
params
.
put
(
"USER_LOGIN"
,
"1"
);
params
.
put
(
"USER_ID"
,
USER_ID
);
params
.
put
(
"USER_ORDER"
,
NativeSystem
.
isAuthenticated
?
"已订购"
:
"未订购"
);
SDKUtil
.
getInstance
().
ky_trackCustom
(
params
);
SDKUtil
.
getInstance
().
ky_userSignIn
(
USER_ID
);
}
}
});
//
Map<String, Object> params = new HashMap<>();
//
params.put("appId", TOPDRAW_APPID);
//
params.put("userId", MelodyApplication.sdk.getUserID());
//
MelodyApplication.sdk.auth(AppActivity.this, MelodyApplication.sdk.getToken(), params, new ITopdrawResultListener() {
//
@Override
//
public void onResult(int i, String s, Object o) {
//
if (10 == i) {
//
NativeSystem.isAuthenticated = true;
//
} else {
//
NativeSystem.isAuthenticated = false;
//
}
if
(
baminSDKInited
)
{
//埋点SDK登录
HashMap
<
Object
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"APP_NAME"
,
APP_NAME
);
params
.
put
(
"APP_TYPE"
,
APP_TYPE
);
params
.
put
(
"USER_LOGIN"
,
"1"
);
params
.
put
(
"USER_ID"
,
USER_ID
);
params
.
put
(
"USER_ORDER"
,
NativeSystem
.
isAuthenticated
?
"已订购"
:
"未订购"
);
// SDKUtil.getInstance().ky_trackCustom(params); //先注释。。。。。
//
SDKUtil.getInstance().ky_userSignIn(USER_ID);
}
//
}
//
});
}
catch
(
Exception
e
)
{
}
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/common/CommonUtils.java
View file @
10304d1
...
...
@@ -3,9 +3,12 @@ package org.cocos2dx.javascript.common;
import
android.content.Context
;
import
android.content.pm.PackageInfo
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
import
android.net.ConnectivityManager
;
import
android.net.NetworkInfo
;
import
android.net.Uri
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
java.io.File
;
...
...
@@ -16,6 +19,8 @@ import java.io.File;
*/
public
class
CommonUtils
{
private
static
final
String
TAG
=
"CommonUtils"
;
public
static
boolean
checkAppInstalled
(
Context
context
,
String
pkgName
)
{
if
(
pkgName
==
null
||
pkgName
.
isEmpty
())
{
return
false
;
...
...
@@ -75,4 +80,46 @@ public class CommonUtils {
}
return
false
;
}
public
static
String
getToken
(
Context
context
)
{
String
value
=
""
;
Uri
uri
=
Uri
.
parse
(
"content://stbconfig/authentication/user_token"
);
Cursor
c
=
null
;
try
{
c
=
context
.
getContentResolver
().
query
(
uri
,
null
,
"name = ?"
,
new
String
[]{
"user_token"
},
null
);
// 建议使用这种name=?参数化的查询语句来操作
if
(
c
!=
null
&&
c
.
moveToFirst
())
{
value
=
c
.
getString
(
c
.
getColumnIndex
(
"value"
));
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
c
!=
null
)
{
c
.
close
();
// 游标放到finally块来释放。
}
}
// Log.d(TAG, "获取机顶盒token..." + value);
return
value
;
}
public
static
String
getServer
(
Context
context
)
{
String
value
=
""
;
Uri
uri
=
Uri
.
parse
(
"content://stbconfig/authentication/epg_server"
);
Cursor
c
=
null
;
try
{
c
=
context
.
getContentResolver
().
query
(
uri
,
null
,
"name = ?"
,
new
String
[]{
"epg_server"
},
null
);
// 建议使用这种name=?参数化的查询语句来操作
if
(
c
!=
null
&&
c
.
moveToFirst
())
{
value
=
c
.
getString
(
c
.
getColumnIndex
(
"value"
));
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
c
!=
null
)
{
c
.
close
();
// 游标放到finally块来释放。
}
}
// Log.d(TAG, "获取机顶盒token..." + value);
return
value
;
}
}
...
...
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/common/HttpClientUtil.java
0 → 100644
View file @
10304d1
package
org
.
cocos2dx
.
javascript
.
common
;
import
android.util.Log
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStreamWriter
;
import
java.net.HttpURLConnection
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
/**
* author : Jinwawa
* date : 2020/4/13 0013.
* desc :
*/
public
class
HttpClientUtil
{
private
static
final
String
TAG
=
"HttpClientUtils"
;
public
static
void
get
(
final
String
requestUrl
,
final
HttpClientUtil
.
OnRequestCallBack
callBack
)
{
new
Thread
()
{
public
void
run
()
{
getRequest
(
requestUrl
,
callBack
);
}
}.
start
();
}
public
static
void
post
(
final
String
requestUrl
,
final
String
params
,
final
String
token
,
final
HttpClientUtil
.
OnRequestCallBack
callBack
)
{
new
Thread
()
{
public
void
run
()
{
postRequest
(
requestUrl
,
params
,
token
,
callBack
);
}
}.
start
();
}
private
static
void
getRequest
(
String
requestUrl
,
HttpClientUtil
.
OnRequestCallBack
callBack
)
{
boolean
isSuccess
=
false
;
String
message
;
InputStream
inputStream
=
null
;
ByteArrayOutputStream
baos
=
null
;
try
{
URL
url
=
new
URL
(
requestUrl
);
HttpURLConnection
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
// 设定请求的方法为"POST",默认是GET
connection
.
setRequestMethod
(
"GET"
);
connection
.
setConnectTimeout
(
50000
);
connection
.
setReadTimeout
(
50000
);
// User-Agent IE9的标识
connection
.
setRequestProperty
(
"User-Agent"
,
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;"
);
connection
.
setRequestProperty
(
"Accept-Language"
,
"zh-CN"
);
connection
.
setRequestProperty
(
"Connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
/*
* 当我们要获取我们请求的http地址访问的数据时就是使用connection.getInputStream().read()方式时我们就需要setDoInput(true),
* 根据api文档我们可知doInput默认就是为true。我们可以不用手动设置了,如果不需要读取输入流的话那就setDoInput(false)。
* 当我们要采用非get请求给一个http网络地址传参 就是使用connection.getOutputStream().write() 方法时我们就需要setDoOutput(true), 默认是false
*/
// 设置是否从httpUrlConnection读入,默认情况下是true;
connection
.
setDoInput
(
true
);
// 设置是否向httpUrlConnection输出,如果是post请求,参数要放在http正文内,因此需要设为true, 默认是false;
//connection.setDoOutput(true);//Android 4.0 GET时候 用这句会变成POST 报错java.io.FileNotFoundException
connection
.
setUseCaches
(
false
);
connection
.
connect
();
//
int
contentLength
=
connection
.
getContentLength
();
if
(
connection
.
getResponseCode
()
==
200
)
{
inputStream
=
connection
.
getInputStream
();
//会隐式调用connect()
baos
=
new
ByteArrayOutputStream
();
int
readLen
;
byte
[]
bytes
=
new
byte
[
1024
];
while
((
readLen
=
inputStream
.
read
(
bytes
))
!=
-
1
)
{
baos
.
write
(
bytes
,
0
,
readLen
);
}
String
result
=
baos
.
toString
();
Log
.
i
(
TAG
,
" result:"
+
result
);
message
=
result
;
isSuccess
=
true
;
}
else
{
message
=
"请求失败 code:"
+
connection
.
getResponseCode
();
}
}
catch
(
MalformedURLException
e
)
{
message
=
e
.
getMessage
();
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
message
=
e
.
getMessage
();
e
.
printStackTrace
();
}
finally
{
try
{
if
(
baos
!=
null
)
{
baos
.
close
();
}
if
(
inputStream
!=
null
)
{
inputStream
.
close
();
}
}
catch
(
IOException
e
)
{
message
=
e
.
getMessage
();
e
.
printStackTrace
();
}
}
if
(
isSuccess
)
{
callBack
.
onSuccess
(
message
);
}
else
{
callBack
.
onError
(
message
);
}
}
private
static
void
postRequest
(
String
requestUrl
,
String
params
,
String
token
,
HttpClientUtil
.
OnRequestCallBack
callBack
)
{
boolean
isSuccess
=
false
;
String
message
;
InputStream
inputStream
=
null
;
ByteArrayOutputStream
baos
=
null
;
try
{
URL
url
=
new
URL
(
requestUrl
);
HttpURLConnection
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
// 设定请求的方法为"POST",默认是GET
connection
.
setRequestMethod
(
"POST"
);
connection
.
setConnectTimeout
(
50000
);
connection
.
setReadTimeout
(
50000
);
// User-Agent IE9的标识
// connection.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0;");
connection
.
setRequestProperty
(
"Accept-Language"
,
"zh-CN"
);
connection
.
setRequestProperty
(
"Connection"
,
"close"
);
connection
.
setRequestProperty
(
"Charset"
,
"UTF-8"
);
connection
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
connection
.
setRequestProperty
(
"Authorization"
,
token
);
/*
* 当我们要获取我们请求的http地址访问的数据时就是使用connection.getInputStream().read()方式时我们就需要setDoInput(true),
* 根据api文档我们可知doInput默认就是为true。我们可以不用手动设置了,如果不需要读取输入流的话那就setDoInput(false)。
* 当我们要采用非get请求给一个http网络地址传参 就是使用connection.getOutputStream().write() 方法时我们就需要setDoOutput(true), 默认是false
*/
// 设置是否从httpUrlConnection读入,默认情况下是true;
connection
.
setDoInput
(
true
);
// 设置是否向httpUrlConnection输出,如果是post请求,参数要放在http正文内,因此需要设为true, 默认是false;
connection
.
setDoOutput
(
true
);
connection
.
setUseCaches
(
false
);
// set params three way OutputStreamWriter
OutputStreamWriter
out
=
new
OutputStreamWriter
(
connection
.
getOutputStream
(),
"UTF-8"
);
// 发送请求params参数
out
.
write
(
params
);
out
.
flush
();
connection
.
connect
();
int
contentLength
=
connection
.
getContentLength
();
if
(
connection
.
getResponseCode
()
==
200
)
{
// 会隐式调用connect()
inputStream
=
connection
.
getInputStream
();
baos
=
new
ByteArrayOutputStream
();
int
readLen
;
byte
[]
bytes
=
new
byte
[
1024
];
while
((
readLen
=
inputStream
.
read
(
bytes
))
!=
-
1
)
{
baos
.
write
(
bytes
,
0
,
readLen
);
}
String
backStr
=
baos
.
toString
();
Log
.
i
(
TAG
,
"请求成功 backStr:"
+
backStr
);
message
=
backStr
;
isSuccess
=
true
;
}
else
{
message
=
"请求失败 code:"
+
connection
.
getResponseCode
();
}
}
catch
(
MalformedURLException
e
)
{
message
=
e
.
getMessage
();
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
message
=
e
.
getMessage
();
e
.
printStackTrace
();
}
finally
{
try
{
if
(
baos
!=
null
)
{
baos
.
close
();
}
if
(
inputStream
!=
null
)
{
inputStream
.
close
();
}
}
catch
(
IOException
e
)
{
message
=
e
.
getMessage
();
e
.
printStackTrace
();
}
}
if
(
isSuccess
)
{
callBack
.
onSuccess
(
message
);
}
else
{
callBack
.
onError
(
message
);
}
}
public
interface
OnRequestCallBack
{
void
onSuccess
(
String
json
);
void
onError
(
String
errorMsg
);
}
}
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/common/TopdrawSDKWrapper.java
View file @
10304d1
...
...
@@ -13,17 +13,15 @@ import android.widget.ProgressBar;
import
android.widget.RelativeLayout
;
import
android.widget.Toast
;
//import com.migu.sdk.api.PayCallBack;
//import com.topdraw.component.MiguPaySDK;
import
com.topdraw.forfun.R
;
import
com.topdraw.sdk.*
;
import
com.topdraw.forfun_FJYD.R
;
import
java.io.File
;
import
org.cocos2dx.javascript.AppActivity
;
import
org.cocos2dx.lib.Cocos2dxJavascriptJavaBridge
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.
cocos2dx.lib.Cocos2dxJavascriptJavaBridge
;
import
org.
json.JSONObject
;
public
class
TopdrawSDKWrapper
{
...
...
@@ -31,7 +29,7 @@ public class TopdrawSDKWrapper {
private
static
AppActivity
_activity
;
private
static
TopdrawSDKWrapper
_instance
=
null
;
static
boolean
pluginLoaded
=
false
;
static
ProgressBar
pb_progress
;
private
static
final
String
HTTP_AUTHORIZE
=
"/EPG/interEpg/user/default/authorize"
;
private
TopdrawSDKWrapper
()
{
}
...
...
@@ -66,67 +64,72 @@ public class TopdrawSDKWrapper {
return
MelodyApplication
.
sdk
.
getUserID
();
}
/**
* 获取播放地址所使用的Listener
*/
private
ITopdrawResultListener
onGetPlayURLListener
=
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
s
,
Object
o
)
{
Log
.
d
(
TAG
,
"TopdrawSDK onGetPlayURL:["
+
i
+
"]"
+
s
);
try
{
final
String
strPlayURL
=
((
JSONArray
)
o
).
getJSONObject
(
0
).
getString
(
"playurl"
);
//通知js
public
static
void
getPlayUrl
(
final
String
strJSCallBack
)
{
Log
.
d
(
TAG
,
"getPlayUrl start..."
+
strJSCallBack
);
String
epgServer
=
CommonUtils
.
getServer
(
_activity
)
+
HTTP_AUTHORIZE
;
String
token
=
CommonUtils
.
getToken
(
_activity
);
String
supercid
=
"42dab385e29e4f0f99c3513939815a2c"
;
//测试用例 电视剧则使用掐头去尾及"-"的mediaCode,电影或单片使用"-1"
String
businessType
=
"1"
;
// 业务类型,1:vod、2:LIVETV。新cp大多是注入点播,此处填1即可
String
contentType
=
"0"
;
// 内容类型,0:视频VOD、1:视频频道、300:节目单。同businessType相似,此处填0即可。
String
playType
=
"1"
;
// 必填,根据demo固定为1,文档未说明该字段
String
tid
=
"-1"
;
// 栏目编号,OTT大屏的cp点播注入不涉及绑定栏目,此处统一填写为-1
String
cid
=
"898abfacb6a34c19b36708ebb43ad044"
;
//测试用例 电视剧的单集使用掐头去尾及"-"的episodeCode,电影单片使用掐头去尾及"-"的mediaCode
String
idflag
=
"1"
;
// 标识cid和supcid的编号类型,统一传1,标识编号为C2接口的内容code。这个字段必需提供,不提供会导致鉴权失败。
JSONObject
mapParams
=
new
JSONObject
();
try
{
mapParams
.
put
(
"supercid"
,
supercid
);
// 电视剧则使用掐头去尾及"-"的mediaCode,电影或单片使用"-1"
mapParams
.
put
(
"businessType"
,
businessType
);
// 业务类型,1:vod、2:LIVETV。新cp大多是注入点播,此处填1即可
mapParams
.
put
(
"contentType"
,
contentType
);
// 内容类型,0:视频VOD、1:视频频道、300:节目单。同businessType相似,此处填0即可。
mapParams
.
put
(
"playType"
,
playType
);
// 必填,根据demo固定为1,文档未说明该字段
mapParams
.
put
(
"tid"
,
tid
);
// 栏目编号,OTT大屏的cp点播注入不涉及绑定栏目,此处统一填写为-1
mapParams
.
put
(
"cid"
,
cid
);
// 电视剧的单集使用掐头去尾及"-"的episodeCode,电影单片使用掐头去尾及"-"的mediaCode
mapParams
.
put
(
"idflag"
,
idflag
);
// 标识cid和supcid的编号类型,统一传1,标识编号为C2接口的内容code。这个字段必需提供,不提供会导致鉴权失败。
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
Log
.
d
(
TAG
,
"token | "
+
CommonUtils
.
getToken
(
_activity
)
+
" server| "
+
CommonUtils
.
getServer
(
_activity
));
HttpClientUtil
.
post
(
epgServer
,
mapParams
.
toString
(),
token
,
new
HttpClientUtil
.
OnRequestCallBack
()
{
@Override
public
void
onSuccess
(
String
json
)
{
Log
.
d
(
TAG
,
"成功获取播放链接 | "
+
json
);
final
String
testUrl
=
"http://mirror.aarnet.edu.au/pub/TED-talks/911Mothers_2010W-480p.mp4"
;
_activity
.
runOnGLThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Cocos2dxJavascriptJavaBridge
.
evalString
(
"cc.log('"
+
strPlayURL
+
"')"
);
Cocos2dxJavascriptJavaBridge
.
evalString
(
"cc.find('Canvas',cc.director.getScene()).getComponent(cc.Topdraw.TVCanvas)."
+
strJSCallBack
+
"('"
+
testUrl
+
"');"
);
}
}
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
};
private
ITopdrawResultListener
onAuthListener
=
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
s
,
Object
o
)
{
Log
.
d
(
TAG
,
"TopdrawSDK authed:["
+
i
+
"]"
+
s
);
if
(
i
==
10
)
{
Log
.
d
(
TAG
,
"auth success"
);
//authResult = true;
}
else
if
(
i
==
-
2010
)
{
//authResult = false;
//sdk.order(context,token,null,orderListener);
Log
.
d
(
TAG
,
"auth failed"
);
JSONObject
joAuthorizeResult
=
null
;
try
{
joAuthorizeResult
=
new
JSONObject
(
json
);
if
(
null
!=
joAuthorizeResult
&&
"0"
.
equals
(
joAuthorizeResult
.
getString
(
"returncode"
)))
{
JSONArray
jaUrls
=
joAuthorizeResult
.
getJSONArray
(
"urls"
);
if
(
null
!=
jaUrls
&&
jaUrls
.
length
()
>
0
)
{
JSONObject
joUrl
=
jaUrls
.
getJSONObject
(
0
);
if
(
null
!=
joUrl
)
{
String
strPlayURL
=
joUrl
.
getString
(
"playurl"
);
}
}
}
}
catch
(
Exception
e
)
{
}
}
}
};
private
ITopdrawResultListener
onOrderListener
=
new
ITopdrawResultListener
()
{
@Override
public
void
onResult
(
int
i
,
String
s
,
Object
o
)
{
Log
.
d
(
TAG
,
"TopdrawSDK ordered:["
+
i
+
"]"
+
s
);
if
(
i
==
20
)
{
//authResult = true;
Log
.
d
(
TAG
,
"Order Success"
);
//WritableMap event = Arguments.createMap();
//event.putString("result","succeess");
//dispatchEvent("orderSuccess",event);
}
else
{
Log
.
d
(
TAG
,
"order failed"
);
@Override
public
void
onError
(
String
errorMsg
)
{
Log
.
d
(
TAG
,
"获取播放链接失败| "
+
errorMsg
);
}
// playCallback = null;
}
};
});
}
public
static
void
isExistApk
(
String
apkName
,
final
String
strJSCallBack
)
{
final
boolean
flag
=
PluginLoader
.
getInstance
().
isExistApk
(
apkName
);
...
...
@@ -156,6 +159,7 @@ public class TopdrawSDKWrapper {
}
pluginLoaded
=
true
;
final
String
packageName
=
apkName
;
// final String className = "com.orbbec.u3d.OrbbecActivity";
final
String
className
=
"org.cocos2dx.lua.AppActivity"
;
PluginLoader
.
getInstance
().
start
(
packageName
,
new
PluginLoader
.
OnResultListener
()
{
@Override
...
...
Please
register
or
sign in
to post a comment