18 changed files with 484 additions and 2 deletions
-
1.idea/compiler.xml
-
1.idea/gradle.xml
-
2app/build.gradle
-
2app/proguard-rules.pro
-
2app/src/main/assets/apps/__UNI__2B9497D/www/app-service.js
-
2app/src/main/assets/apps/__UNI__2B9497D/www/app-view.js
-
9app/src/main/assets/dcloud_uniplugins.json
-
2settings.gradle
-
23uniappWWW/unipluginDemo/pages/sample/ext-module-vue.vue
-
1uniplugin_module_TXLiveAVSDK/.gitignore
-
55uniplugin_module_TXLiveAVSDK/build.gradle
-
21uniplugin_module_TXLiveAVSDK/proguard-rules.pro
-
12uniplugin_module_TXLiveAVSDK/src/main/AndroidManifest.xml
-
92uniplugin_module_TXLiveAVSDK/src/main/java/io/dcloud/txLive/MainActivity.java
-
35uniplugin_module_TXLiveAVSDK/src/main/java/io/dcloud/txLive/NativePageActivity.java
-
139uniplugin_module_TXLiveAVSDK/src/main/java/io/dcloud/txLive/TXLiveModule.java
-
84uniplugin_module_TXLiveAVSDK/src/main/res/layout/activity_main.xml
-
3uniplugin_module_TXLiveAVSDK/src/main/res/values/strings.xml
2
app/src/main/assets/apps/__UNI__2B9497D/www/app-service.js
File diff suppressed because it is too large
View File
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
File diff suppressed because it is too large
View File
@ -0,0 +1 @@ |
|||||
|
/build |
@ -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' |
||||
|
} |
@ -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 |
@ -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> |
@ -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); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -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); |
||||
|
} |
||||
|
} |
@ -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); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -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> |
@ -0,0 +1,3 @@ |
|||||
|
<resources> |
||||
|
<string name="app_name">uniplugin_richAlert</string> |
||||
|
</resources> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue