import 'package:flutter/material.dart';
import '../widget/LocalVideoPlayer.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.fileType);

    if (widget.videoUrl != '' && widget.videoUrl != null) {
      if (widget.fileType == 'netWork') {
        String url = widget.videoUrl.replaceAll('/var', 'http://47.96.141.102:8080');
        _defalutUrl = url;
        isNet = true;
      } else {
        _defalutUrl = widget.videoUrl;
        isNet = false;
      }
    } else {
      isNet = true;
    }
    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,
                  )
                : LocalVideoPlayer(
                    _defalutUrl,
                    isFullScreen: true,
                  )));
  }
}
