提交 485e1cd5 authored 作者: kongdywang's avatar kongdywang

1. Compatible with Flutter 3.29 version

2. Fix known issues
上级 4d51c9c0
group 'com.tencent.vod.flutter'
plugins {
id "com.android.library" // ✅ 声明式插件语法
}
apply from:'config.gradle'
apply plugin: 'com.android.library'
group 'com.tencent.vod.flutter'
version rootProject.ext.playerVersion
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
//
//buildscript {
// repositories {
// google()
// mavenCentral()
// }
//
// dependencies {
// classpath 'com.android.tools.build:gradle:4.1.0'
// }
//}
rootProject.allprojects {
repositories {
......
......@@ -34,13 +34,6 @@ public abstract class FTXVodPlayerRenderHost extends FTXBasePlayer implements FT
@Override
public void setRenderView(FTXRenderCarrier textureView) {
if (null != textureView) {
// if (mTextureView != textureView) {
// removeRenderView();
// mTextureView = textureView;
// textureView.bindPlayer(this);
// } else {
// textureView.bindPlayer(this);
// }
LiteavLog.i(TAG, "start bind Player:" + textureView + ", player:" + hashCode());
mTextureView = textureView;
textureView.bindPlayer(this);
......
package com.tencent.vod.flutter.ui.render;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.SurfaceTexture;
import android.os.Build;
import android.view.Surface;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
......@@ -49,11 +50,16 @@ public class FTXTextureView extends TextureView implements TextureView.SurfaceTe
@Override
public void bindPlayer(FTXPlayerRenderSurfaceHost surfaceHost) {
if (surfaceHost != mPlayer) {
mPlayer = surfaceHost;
if (null != mSurface && null != surfaceHost) {
LiteavLog.i(TAG, "bindPlayer suc,player: " + surfaceHost + ", view:" + hashCode());
surfaceHost.setSurface(mSurface);
}
} else {
LiteavLog.w(TAG, "bindPlayer interrupt ,player: " + surfaceHost + " is equal before, view:"
+ hashCode());
}
}
@Override
......@@ -83,7 +89,7 @@ public class FTXTextureView extends TextureView implements TextureView.SurfaceTe
}
private void updateSurfaceTexture(SurfaceTexture surfaceTexture) {
if (mSurfaceTexture != surfaceTexture || null != surfaceTexture) {
if (mSurfaceTexture != surfaceTexture && null != surfaceTexture) {
LiteavLog.v(TAG, "surfaceTexture is updated:" + surfaceTexture);
mSurfaceTexture = surfaceTexture;
mSurface = new Surface(surfaceTexture);
......@@ -124,11 +130,10 @@ public class FTXTextureView extends TextureView implements TextureView.SurfaceTe
}
mSurfaceTexture = null;
mSurface = null;
return false;
return true;
}
@Override
public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) {
}
}
plugins {
id "com.android.application"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
......@@ -6,11 +11,6 @@ if (localPropertiesFile.exists()) {
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
......@@ -21,9 +21,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdk 34
......
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
}
}
rootProject.allprojects {
allprojects {
repositories {
google()
mavenCentral()
......
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.2.0" apply false
// id "org.jetbrains.kotlin.android" version "{kotlinVersion}" apply false
}
include ":app"
\ No newline at end of file
......@@ -71,17 +71,6 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
}
});
playNetEventSubscription = _controller.onPlayerNetStatusBroadcast.listen((event) async {
// Subscribe to status changes
double w = (event[TXVodNetEvent.NET_STATUS_VIDEO_WIDTH]).toDouble();
double h = (event[TXVodNetEvent.NET_STATUS_VIDEO_HEIGHT]).toDouble();
if (w > 0 && h > 0) {
setState(() {
_aspectRatio = 1.0 * w / h;
});
}
});
await _controller.setLoop(true);
await _controller.enableHardwareDecode(enableHardware);
await _controller.setConfig(FTXVodPlayConfig());
......@@ -94,10 +83,6 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
} else {
await _controller.startVodPlay(_url);
}
TXPlayerDrmBuilder builder = TXPlayerDrmBuilder("https://widevine.drm.vod-qcloud.com/widevine/getlicense/v2?drmToken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9~eyJ0eXBlIjoiRHJtVG9rZW4iLCJhcHBJZCI6MTUwMDAzMzc4NiwiZmlsZUlkIjoiMTM5Nzc1Nzg5MTA1OTU0NzE3NiIsImN1cnJlbnRUaW1lU3RhbXAiOjAsImV4cGlyZVRpbWVTdGFtcCI6MTczNTgzMDAwMCwicmFuZG9tIjowLCJvdmVybGF5S2V5IjoiIiwib3ZlcmxheUl2IjoiIiwiY2lwaGVyZWRPdmVybGF5S2V5IjoiIiwiY2lwaGVyZWRPdmVybGF5SXYiOiIiLCJrZXlJZCI6MSwic3RyaWN0TW9kZSI6MCwicGVyc2lzdGVudCI6IiIsInJlbnRhbER1cmF0aW9uIjowLCJmb3JjZUwxVHJhY2tUeXBlcyI6bnVsbH0~PKD-JRK2W8RfFJFqEpEq7pr3a8O9xQBWfysRiBHDYgE"
, "https://1500033786.vod-qcloud.com/184dff4avodtranshk1500033786/c4c7fcda1397757891059547176/adp.13.m3u8?t=6776a9f0&rlimit=10&us=ghaoreutqarlk&sign=979492f2bd330520e8ebb2225ff4e472");
// _controller.start
}
void _resizeVideo(Map<dynamic, dynamic> event) {
......@@ -155,7 +140,6 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
),
body: SafeArea(
child: Container(
//color: Colors.blueGrey,
child: Column(
children: [
Container(
......
......@@ -55,16 +55,14 @@ class TXPlayerVideoState extends State<TXPlayerVideo> {
if (defaultTargetPlatform == TargetPlatform.android) {
return IgnorePointer(
ignoring: true,
child: PlatformViewLink(
surfaceFactory: (context, controller) {
return AndroidViewSurface(
controller: controller as AndroidViewController,
child: AndroidView(
viewType: _kFTXPlayerRenderViewType,
layoutDirection: TextDirection.ltr,
creationParams: {_kFTXAndroidRenderTypeKey: widget.renderViewType.index},
creationParamsCodec: const StandardMessageCodec(),
onPlatformViewCreated: _onCreateAndroidView,
gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
);
},
onCreatePlatformView: _onCreateAndroidView,
viewType: _kFTXPlayerRenderViewType),
),
);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
return IgnorePointer(
......@@ -82,25 +80,13 @@ class TXPlayerVideoState extends State<TXPlayerVideo> {
}
}
PlatformViewController _onCreateAndroidView(PlatformViewCreationParams params) {
void _onCreateAndroidView(int id) {
if (_viewIdCompleter.isCompleted) {
_viewIdCompleter = Completer();
}
_viewId = params.id;
_viewIdCompleter.complete(params.id);
_setPlayerView(params.id);
return PlatformViewsService.initSurfaceAndroidView(
id: params.id,
viewType: _kFTXPlayerRenderViewType,
layoutDirection: TextDirection.ltr,
creationParams: {_kFTXAndroidRenderTypeKey : widget.renderViewType.index},
creationParamsCodec: const StandardMessageCodec(),
onFocus: () {
params.onFocusChanged(true);
},
)
..addOnPlatformViewCreatedListener(params.onPlatformViewCreated)
..create();
_viewId = id;
_viewIdCompleter.complete(id);
_setPlayerView(id);
}
Future<void> _setPlayerView(int viewId) async {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论