Viewing version 2.4.0. Open the latest package page.

video_player_web

2.4.0

Web platform implementation of video_player.

Download archive

Readme

video_player_web

The web implementation of video_player.

Usage

This package is endorsed, which means you can simply use video_player normally. This package will be automatically included in your app when you do, so you do not need to add it to your pubspec.yaml.

However, if you import this package to use any of its APIs directly, you should add it to your pubspec.yaml as usual.

Limitations on the Web platform

Video playback on the Web platform has some limitations that might surprise developers more familiar with mobile/desktop targets.

In no particular order:

dart:io

The web platform does not suppport dart:io, so attempts to create a VideoPlayerController.file will throw an UnimplementedError.

Autoplay

Attempts to start playing videos with an audio track (or not muted) without user interaction with the site ("user activation") will be prohibited by the browser and cause runtime errors in JS.

See also:

Some videos restart when using the seek bar/progress bar/scrubber

Certain videos will rewind to the beginning when users attempt to seekTo (change the progress/scrub to) another position, instead of jumping to the desired position. Once the video is fully stored in the browser cache, seeking will work fine after a full page reload.

The most common explanation for this issue is that the server where the video is stored doesn't support HTTP range requests.

NOTE: Flutter web's local server (the one that powers flutter run) DOES NOT support range requests, so all video assets in debug mode will exhibit this behavior.

See Issue #49360 for more information on how to diagnose if a server supports range requests or not.

Mixing audio with other audio sources

The VideoPlayerOptions.mixWithOthers option can't be implemented in web, at least at the moment. If you use this option it will be silently ignored.

Supported Formats

Different web browsers support different sets of video codecs.

Video codecs?

Check MDN's Web video codec guide to learn more about the pros and cons of each video codec.

What codecs are supported?

Visit caniuse.com: 'video format' for a breakdown of which browsers support what codecs. You can customize charts there for the users of your particular website(s).

Here's an abridged version of the data from caniuse, for a Global audience:

MPEG-4/H.264

Data on Global support for the MPEG-4/H.264 video format

WebM

Data on Global support for the WebM video format

Ogg/Theora

Data on Global support for the Ogg/Theora video format

AV1

Data on Global support for the AV1 video format

HEVC/H.265

Data on Global support for the HEVC/H.265 video format

Changelog

2.4.0

  • Adds HTML5 video poster support as a VideoPlayerWebOptions.
  • Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.

2.3.5

  • Fixes blank first frame on iOS.

2.3.4

  • Adjusts the code to the new platform interface.

2.3.3

  • Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
  • Corrects the behavior of muting/unmuting videos in Chrome's Tap Emulation mode.

2.3.2

  • Adds support for web: ^1.0.0.

2.3.1

  • Fixes some package:web tweaks.

2.3.0

  • Migrates package and tests to package:web.
  • Fixes infinite event loop caused by seekTo when the video ends.

2.2.0

  • Updates SDK version to Dart ^3.3.0. Flutter ^3.19.0.

2.1.3

  • Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
  • Fixes new lint warnings.

2.1.2

  • Listens to loadedmetadata as an event that marks that initialization is complete. (Fixes playback in Safari iOS 17).
  • Sets the src of the underlying video element after every other attribute.

2.1.1

  • Ensures that the autoplay attribute of the underlying video element is set to false.

2.1.0

  • Adds web options to customize the control list and context menu display.

2.0.18

  • Migrates to dart:ui_web APIs.
  • Updates minimum supported SDK version to Flutter 3.13.0/Dart 3.1.0.

2.0.17

  • Adds pub topics to package metadata.
  • Updates minimum supported SDK version to Flutter 3.7/Dart 2.19.

2.0.16

  • Synchronizes VideoPlayerValue.isPlaying with VideoElement.

2.0.15

  • Clarifies explanation of endorsement in README.
  • Aligns Dart and Flutter SDK constraints.

2.0.14

  • Updates links for the merge of flutter/plugins into flutter/packages.
  • Updates minimum Flutter version to 3.0.

2.0.13

  • Adds compatibilty with version 6.0 of the platform interface.
  • Updates minimum Flutter version to 2.10.

2.0.12

  • Updates the README with:
    • Information about a common known issue: "Some videos restart when using the seek bar/progress bar/scrubber" (Issue #49630)
    • Links to the Autoplay information of all major browsers (Chrome/Edge, Firefox, Safari).

2.0.11

  • Improves handling of videos with Infinity duration.

2.0.10

  • Minor fixes for new analysis options.

2.0.9

  • Removes unnecessary imports.
  • Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors lint warnings.

2.0.8

  • Ensures buffering state is only removed when the browser reports enough data has been buffered so that the video can likely play through without stopping (onCanPlayThrough). Issue #94630.
  • Improves testability of the _VideoPlayer private class.
  • Ensures that tests that listen to a Stream fail "fast" (1 second max timeout).

2.0.7

  • Internal code cleanup for stricter analysis options.

2.0.6

  • Removes dependency on meta.

2.0.5

  • Adds compatibility with video_player_platform_interface 5.0, which does not include non-dev test dependencies.

2.0.4

  • Adopt video_player_platform_interface 4.2 and opt out of contentUri data source.

2.0.3

  • Add implements to pubspec.

2.0.2

  • Updated installation instructions in README.

2.0.1

  • Fix videos not playing in Safari/Chrome on iOS by setting autoplay to false
  • Change sizing code of Video widget's HtmlElementView so it works well when slotted.
  • Move tests to example directory, so they run as integration_tests with flutter drive.

2.0.0

  • Migrate to null safety.
  • Calling setMixWithOthers() now is silently ignored instead of throwing an exception.
  • Fixed an issue where isBuffering was not updating on Web.

0.1.4+2

  • Update Flutter SDK constraint.

0.1.4+1

  • Substitute undefined_prefixed_name: ignore analyzer setting by a dart:ui shim with conditional exports. Issue.

0.1.4

  • Added option to set the video playback speed on the video controller.

0.1.3+2

  • Allow users to set the 'muted' attribute on video elements by setting their volume to 0.
  • Do not parse URIs on 'network' videos to not break blobs (Safari).

0.1.3+1

  • Remove Android folder from video_player_web.

0.1.3

  • Updated video_player_platform_interface, bumped minimum Dart version to 2.1.0.

0.1.2+3

0.1.2+2

0.1.2+1

  • Make the pedantic dev_dependency explicit.

0.1.2

  • Add a PlatformException to the player's eventController when there's a videoElement.onError. Fixes https://github.com/flutter/flutter/issues/48884.
  • Handle DomExceptions on videoElement.play() and turn them into PlatformException as well, so we don't end up with unhandled Futures.
  • Update setup instructions in the README.

0.1.1+1

0.1.1

  • Support videos from assets.

0.1.0+1

  • Remove the deprecated author: field from pubspec.yaml
  • Require Flutter SDK 1.10.0 or greater.

0.1.0

  • Initial release

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'video_player_web:2.4.0'
pubspec.yaml
name: video_player_web
description: Web platform implementation of video_player.
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.4.0

environment:
  sdk: ^3.6.0
  flutter: ">=3.27.0"

flutter:
  plugin:
    implements: video_player
    platforms:
      web:
        pluginClass: VideoPlayerPlugin
        fileName: video_player_web.dart

dependencies:
  flutter:
    sdk: flutter
  flutter_web_plugins:
    sdk: flutter
  video_player_platform_interface: ^6.4.0
  web: ">=0.5.1 <2.0.0"

dev_dependencies:
  flutter_test:
    sdk: flutter

topics:
  - video
  - video-player

Version history

VersionPublishedArchiveSHA-256
0.1.0On demandDownloadd8797d3a…eb746f
0.1.0+1On demandDownloadaf65b73c…2074fd
0.1.1On demandDownload6c4bd00b…5520dc
0.1.1+1On demandDownload8d4eb424…89eef6
0.1.2On demandDownloadba621664…1887ea
0.1.2+1On demandDownloadf9c6ce28…7a529f
0.1.2+3On demandDownload8e43bfd0…487d86
0.1.3On demandDownload09318b52…318be2
0.1.3+1On demandDownload82a08140…cc384e
0.1.3+2On demandDownload6753d523…ecabda
0.1.4On demandDownload55c9ac1c…bd32bf
0.1.4+1On demandDownload1b0fb9d6…bb1241
2.0.0-nullsafetyOn demandDownload8822fea3…295a85
2.0.0-nullsafety.1On demandDownload9544594d…f30f7d
2.0.0-nullsafety.2On demandDownload23a88a47…75aa3a
2.0.0-nullsafety.3On demandDownloadf44974fa…6c5492
2.0.0On demandDownloadc806616e…ad91ce
2.0.1On demandDownloade1b82f35…3c5505
2.0.2On demandDownloada3aaf4c6…b83d62
2.0.3On demandDownload6d8f0c66…3dc9c1
2.0.4On demandDownload923344c8…e23526
2.0.5On demandDownload0c4c05b3…67f0fe
2.0.6On demandDownloadbdf78cb2…a4503a
2.0.7On demandDownload48de7d5f…56fc81
2.0.8On demandDownload68db6341…3052a9
2.0.9On demandDownload50c467f6…87deee
2.0.10On demandDownloadcc4f6fbc…3bc48b
2.0.11On demandDownloade3c4a27d…21f785
2.0.12On demandDownloaded949a3d…3f584b
2.0.13On demandDownloadb649b07b…5ddb99
2.0.14On demandDownloadd635bb28…3289c8
2.0.15On demandDownloadfb3bbeaf…79940e
2.0.16On demandDownload44ce4142…81c74c
2.0.17On demandDownload9c34a243…02fcb7
2.0.18On demandDownload68bdd115…1541a9
2.1.0On demandDownload66fc0d56…122a4f
2.1.1On demandDownload2dd24f7b…0fd62f
2.1.2On demandDownloadab7a462b…c5cb5b
2.1.3On demandDownload34beb3a0…a6e2cb
2.2.0On demandDownload8e9cb7fe…0e057b
2.3.0On demandDownload41245cef…89d6e4
2.3.1On demandDownloadff4d69a6…2b8fe2
2.3.2On demandDownload6dcdd298…caf774
2.3.3On demandDownload881b375a…064a10
2.3.4On demandDownload3ef40ea6…e13476
2.3.5On demandDownloade8bba2e5…d365ba
2.4.0Cached · Upstream SHA-256 matchedDownload9f3c00be…afbdeb

Dependencies

flutter { "sdk": "flutter" }

flutter_web_plugins { "sdk": "flutter" }

video_player_platform_interface "^6.4.0"

web "\u003e=0.5.1 \u003c2.0.0"