import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:oktoast/oktoast.dart';
import 'package:tencent_live_fluttify/tencent_live_fluttify.dart';

import 'src/tencent_live.screen.dart';

const _testPushUrl =
    'rtmp://live-push.tuobaye.cn/live/123456?txSecret=19b0c51e26a677614f233541f71e36f5&txTime=5EDD0EFF';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await TencentLive.instance.init(
    licenseUrl:
        'https://license.vod2.myqcloud.com/license/v1/bc8b7690d75d757e9a0fcfa0be01c96f/TXLiveSDK.licence',
    licenseKey: '26be8d6e80f07acc9ee8830d809de878',
  );
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return OKToast(
      child: MaterialApp(
        home: TencentLiveScreen(),
      ),
    );
  }
}

//
//class MyApp extends StatefulWidget {
//  @override
//  _MyAppState createState() => _MyAppState();
//}
//
//class _MyAppState extends State<MyApp> {
//  @override
//  Widget build(BuildContext context) {
//    return MaterialApp(home: _HomeScreen());
//  }
//}
//
//class _HomeScreen extends StatefulWidget {
//  const _HomeScreen({
//    Key key,
//  }) : super(key: key);
//
//  @override
//  __HomeScreenState createState() => __HomeScreenState();
//}
//
//class __HomeScreenState extends State<_HomeScreen> {
//  @override
//  Widget build(BuildContext context) {
//    return Scaffold(
//      appBar: AppBar(
//        title: const Text('Plugin example app'),
//      ),
//      body: CloudVideo(
//        onCloudVideoCreated: (controller) async {
//          final player = await LivePlayer.create();
//          await player.setPlayerView(controller.playerView);
//          await player.setRenderMode(RenderMode.ADJUST_RESOLUTION);
//          await player.startPlay('rtmp://58.200.131.2:1935/livetv/cctv1');
//        },
//      ),
//    );
//  }
//}
