import 'package:flutter/material.dart';
import '../widget/LocalVideoPlayer.dart';
import '../net/HttpManager.dart';

class VideoPlayerPage extends StatefulWidget {
  VideoPlayerPage({Key key, this.videoUrl, this.fileType}) : super(key: key);
  final String videoUrl; // 用来储存传递过来的值
  final String fileType;
  @override
  _VideoPlayerPageState createState() => _VideoPlayerPageState();
}

class _VideoPlayerPageState extends State<VideoPlayerPage> {
  String _defalutUrl = 'http://oss.izouma.com/shouyoudianjing/video/2019-04-08-09-47-26-5e6fy69t.mp4';
  bool isNet = true;

  @override
  void initState() {
    super.initState();
    print(widget.videoUrl);

    if (widget.videoUrl != '' && widget.videoUrl != null) {
      if (widget.fileType == 'netWork') {
        String url = widget.videoUrl.replaceAll('/var', 'http://202.79.174.56:8206');
        _defalutUrl = url;
        isNet = true;
      } else {
        _defalutUrl = widget.videoUrl;
        isNet = false;
      }
    } else {
      isNet = true;
    }
    // _defalutUrl='http://123.58.240.138:8080/videos/2019-05-24-04-47-48-4bzyynao.mp4';
    print(_defalutUrl);
    print(isNet);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('比赛记录'),
        ),
        body: Container(
            // height: 300.0,
            child: isNet
                ? LocalVideoPlayer(
                  
                    _defalutUrl,
                    isFullScreen: true,
                    isNet:true,
                  )
                : LocalVideoPlayer(
                    _defalutUrl,
                    isFullScreen: true,
                    isNet:false,
                  )));
  }
}
