import 'package:fis_lib_media_rt/implementations/nt_rtmp/channel/channel.dart';
import 'package:fis_lib_media_rt/implementations/nt_rtmp/widgets/remote_view/remote_view.dart';
import 'package:fis_lib_media_rt/implementations/trtc/channel.dart';
import 'package:flutter/material.dart';

import '../config.dart';
import '../implementations/trtc/widgets/remote_view.dart';
import '../interface/channel.dart';

/// 实时画面视图（单路）
class FRTPlayChannelView extends StatelessWidget {
  /// 播放路源
  final IPlayChannel channel;

  /// 指定尺寸
  final Size? size;

  const FRTPlayChannelView(this.channel, {super.key, this.size});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.black54,
      width: size?.width,
      height: size?.height,
      child: Center(
        child: _buildView(),
      ),
    );
  }

  Widget _buildView() {
    final type = FRTMediaConfig.serviceType;
    if (type == FRealTimeMediaServiceType.ntRtmp) {
      return NTRemoteView(channel: channel as NTPlayChannel);
    } else if (type == FRealTimeMediaServiceType.vrtc) {
//
    }
    return TrtcRemoteView(channel as TrtcPlayChannel);
  }
}
