Browse Source

nt_android 适配

Melon 1 year ago
parent
commit
2984db3c0e

+ 1 - 1
.flutter-plugins

@@ -1,5 +1,5 @@
 # This is a generated file; do not edit or check into version control.
-daniulive=C:\\Users\\18651\\AppData\\Local\\Pub\\Cache\\git\\fis_plugin_daniu-d2d5718dad770607567acc8825e77b65b29fa4cb\\
+daniulive=C:\\Users\\18651\\AppData\\Local\\Pub\\Cache\\git\\fis_plugin_daniu-3a0e9c0980fdba1431afcb3f6838e0a66d753d0f\\
 image_crop_plus=C:\\Users\\18651\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\image_crop_plus-0.6.1\\
 path_provider=C:\\Users\\18651\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\path_provider-2.0.2\\
 path_provider_linux=C:\\Users\\18651\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\path_provider_linux-2.1.8\\

File diff suppressed because it is too large
+ 0 - 0
.flutter-plugins-dependencies


+ 2 - 2
example/pubspec.lock

@@ -89,8 +89,8 @@ packages:
     dependency: transitive
     description:
       path: "."
-      ref: "^0.0.1"
-      resolved-ref: d2d5718dad770607567acc8825e77b65b29fa4cb
+      ref: "^0.0.2"
+      resolved-ref: "3a0e9c0980fdba1431afcb3f6838e0a66d753d0f"
       url: "http://git.ius.plus:88/melon.yin/fis_plugin_daniu"
     source: git
     version: "0.0.1"

+ 19 - 13
lib/implementations/nt_rtmp/channel/channel_io.dart

@@ -44,16 +44,17 @@ class NTPublishChannel extends NTBasePublishChannel {
 
 class NTPlayChannel extends NTBasePlayChannel {
   int _volume = 100;
+  String _userId = "";
 
   NTPlayChannel({required super.member}) {
-    _initMobile();
+    _init();
   }
 
   @override
   int get volume => _volume;
 
   IPlayController? get playController =>
-      NTNativeShare.playControllers.get(member.userId!);
+      NTNativeShare.playControllers.get(_userId);
 
   @override
   void setAudioMute(bool isMute) async {
@@ -90,33 +91,38 @@ class NTPlayChannel extends NTBasePlayChannel {
     updateReadyState(viewId > 0);
   }
 
-  void _initMobile() {
-    final userId = member.userId!;
+  void _init() {
+    _userId = member.userId!;
     if (isDevice) {
-      _loadMobileDevice(userId);
+      _loadMobileDevice();
     } else {
-      final controller = PlayController(liveInfo.rtmpUrl, userId: userId);
-      NTNativeShare.playControllers.put(userId, controller);
+      final controller = PlayController(liveInfo.rtmpUrl, userId: _userId);
+      NTNativeShare.playControllers.put(_userId, controller);
     }
   }
 
-  void _loadMobileDevice(String userId) {
+  void _loadMobileDevice() {
     DeviceRtmpLiveInfo info = liveInfo as DeviceRtmpLiveInfo;
     if (info.isMerge) {
-      final subCount = (member as RtmpMemberInfo).deviceInfoList!.length - 1;
+      _userId = MERGE_DEVICE_NATIVE_SIGN; // 合图使用虚拟用户ID
+
+      final subCount =
+          (member as NTRemoteMember).memberInfo.deviceInfoList!.length - 1;
       if (isDeviceMain) {
         final controller = MergePlayController(
           liveInfo.rtmpUrl,
-          userId: MERGE_DEVICE_NATIVE_SIGN,
+          userId: _userId,
           mergeWidth: info.mergeWidth,
           mergeHeight: info.mergeHeight,
           subViewCount: subCount,
         );
-        NTNativeShare.playControllers.put(MERGE_DEVICE_NATIVE_SIGN, controller);
+        NTNativeShare.playControllers.put(_userId, controller);
+      } else {
+        _userId = "DeviceSub";
       }
     } else {
-      final controller = PlayController(liveInfo.rtmpUrl, userId: userId);
-      NTNativeShare.playControllers.put(userId, controller);
+      final controller = PlayController(liveInfo.rtmpUrl, userId: _userId);
+      NTNativeShare.playControllers.put(_userId, controller);
     }
   }
 }

+ 9 - 1
lib/implementations/nt_rtmp/widgets/remote_view/inner_view_io.dart

@@ -51,9 +51,17 @@ class _InnerViewState extends State<InnerView> {
           width: widget.channel.liveInfo.width,
           height: widget.channel.liveInfo.height,
           controller: controller as MergePlayController,
+          onViewCreated: (value) {
+            widget.channel.viewId = value;
+          },
         );
       } else {
-        return PlayView(controller: controller);
+        return PlayView(
+          controller: controller,
+          onViewCreated: (value) {
+            widget.channel.viewId = value;
+          },
+        );
       }
     }
   }

+ 3 - 2
lib/implementations/nt_rtmp/widgets/sub_view/inner_view_io.dart

@@ -18,8 +18,9 @@ class _InnerViewState extends State<InnerView> {
 
   @override
   void initState() {
-    controller = NTNativeShare.playControllers.get(MERGE_DEVICE_NATIVE_SIGN)!
-        as MergePlayController;
+    final instance =
+        NTNativeShare.playControllers.get(MERGE_DEVICE_NATIVE_SIGN);
+    controller = instance! as MergePlayController;
     super.initState();
   }
 

+ 1 - 1
pubspec.yaml

@@ -31,7 +31,7 @@ dependencies:
   daniulive:
     git:
       url: http://git.ius.plus:88/melon.yin/fis_plugin_daniu
-      ref: ^0.0.1
+      ref: ^0.0.2
     # path: ../../fis_packages/fis_plugin_daniu
 
 dev_dependencies:

Some files were not shown because too many files changed in this diff