提交 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 from:'config.gradle'
apply plugin: 'com.android.library' group 'com.tencent.vod.flutter'
version rootProject.ext.playerVersion version rootProject.ext.playerVersion
//
buildscript { //buildscript {
repositories { // repositories {
google() // google()
mavenCentral() // mavenCentral()
} // }
//
dependencies { // dependencies {
classpath 'com.android.tools.build:gradle:4.1.0' // classpath 'com.android.tools.build:gradle:4.1.0'
} // }
} //}
rootProject.allprojects { rootProject.allprojects {
repositories { repositories {
......
...@@ -34,13 +34,6 @@ public abstract class FTXVodPlayerRenderHost extends FTXBasePlayer implements FT ...@@ -34,13 +34,6 @@ public abstract class FTXVodPlayerRenderHost extends FTXBasePlayer implements FT
@Override @Override
public void setRenderView(FTXRenderCarrier textureView) { public void setRenderView(FTXRenderCarrier textureView) {
if (null != 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()); LiteavLog.i(TAG, "start bind Player:" + textureView + ", player:" + hashCode());
mTextureView = textureView; mTextureView = textureView;
textureView.bindPlayer(this); textureView.bindPlayer(this);
......
package com.tencent.vod.flutter.ui.render; package com.tencent.vod.flutter.ui.render;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
import android.os.Build;
import android.view.Surface; import android.view.Surface;
import android.view.TextureView; import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewParent; import android.view.ViewParent;
...@@ -49,10 +50,15 @@ public class FTXTextureView extends TextureView implements TextureView.SurfaceTe ...@@ -49,10 +50,15 @@ public class FTXTextureView extends TextureView implements TextureView.SurfaceTe
@Override @Override
public void bindPlayer(FTXPlayerRenderSurfaceHost surfaceHost) { public void bindPlayer(FTXPlayerRenderSurfaceHost surfaceHost) {
mPlayer = surfaceHost; if (surfaceHost != mPlayer) {
if (null != mSurface && null != surfaceHost) { mPlayer = surfaceHost;
LiteavLog.i(TAG, "bindPlayer suc,player: " + surfaceHost + ", view:" + hashCode()); if (null != mSurface && null != surfaceHost) {
surfaceHost.setSurface(mSurface); 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());
} }
} }
...@@ -83,7 +89,7 @@ public class FTXTextureView extends TextureView implements TextureView.SurfaceTe ...@@ -83,7 +89,7 @@ public class FTXTextureView extends TextureView implements TextureView.SurfaceTe
} }
private void updateSurfaceTexture(SurfaceTexture surfaceTexture) { private void updateSurfaceTexture(SurfaceTexture surfaceTexture) {
if (mSurfaceTexture != surfaceTexture || null != surfaceTexture) { if (mSurfaceTexture != surfaceTexture && null != surfaceTexture) {
LiteavLog.v(TAG, "surfaceTexture is updated:" + surfaceTexture); LiteavLog.v(TAG, "surfaceTexture is updated:" + surfaceTexture);
mSurfaceTexture = surfaceTexture; mSurfaceTexture = surfaceTexture;
mSurface = new Surface(surfaceTexture); mSurface = new Surface(surfaceTexture);
...@@ -124,11 +130,10 @@ public class FTXTextureView extends TextureView implements TextureView.SurfaceTe ...@@ -124,11 +130,10 @@ public class FTXTextureView extends TextureView implements TextureView.SurfaceTe
} }
mSurfaceTexture = null; mSurfaceTexture = null;
mSurface = null; mSurface = null;
return false; return true;
} }
@Override @Override
public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) { public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) {
} }
} }
plugins {
id "com.android.application"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties() def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties') def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) { if (localPropertiesFile.exists()) {
...@@ -6,11 +11,6 @@ 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') def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) { if (flutterVersionCode == null) {
flutterVersionCode = '1' flutterVersionCode = '1'
...@@ -21,9 +21,6 @@ if (flutterVersionName == null) { ...@@ -21,9 +21,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0' flutterVersionName = '1.0'
} }
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android { android {
compileSdk 34 compileSdk 34
......
buildscript { allprojects {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
}
}
rootProject.allprojects {
repositories { repositories {
google() google()
mavenCentral() 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") includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
def properties = new Properties()
assert localPropertiesFile.exists() repositories {
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } google()
mavenCentral()
gradlePluginPortal()
}
}
def flutterSdkPath = properties.getProperty("flutter.sdk") plugins {
assert flutterSdkPath != null, "flutter.sdk not set in local.properties" id "dev.flutter.flutter-plugin-loader" version "1.0.0"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 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 ...@@ -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.setLoop(true);
await _controller.enableHardwareDecode(enableHardware); await _controller.enableHardwareDecode(enableHardware);
await _controller.setConfig(FTXVodPlayConfig()); await _controller.setConfig(FTXVodPlayConfig());
...@@ -94,10 +83,6 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb ...@@ -94,10 +83,6 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
} else { } else {
await _controller.startVodPlay(_url); 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) { void _resizeVideo(Map<dynamic, dynamic> event) {
...@@ -155,7 +140,6 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb ...@@ -155,7 +140,6 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
), ),
body: SafeArea( body: SafeArea(
child: Container( child: Container(
//color: Colors.blueGrey,
child: Column( child: Column(
children: [ children: [
Container( Container(
......
...@@ -55,16 +55,14 @@ class TXPlayerVideoState extends State<TXPlayerVideo> { ...@@ -55,16 +55,14 @@ class TXPlayerVideoState extends State<TXPlayerVideo> {
if (defaultTargetPlatform == TargetPlatform.android) { if (defaultTargetPlatform == TargetPlatform.android) {
return IgnorePointer( return IgnorePointer(
ignoring: true, ignoring: true,
child: PlatformViewLink( child: AndroidView(
surfaceFactory: (context, controller) { viewType: _kFTXPlayerRenderViewType,
return AndroidViewSurface( layoutDirection: TextDirection.ltr,
controller: controller as AndroidViewController, creationParams: {_kFTXAndroidRenderTypeKey: widget.renderViewType.index},
gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{}, creationParamsCodec: const StandardMessageCodec(),
hitTestBehavior: PlatformViewHitTestBehavior.opaque, onPlatformViewCreated: _onCreateAndroidView,
); gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
}, ),
onCreatePlatformView: _onCreateAndroidView,
viewType: _kFTXPlayerRenderViewType),
); );
} else if (defaultTargetPlatform == TargetPlatform.iOS) { } else if (defaultTargetPlatform == TargetPlatform.iOS) {
return IgnorePointer( return IgnorePointer(
...@@ -82,25 +80,13 @@ class TXPlayerVideoState extends State<TXPlayerVideo> { ...@@ -82,25 +80,13 @@ class TXPlayerVideoState extends State<TXPlayerVideo> {
} }
} }
PlatformViewController _onCreateAndroidView(PlatformViewCreationParams params) { void _onCreateAndroidView(int id) {
if (_viewIdCompleter.isCompleted) { if (_viewIdCompleter.isCompleted) {
_viewIdCompleter = Completer(); _viewIdCompleter = Completer();
} }
_viewId = params.id; _viewId = id;
_viewIdCompleter.complete(params.id); _viewIdCompleter.complete(id);
_setPlayerView(params.id); _setPlayerView(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();
} }
Future<void> _setPlayerView(int viewId) async { Future<void> _setPlayerView(int viewId) async {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论