How to play video using flutter_webview_plugin

Issue

I’m trying to play video stored in google drive in flutter app. I embed the video and I got the url. when I try to play the video it not work in android while in IOS it works well. Is the plugin don’t work will in android or I my way to use plugin is wrong?

flutter_webview_plugin: ^0.3.0+2

Widget build(BuildContext context) {
    return WebviewScaffold(
      appBar: AppBar(
        title: Text("play video"),
      ),
      url: "https://drive.google.com/file/d/1O8WF2MsdyoKpQZE2973IFPRpqwKUjm_q/preview",
      initialChild: Center(
        child: CircularProgressIndicator(),
      ),
    );
  }

Solution

I have faced this issue before, where the video does not play (only audio) on any emulator on android, but does work normally on a real device.

The alternative approach towards playing videos natively on flutter is to use the video_player package that enables direct video playing without the use of a webview. Using that, you can play network videos in a much simpler way.

 _controller = VideoPlayerController.network(
        'http://yourvideo.com/videolink')
      ..initialize().then((_) {
        setState(() {});
      });

Complete example and guideline here.

Answered By – Esh

Answer Checked By – Robin (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.