Browse Source

调通腾讯短视频SDK

tencentVideo
zmt 3 years ago
parent
commit
f2e03bfd42
  1. 1
      .idea/compiler.xml
  2. 1
      .idea/gradle.xml
  3. 2
      app/build.gradle
  4. 2
      app/proguard-rules.pro
  5. 2
      app/src/main/assets/apps/__UNI__2B9497D/www/app-service.js
  6. 2
      app/src/main/assets/apps/__UNI__2B9497D/www/app-view.js
  7. 9
      app/src/main/assets/dcloud_uniplugins.json
  8. 2
      settings.gradle
  9. 23
      uniappWWW/unipluginDemo/pages/sample/ext-module-vue.vue
  10. 1
      uniplugin_module_TXLiveAVSDK/.gitignore
  11. 55
      uniplugin_module_TXLiveAVSDK/build.gradle
  12. 21
      uniplugin_module_TXLiveAVSDK/proguard-rules.pro
  13. 12
      uniplugin_module_TXLiveAVSDK/src/main/AndroidManifest.xml
  14. 92
      uniplugin_module_TXLiveAVSDK/src/main/java/io/dcloud/txLive/MainActivity.java
  15. 35
      uniplugin_module_TXLiveAVSDK/src/main/java/io/dcloud/txLive/NativePageActivity.java
  16. 139
      uniplugin_module_TXLiveAVSDK/src/main/java/io/dcloud/txLive/TXLiveModule.java
  17. 84
      uniplugin_module_TXLiveAVSDK/src/main/res/layout/activity_main.xml
  18. 3
      uniplugin_module_TXLiveAVSDK/src/main/res/values/strings.xml

1
.idea/compiler.xml

@ -11,6 +11,7 @@
<module name="UniPlugin-Hello-AS.uniplugin_component" target="1.8" />
<module name="UniPlugin-Hello-AS.uniplugin_module" target="1.8" />
<module name="UniPlugin-Hello-AS.uniplugin_module_ox" target="1.8" />
<module name="UniPlugin-Hello-AS.uniplugin_module_TXLiveAVSDK" target="1.8" />
<module name="UniPlugin-Hello-AS.uniplugin_richalert" target="1.8" />
<module name="UniPlugin-Hello-AS.zmt_module" target="1.8" />
</bytecodeTargetLevel>

1
.idea/gradle.xml

@ -19,6 +19,7 @@
<option value="$PROJECT_DIR$/registerlibrary" />
<option value="$PROJECT_DIR$/uniplugin_component" />
<option value="$PROJECT_DIR$/uniplugin_module" />
<option value="$PROJECT_DIR$/uniplugin_module_TXLiveAVSDK" />
<option value="$PROJECT_DIR$/uniplugin_module_ox" />
<option value="$PROJECT_DIR$/uniplugin_richalert" />
<option value="$PROJECT_DIR$/zmt_module" />

2
app/build.gradle

@ -101,6 +101,8 @@ dependencies {
implementation project(path: ':registerlibrary')
implementation project(path: ':facelibrary')
implementation project(path: ':gatelibrary')
implementation project(path: ':uniplugin_module_TXLiveAVSDK')
}

2
app/proguard-rules.pro

@ -34,6 +34,8 @@
-keep class io.dcloud.nineoldandroids.** {*;}
-keep class vi.com.gdi.** {*;}
-keep class androidx.** {*;}
-keep class com.tencent.** { *; }
-dontwarn pl.droidsonroids.gif.**
-keepclasseswithmembers class * extends io.dcloud.js.geolocation.GeoManagerBase {

2
app/src/main/assets/apps/__UNI__2B9497D/www/app-service.js
File diff suppressed because it is too large
View File

2
app/src/main/assets/apps/__UNI__2B9497D/www/app-view.js
File diff suppressed because it is too large
View File

9
app/src/main/assets/dcloud_uniplugins.json

@ -48,6 +48,15 @@
]
},
{
"plugins": [
{
"type": "module",
"name": "TXLiveModule",
"class": "io.dcloud.txLive.TXLiveModule"
}
]
},
{
"hooksClass": "com.appdev.face_module.FaceAppProxy",
"plugins": [
{

2
settings.gradle

@ -11,3 +11,5 @@ include ':uniplugin_richalert'
include ':registerlibrary'
include ':gatelibrary'
include ':facelibrary'
include ':uniplugin_module_TXLiveAVSDK'

23
uniappWWW/unipluginDemo/pages/sample/ext-module-vue.vue

@ -25,6 +25,8 @@
<button class="btn" type="primary" @click="testAsyncFunc">uniplugin_module testAsyncFunc</button>
<button class="btn" type="primary" @click="testSyncFunc">uniplugin_module testSyncFunc</button>
<button class="btn" type="primary" @click="liveInit">[短视频SDK测试]</button>
<button class="btn" type="primary" @click="gotoLiveNativePage()">[短视频gotoLiveNativePage]</button>
</div>
</template>
@ -36,6 +38,9 @@
var testModule = uni.requireNativePlugin("TestModule") //uniplugin_module
var uniplugin_module_ox = uni.requireNativePlugin("uniplugin_module_ox") //uniplugin_module_ox
var faceModule = uni.requireNativePlugin("Face-Module") //SDK, face_module
var TXLiveModule = uni.requireNativePlugin("TXLiveModule") //SDK, TXLiveModule
const modal = uni.requireNativePlugin('modal');
// #endif
@ -96,6 +101,21 @@
});
// #endif
},
liveInit() {
this.log("执行TXLiveModule.liveInit");
//
TXLiveModule.liveInit({
'name': 'unimp',
'age': 1
},
(ret) => {
modal.toast({
message: ret,
duration: 1.5
});
this.log(JSON.stringify(ret))
})
},
//SDK,,(android faceClass)
faceAsyncFunc() {
this.log("执行faceModule.faceAsyncFunc");
@ -220,6 +240,9 @@
},
gotoNativePage() {
testModule.gotoNativePage();
},
gotoLiveNativePage(){
TXLiveModule.gotoNativePage();
}
}
}

1
uniplugin_module_TXLiveAVSDK/.gitignore

@ -0,0 +1 @@
/build

55
uniplugin_module_TXLiveAVSDK/build.gradle

@ -0,0 +1,55 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
ndk {
abiFilters "armeabi", "armeabi-v7a"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation project(path: ':uniplugin_module')
compileOnly fileTree(dir: 'libs', include: ['*.jar'])
compileOnly fileTree(dir: '../app/libs', include: ['uniapp-v8-release.aar'])
compileOnly 'androidx.recyclerview:recyclerview:1.0.0'
compileOnly 'androidx.legacy:legacy-support-v4:1.0.0'
compileOnly 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.alibaba:fastjson:1.1.46.android'
implementation 'com.facebook.fresco:fresco:1.13.0'
/*implementation 'com.android.support:appcompat-v7:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'*/
// mqtt
// implementation 'com.tencent.iot.hub:hub-device-android:3.3.5'
//liveSDK
implementation 'com.tencent.liteav:LiteAVSDK_UGC:latest.release'
}

21
uniplugin_module_TXLiveAVSDK/proguard-rules.pro

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

12
uniplugin_module_TXLiveAVSDK/src/main/AndroidManifest.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uni.dcloud.io.uniplugin_module">
<application>
<activity android:name="io.dcloud.uniplugin.MainActivity"></activity>
<activity
android:name="io.dcloud.uniplugin.NativePageActivity"
android:theme="@android:style/Theme.DeviceDefault.Light.NoActionBar" />
</application>
</manifest>

92
uniplugin_module_TXLiveAVSDK/src/main/java/io/dcloud/txLive/MainActivity.java

@ -0,0 +1,92 @@
package io.dcloud.uniplugin;
import android.app.Activity;
import android.content.Context;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import uni.dcloud.io.uniplugin_module.R;
public class MainActivity extends Activity {
private Context mContext;
// Default testing parameters
private String mBrokerURL = null; //传入null即使用腾讯云物联网通信默认地址 "${ProductId}.iotcloud.tencentdevices.com:8883" https://cloud.tencent.com/document/product/634/32546
private String mProductID = "BE8N7UZ7OF";//
private String mDevName = "pad20220105";//BuildConfig.DEVICE_NAME;
private String mDevPSK = "7udrYcfTVThbzdMlLT9fHQ==";//BuildConfig.DEVICE_PSK; //若使用证书验证设为null
private String mSubProductID = null;//BuildConfig.SUB_PRODUCT_ID; // If you wont test gateway, let this to be null
private String mSubDevName = null;//BuildConfig.SUB_DEV_NAME;
private String mSubDevPsk = null;//BuildConfig.SUB_DEVICE_PSK;
private String mTestTopic = "BE8N7UZ7OF/pad20220105/data";//BuildConfig.TEST_TOPIC; // productID/DeviceName/TopicName
private String mDevCertName = null;//"YOUR_DEVICE_NAME_cert.crt";
private String mDevKeyName = null;//"YOUR_DEVICE_NAME_private.key";
private String mProductKey = null;//BuildConfig.PRODUCT_KEY; // Used for dynamic register
private String mDevCert = ""; // Cert String
private String mDevPriv = ""; // Priv String
private static final String TAG = "TXMQTT";
private TextView mLogInfoText;
private volatile boolean mIsConnected; //是否连接
private Button statusBtn, connectBtn, disconnectBtn, subscribeBtn, unSubscribeBtn, publishBtn, clearBtn;
/**日志保存的路径*/
private final static String mLogPath = Environment.getExternalStorageDirectory().getPath() + "/tencent/";
private AtomicInteger temperature = new AtomicInteger(0);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContext = this;
mLogInfoText =(TextView)findViewById(R.id.tv1);
statusBtn = (Button)findViewById(R.id.btn1);
connectBtn = (Button)findViewById(R.id.btn2);
disconnectBtn = (Button)findViewById(R.id.btn3);
subscribeBtn = (Button)findViewById(R.id.btn4);
unSubscribeBtn = (Button)findViewById(R.id.btn5);
publishBtn = (Button)findViewById(R.id.btn6);
clearBtn = (Button)findViewById(R.id.btn7);
}
}

35
uniplugin_module_TXLiveAVSDK/src/main/java/io/dcloud/txLive/NativePageActivity.java

@ -0,0 +1,35 @@
package io.dcloud.txLive;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.TextView;
import static io.dcloud.txLive.TXLiveModule.REQUEST_CODE;
public class NativePageActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FrameLayout rootView = new FrameLayout(this);
TextView textView = new TextView(this);
textView.setTextColor(Color.BLACK);
textView.setTextSize(30);
textView.setText("点击我将返回 并携带参数返回");
rootView.addView(textView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300));
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.putExtra("respond", "我是原生页面");
setResult(REQUEST_CODE, intent);
finish();
}
});
setContentView(rootView);
}
}

139
uniplugin_module_TXLiveAVSDK/src/main/java/io/dcloud/txLive/TXLiveModule.java

@ -0,0 +1,139 @@
package io.dcloud.txLive;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.alibaba.fastjson.JSONObject;
import com.tencent.rtmp.TXLiveBase;
import com.tencent.ugc.TXUGCBase;
import com.tencent.ugc.TXVideoEditConstants;
import com.tencent.ugc.TXVideoJoiner;
import java.util.List;
import io.dcloud.feature.uniapp.annotation.UniJSMethod;
import io.dcloud.feature.uniapp.bridge.UniJSCallback;
import io.dcloud.feature.uniapp.common.UniModule;
public class TXLiveModule extends UniModule {
String TAG = "TXLiveModule";
public static int REQUEST_CODE = 1000;
public Context mcontext = this.mUniSDKInstance.getContext();
//run ui thread
@UniJSMethod(uiThread = true)
public void liveInit(JSONObject options, final UniJSCallback callback) {
Log.e(TAG, "liveInit--"+options);
if(callback != null) {
JSONObject data = new JSONObject();
String sdkver = TXLiveBase.getSDKVersionStr();
data.put("liveSDKVersion", sdkver);
Log.d("liteavsdk", "liteav sdk version is : " + sdkver);
callback.invokeAndKeepAlive(data); //回调liveSDK版本信息
String ugcLicenceUrl = "https://license.vod2.myqcloud.com/license/v2/1251209212_1/v_cube.license"; // 填入您从控制台申请的 licence url
String ugcKey = "9de447b3bc9a10f79fc5e5bee7f1df2a"; // 填入您从控制台申请的 licence key
TXUGCBase.setListener(new TXUGCBase.TXUGCBaseListener() {
@Override
public void onLicenceLoaded(int result, String reason) {
super.onLicenceLoaded(result, reason);
JSONObject setListenerData = new JSONObject();
setListenerData.put("result", result);
setListenerData.put("reason", reason);
callback.invokeAndKeepAlive(setListenerData); //回调本次授权结果
}
});
TXUGCBase.getInstance().setLicence(this.mUniSDKInstance.getContext(), ugcLicenceUrl, ugcKey);
TXLiveBase.setConsoleEnabled(true); //设置控制台打印log
TXLiveBase.setLogLevel(1); //0 - 6 输出log等级
}
}
@UniJSMethod(uiThread = true)
public void getLicenceInfo(JSONObject options, final UniJSCallback callback) {
String licenceInfo = TXUGCBase.getInstance().getLicenceInfo(mUniSDKInstance.getContext());
JSONObject licenceInfoData = new JSONObject();
licenceInfoData.put("licenceInfo", licenceInfo);
callback.invokeAndKeepAlive(licenceInfoData); //回调授权信息
}
@UniJSMethod(uiThread = true)
public void joinerVideo(JSONObject options, final UniJSCallback callback) {
List<String> mVideoSourceList = null;
String mVideoOutputPath = null;
String mList = options.getString("videoList");
//准备预览 View
TXVideoEditConstants.TXPreviewParam param = new TXVideoEditConstants.TXPreviewParam();
// param.videoView = mVideoView;
param.renderMode = TXVideoEditConstants.PREVIEW_RENDER_MODE_FILL_EDGE;
// 创建 TXUGCJoiner 对象并设置预览 view
TXVideoJoiner mTXVideoJoiner = new TXVideoJoiner(mcontext);
// mTXVideoJoiner.setTXVideoPreviewListener((TXVideoJoiner.TXVideoPreviewListener) mcontext); //设置预览监听
mTXVideoJoiner.initWithPreview(param);
// 设置待拼接的视频文件组 mVideoSourceList也就是第一步中选择的若干个文件
mTXVideoJoiner.setVideoPathList(mVideoSourceList);
//预览效果满意后调用生成接口即可生成合成后的文件
mTXVideoJoiner.setVideoJoinerListener(new TXVideoJoiner.TXVideoJoinerListener() { //设置拼接监听
@Override
public void onJoinProgress(float v) {
Log.e(TAG+" onJoinProgress",Float.toString(v));
}
@Override
public void onJoinComplete(TXVideoEditConstants.TXJoinerResult txJoinerResult) {
Log.e(TAG+" onJoinComplete",txJoinerResult.toString());
JSONObject JoinerData = new JSONObject();
JoinerData.put("code", "1");
callback.invokeAndKeepAlive(JoinerData); //回调授权信息
}
});
mTXVideoJoiner.joinVideo(TXVideoEditConstants.VIDEO_COMPRESSED_540P, mVideoOutputPath);
}
//run JS thread
@UniJSMethod (uiThread = false)
public JSONObject testSyncFunc(){
JSONObject data = new JSONObject();
data.put("code", "success uniplugin_module");
return data;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == REQUEST_CODE && data.hasExtra("respond")) {
Log.e("TestModule", "原生页面返回----"+data.getStringExtra("respond"));
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
@UniJSMethod (uiThread = true)
public void gotoNativePage(){
if(mUniSDKInstance != null && mUniSDKInstance.getContext() instanceof Activity) {
// Intent intent = new Intent(mUniSDKInstance.getContext(), io.dcloud.uniplugin.MainActivity.class);
Intent intent = new Intent(mUniSDKInstance.getContext(), NativePageActivity.class);
((Activity)mUniSDKInstance.getContext()).startActivityForResult(intent, REQUEST_CODE);
}
}
}

84
uniplugin_module_TXLiveAVSDK/src/main/res/layout/activity_main.xml

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="io.dcloud.uniplugin.MainActivity">
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="连接状态" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="连接MQTT" />
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="断开连接MQTT" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btn4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="订阅主题" />
<Button
android:id="@+id/btn5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="取消订阅主题" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/btn6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发布主题" />
<Button
android:id="@+id/btn7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="清空日志" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="日志输出" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ScrollView>
</LinearLayout>

3
uniplugin_module_TXLiveAVSDK/src/main/res/values/strings.xml

@ -0,0 +1,3 @@
<resources>
<string name="app_name">uniplugin_richAlert</string>
</resources>
Loading…
Cancel
Save