play video in flutter web

You can now just use the official video_player_web plugin by adding it to your pubspec.yaml:

video_player: ^0.10.4+1
video_player_web: ^0.1.0

Then you can follow the video player cookbook or use the chewie plugin to get a nice UI.


I have managed to play the video automatically and play with the sound.

I need to be able to interact with the video, such as pause, stop or play.

I hope it helps you, greetings.

DART

import 'package:flutter_web_ui/ui.dart' as ui;
import 'dart:html';

main() async {
  await ui.webOnlyInitializePlatform();
  VideoElement videoElement;
  videoElement = querySelector('#video');
  videoElement.src = "https://storage04.dropshots.com/photos6000/photos/1381926/20170326/005609.mp4";
  videoElement.muted = false;
  await videoElement.play();
}

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title></title>
  <script defer src="reproductor.dart.js" type="application/javascript"></script>
</head>
<body>    
    <video id="video" class="absolute right-0 bottom-0 min-w-full min-h-full w-auto" controls autoplay muted></video>
</body>
</html>