视频不可见,但音频在iOS和颤抖的视频播放器中可以正常工作

时间:2020-04-02 07:59:24

标签: flutter

这在android设备中正常工作,音频和视频都在相应播放。但是对于iOS,只有音频有效,没有视觉效果。 我正在iOS模拟器中运行该应用程序。我还在GitHub上搜索了这个问题,人们建议它可以在真实设备上正常运行,但事实并非如此。

这是我播放视频的全部代码

class UiPathVideoPage extends StatefulWidget {
  final String text;
  UiPathVideoPage({Key key, @required this.text}) : super(key: key);
  @override
  _UiPathVideoPageState createState() => _UiPathVideoPageState();
}

class _UiPathVideoPageState extends State<UiPathVideoPage> {
  VideoPlayerController _controller;
  ProgressDialog pr;
  @override void initState() {
    // TODO: implement initState


    super.initState();




    if(widget.text == 'Telecom') {
      _controller = VideoPlayerController.network(
          'https://firebasestorage.googleapis.com/v0/b/recycler-view-8483d.appspot.com/04ea5f9ca1')
        ..initialize().then((_) {
          // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
          setState(() {});
          _controller.value.isPlaying
              ? _controller.pause()
              : _controller.play();

        });
    }
    if(widget.text == 'Finance'){
      _controller = VideoPlayerController.network(
          'https://firebasestorage.googleapis.com/v0/b/recycler-view-8483d.appspot.com/o/VideoLibrary%273320d38f')
        ..initialize().then((_) {
          // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
          setState(() {});
          _controller.value.isPlaying
              ? _controller.pause()
              : _controller.play();
        });

    }
    if(widget.text == 'Sales'){
      _controller = VideoPlayerController.network(
          'https://firebasestorage.googleapis.com/v0/b/recycler-view-8483d.appspot.com/o/VideoLibraryc498e')
        ..initialize().then((_) {
          // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
          setState(() {});
          _controller.value.isPlaying
              ? _controller.pause()
              : _controller.play();
        });

    }

    if(widget.text == 'Others'){

      _controller = VideoPlayerController.network(
          'https://firebasestorage.googleapis.com/v0/b/recycler-view-8483d.appspot.com/o/VideoLibrary%2Fcea5f9ca1')
        ..initialize().then((_) {
          // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
          setState(() {});
          _controller.value.isPlaying
              ? _controller.pause()
              : _controller.play();

        });

    }

  }
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    _controller.dispose();
  }
  @override
  Widget build(BuildContext context) {
    pr = new ProgressDialog(context);
    pr.style(
        message: 'Please Waiting...',
        borderRadius: 10.0,
        backgroundColor: Colors.white,
        progressWidget: CircularProgressIndicator(),
        elevation: 10.0,
        insetAnimCurve: Curves.easeInOut,
        progress: 0.0,
        maxProgress: 100.0,
        progressTextStyle: TextStyle(
            color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
        messageTextStyle: TextStyle(
            color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600)
    );
    return Container(
      child: Scaffold(
        backgroundColor: Colors.grey[200],
        appBar: AppBar(
          backgroundColor: Colors.grey[900],
          title: Text(""),
        ),
        body: Center(
            child:
            _controller.value.initialized
                ? AspectRatio(
              aspectRatio: _controller.value.aspectRatio,
              child: VideoPlayer(_controller),
            )
                : Container(
              child: Image.asset('assets/loading.gif'),
            )

        ),


        floatingActionButton: FloatingActionButton(
          onPressed: () {
            setState(() {

              _controller.value.isPlaying
                  ? _controller.pause()
                  : _controller.play();
            });
          },
          child: Icon(
            _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
          ),
        ),
      ),
    );
  }
}

我正在寻找帮助,在此先感谢

0 个答案:

没有答案