How to play video using flutter_webview_plugin

4,452

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.

Share:
4,452
Admin
Author by

Admin

Updated on December 09, 2022

Comments

  • Admin
    Admin over 1 year

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