// import 'package:daniulive/controllers/interfaces/play_controller.dart';
// import 'package:daniulive/controllers/merge_play_controller.dart';
// import 'package:daniulive/controllers/play_controller.dart';
// import 'package:daniulive/controllers/publish_controller.dart';
import 'package:fis_lib_media_rt/implementations/nt_rtmp/members.dart';
import 'package:fis_lib_media_rt/implementations/nt_rtmp/models.dart';
import 'package:fis_lib_media_rt/implementations/nt_rtmp/values.dart';
import 'package:flutter/foundation.dart';

import '../native_share.dart';
import 'base.dart';

class NTPublishChannel extends NTBasePublishChannel {
  int _volume = 100;

  NTPublishChannel({required super.member});

  @override
  void setAudioMute(bool isMute) async {
    // await NTNativeShare.publishController?.muteAudio(isMute);
    // super.setAudioMute(isMute);
  }

  @override
  void setVideoMute(bool isMute) async {
    // await NTNativeShare.publishController?.muteVideo(isMute);
    // super.setVideoMute(isMute);
  }

  @override
  void setVolume(int volume) async {
    // await NTNativeShare.publishController?.setVolume(volume);
    // _volume = volume;
  }

  @override
  void onViewIdChanged() {
    updateReadyState(viewId > 0);
  }

  @override
  int get volume => _volume;
}

class NTPlayChannel extends NTBasePlayChannel {
  int _volume = 100;
  String _userId = "";

  NTPlayChannel({required super.member}) {
    _init();
  }

  @override
  int get volume => _volume;

  get playController => null;

  @override
  void setAudioMute(bool isMute) async {
    await playController?.muteAudio(isMute);
    super.setAudioMute(isMute);
  }

  @override
  void setVideoMute(bool isMute) async {
    await playController?.muteVideo(isMute);
    super.setVideoMute(isMute);
  }

  @override
  Future<void> play() async {
    await playController?.play();
    return super.play();
  }

  @override
  Future<void> stop() async {
    await playController?.stop();
    return super.stop();
  }

  @override
  void setVolume(int volume) async {
    await playController?.setVolume(volume);
    _volume = volume;
  }

  @override
  void onViewIdChanged() {
    updateReadyState(viewId > 0);
  }

  void _init() {
    // _userId = member.userId!;
    // if (isDevice) {
    //   _loadMobileDevice();
    // } else {
    //   final controller = PlayController(liveInfo.rtmpUrl, userId: _userId);
    //   NTNativeShare.playControllers.put(_userId, controller);
    // }
  }

  void _loadMobileDevice() {
    // DeviceRtmpLiveInfo info = liveInfo as DeviceRtmpLiveInfo;
    // if (isDeviceMain) {
    //   int subCount = 0;
    //   if (info.isMerge) {
    //     subCount =
    //         (member as NTRemoteMember).memberInfo.deviceInfoList!.length - 1;
    //   }
    //   // 主画面无论是否合图，都走自渲染逻辑，截图录制需要自渲染数据
    //   _userId = MERGE_DEVICE_NATIVE_SIGN; // 合图使用虚拟用户ID
    //   // final controller = MergePlayController(
    //   //   liveInfo.rtmpUrl,
    //   //   userId: _userId,
    //   //   mergeWidth: info.mergeWidth,
    //   //   mergeHeight: info.mergeHeight,
    //   //   subViewCount: subCount,
    //   // );
    //   NTNativeShare.playControllers.put(_userId, controller);
    // } else {
    //   if (info.isMerge) {
    //     // 合图子画面不需要独立的Controller，监听主画面帧流的广播
    //     _userId = "DeviceSub";
    //   } else {
    //     final controller = PlayController(liveInfo.rtmpUrl, userId: _userId);
    //     NTNativeShare.playControllers.put(_userId, controller);
    //   }
    // }
  }
}
