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

import '../config.dart';
import '../interface/channel.dart';

/// 推流预览视图
class FRTPublishPreviewView extends StatelessWidget {
  /// 推流通道
  final IPublishChannel channel;

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

  const FRTPublishPreviewView(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 NTPreviewView(channel: channel as NTPublishChannel);
    } else if (type == FRealTimeMediaServiceType.vrtc) {
//
    }
    return TrtcPreviewView(channel as TrtcPublishChannel);
  }
}
