Skip to content

Commit 0608fc6

Browse files
xanderzhao-zbAbySwifter
authored andcommitted
【Android】Version 4.2.0 add tceffectplayerkit module
1 parent e9507f9 commit 0608fc6

11 files changed

Lines changed: 279 additions & 2 deletions

File tree

.DS_Store

2 KB
Binary file not shown.

tceffectplayerkit/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties
16+
.kotlin

tceffectplayerkit/build.gradle

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
4+
android {
5+
compileSdk 34
6+
namespace "com.tencent.effect.tceffectplayerkit"
7+
8+
defaultConfig {
9+
minSdkVersion 21
10+
11+
consumerProguardFiles "consumer-rules.pro"
12+
}
13+
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
18+
}
19+
debug {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
25+
def javaVersion = JavaVersion.VERSION_1_8
26+
def gradleMajorVersion = gradle.gradleVersion.tokenize('.')[0].toInteger()
27+
if (gradleMajorVersion >= 8) {
28+
javaVersion = JavaVersion.VERSION_17
29+
}
30+
31+
compileOptions {
32+
sourceCompatibility javaVersion
33+
targetCompatibility javaVersion
34+
}
35+
kotlinOptions {
36+
jvmTarget = javaVersion
37+
}
38+
}
39+
40+
dependencies {
41+
api 'com.google.android.material:material:1.12.0'
42+
api("com.tencent.mediacloud:TCEffectPlayer:3.0.0.250") {
43+
exclude group: "com.tencent.mediacloud", module: "TCXMagicAuth"
44+
}
45+
46+
api rootProject.getChildProjects().containsKey("tuicore") ? project(':tuicore') : "com.tencent.liteav.tuikit:tuicore:8.8.7357"
47+
}

tceffectplayerkit/consumer-rules.pro

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<application>
4+
5+
<provider
6+
android:name="com.tencent.effect.tceffectplayerkit.core.TUIEffectPlayerProvider"
7+
android:authorities="${applicationId}.TUIEffectPlayerProvider"
8+
android:enabled="true"
9+
android:exported="false" />
10+
11+
</application>
12+
</manifest>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.tencent.effect.tceffectplayerkit;
2+
3+
public interface Constants {
4+
String KEY_EXTENSION_NAME = "TUIEffectPlayerExtension";
5+
String KEY_SERVICE_NAME = "TUIEffectPlayerService";
6+
String KEY_GET_VIEW = "TCEffectAnimView";
7+
String KEY_METHOD_SET_LICENSE = "setLicense";
8+
String KEY_METHOD_START_PLAY = "startPlay";
9+
String KEY_METHOD_STOP_PLAY = "stopPlay";
10+
String KEY_PARAM_PLAY_URL = "playUrl";
11+
String KEY_PARAM_CONTEXT = "context";
12+
String KEY_PARAM_VIEW = "view";
13+
String KEY_PARAM_CLEAR_LAST_FRAME = "clearLastFrame";
14+
String KEY_PARAM_LICENSE_URL = "licenseUrl";
15+
String KEY_PARAM_LICENSE_KEY = "licenseKey";
16+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.tencent.effect.tceffectplayerkit.core;
2+
3+
import android.content.Context;
4+
5+
import com.tencent.effect.tceffectplayerkit.Constants;
6+
import com.tencent.qcloud.tuicore.interfaces.ITUIExtension;
7+
import com.tencent.qcloud.tuicore.interfaces.TUIExtensionInfo;
8+
import com.tencent.tcmediax.tceffectplayer.api.TCEffectAnimView;
9+
import com.tencent.tcmediax.tceffectplayer.api.TCEffectPlayerConstant;
10+
11+
import java.util.Collections;
12+
import java.util.HashMap;
13+
import java.util.List;
14+
import java.util.Map;
15+
16+
public class TUIEffectPlayerExtension implements ITUIExtension {
17+
18+
@Override
19+
public List<TUIExtensionInfo> onGetExtension(String extensionID, Map<String, Object> param) {
20+
HashMap<String, Object> hashMap = new HashMap<>();
21+
if (param != null && Constants.KEY_EXTENSION_NAME.equals(extensionID)) {
22+
Context context = (Context) param.get(Constants.KEY_PARAM_CONTEXT);
23+
if (param.containsKey(Constants.KEY_GET_VIEW)) {
24+
TCEffectAnimView animView = new TCEffectAnimView(context);
25+
animView.setScaleType(TCEffectPlayerConstant.ScaleType.FIT_XY);
26+
hashMap.put(Constants.KEY_GET_VIEW, animView);
27+
TUIExtensionInfo info = new TUIExtensionInfo();
28+
info.setData(hashMap);
29+
return Collections.singletonList(info);
30+
}
31+
}
32+
return null;
33+
}
34+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.tencent.effect.tceffectplayerkit.core;
2+
3+
import android.content.ContentProvider;
4+
import android.content.ContentValues;
5+
import android.database.Cursor;
6+
import android.net.Uri;
7+
import android.util.Log;
8+
9+
import com.tencent.effect.tceffectplayerkit.Constants;
10+
import com.tencent.qcloud.tuicore.TUICore;
11+
12+
public final class TUIEffectPlayerProvider extends ContentProvider {
13+
private static final String TAG = "TUIEffectPlayerProvider";
14+
15+
@Override
16+
public boolean onCreate() {
17+
Log.d(TAG, "TUIEffectPlayerProvider onCreate");
18+
TUICore.registerExtension(Constants.KEY_EXTENSION_NAME, new TUIEffectPlayerExtension());
19+
TUICore.registerService(Constants.KEY_SERVICE_NAME, new TUIEffectPlayerService());
20+
return false;
21+
}
22+
23+
@Override
24+
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
25+
return null;
26+
}
27+
28+
29+
@Override
30+
public String getType(Uri uri) {
31+
return null;
32+
}
33+
34+
35+
@Override
36+
public Uri insert(Uri uri, ContentValues values) {
37+
return null;
38+
}
39+
40+
@Override
41+
public int delete(Uri uri, String selection, String[] selectionArgs) {
42+
return 0;
43+
}
44+
45+
@Override
46+
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
47+
return 0;
48+
}
49+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package com.tencent.effect.tceffectplayerkit.core;
2+
3+
import android.content.Context;
4+
import android.os.Bundle;
5+
import android.text.TextUtils;
6+
7+
import com.tencent.effect.tceffectplayerkit.Constants;
8+
import com.tencent.qcloud.tuicore.interfaces.ITUIService;
9+
import com.tencent.qcloud.tuicore.interfaces.TUIServiceCallback;
10+
import com.tencent.tcmediax.api.TCMediaXBase;
11+
import com.tencent.tcmediax.tceffectplayer.api.TCEffectAnimView;
12+
import com.tencent.tcmediax.tceffectplayer.api.TCEffectPlayerConstant;
13+
14+
import java.util.Map;
15+
16+
public class TUIEffectPlayerService implements ITUIService {
17+
18+
@Override
19+
public Object onCall(String method, Map<String, Object> param, TUIServiceCallback callback) {
20+
if (param != null && TextUtils.equals(Constants.KEY_METHOD_START_PLAY, method)) {
21+
String url = (String) param.get(Constants.KEY_PARAM_PLAY_URL);
22+
Object view = param.get(Constants.KEY_PARAM_VIEW);
23+
if (view instanceof TCEffectAnimView) {
24+
TCEffectAnimView animView = (TCEffectAnimView) view;
25+
animView.setScaleType(TCEffectPlayerConstant.ScaleType.CENTER_CROP);
26+
animView.setPlayListener(new AnimPlayListener(callback));
27+
animView.startPlay(url);
28+
}
29+
} else if (param != null && TextUtils.equals(Constants.KEY_METHOD_STOP_PLAY, method)) {
30+
Object view = param.get(Constants.KEY_PARAM_VIEW);
31+
Boolean clearLastFrame = (Boolean) param.get(Constants.KEY_PARAM_CLEAR_LAST_FRAME);
32+
if (view instanceof TCEffectAnimView) {
33+
TCEffectAnimView animView = (TCEffectAnimView) view;
34+
animView.setPlayListener(null);
35+
animView.stopPlay(Boolean.TRUE.equals(clearLastFrame));
36+
}
37+
} else if (param != null && TextUtils.equals(Constants.KEY_METHOD_SET_LICENSE, method)) {
38+
String url = (String) param.get(Constants.KEY_PARAM_LICENSE_URL);
39+
String key = (String) param.get(Constants.KEY_PARAM_LICENSE_KEY);
40+
Context context = (Context) param.get(Constants.KEY_PARAM_CONTEXT);
41+
TCMediaXBase.getInstance().setLicense(context, url, key, (i, s) -> {
42+
if (callback != null) {
43+
callback.onServiceCallback(i, s, null);
44+
}
45+
});
46+
}
47+
return null;
48+
}
49+
50+
private static final class AnimPlayListener implements TCEffectAnimView.IAnimPlayListener {
51+
52+
private final TUIServiceCallback mCallback;
53+
54+
public AnimPlayListener(TUIServiceCallback callback) {
55+
mCallback = callback;
56+
}
57+
58+
@Override
59+
public void onPlayStart() {
60+
61+
}
62+
63+
@Override
64+
public void onPlayEnd() {
65+
if (mCallback != null) {
66+
mCallback.onServiceCallback(0, "", null);
67+
}
68+
}
69+
70+
@Override
71+
public void onPlayError(int i) {
72+
if (mCallback != null) {
73+
mCallback.onServiceCallback(i, "", null);
74+
}
75+
}
76+
77+
@Override
78+
public void onPlayEvent(int i, Bundle bundle) {
79+
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)