dartKnightRises
dartKnightRises

Reputation: 905

Video is not visible but audio works fine in iOS, flutter video player

This works fine in android device both audio and video is playing accordingly. But in the case of iOS, only audio work and there are no visuals. I'm running the app in the iOS simulator. I also searched for the issue on GitHub where people suggested that it will work fine on a real device but it isn't.

Here is my whole code which plays video

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,
          ),
        ),
      ),
    );
  }
}

I'm looking for help, Thanks in advance

Upvotes: 5

Views: 1200

Answers (1)

Amit Goyal
Amit Goyal

Reputation: 1

I was also facing same issue final my problem was vp9 video codec that not supported by IOS.

Upvotes: 0

Related Questions