Viewing version 2.4.0. Open the latest package page.
video_player_web
2.4.0Web platform implementation of video_player.
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:
- Autoplay policy in Chrome
- MDN > Autoplay guide for media and Web Audio APIs
- Delivering Video Content for Safari > Enable Video Autoplay
- More info about "user activation", in general:
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 indebugmode 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
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:webtweaks.
2.3.0
- Migrates package and tests to
package:web. - Fixes infinite event loop caused by
seekTowhen 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
loadedmetadataas an event that marks that initialization is complete. (Fixes playback in Safari iOS 17). - Sets the
srcof the underlying video element after every other attribute.
2.1.1
- Ensures that the
autoplayattribute 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_webAPIs. - 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.isPlayingwithVideoElement.
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
READMEwith:- 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
Infinityduration.
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
bufferingstate 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
_VideoPlayerprivate 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_interface5.0, which does not include non-dev test dependencies.
2.0.4
- Adopt
video_player_platform_interface4.2 and opt out ofcontentUridata source.
2.0.3
- Add
implementsto 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
Videowidget'sHtmlElementViewso it works well when slotted. - Move tests to
exampledirectory, so they run as integration_tests withflutter drive.
2.0.0
- Migrate to null safety.
- Calling
setMixWithOthers()now is silently ignored instead of throwing an exception. - Fixed an issue where
isBufferingwas not updating on Web.
0.1.4+2
- Update Flutter SDK constraint.
0.1.4+1
- Substitute
undefined_prefixed_name: ignoreanalyzer setting by adart:uishim 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
- Declare API stability and compatibility with
1.0.0(more details at: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0).
0.1.2+2
- Add
analysis_options.yamlto the package, so we can ignoreundefined_prefixed_nameerrors. Works around https://github.com/flutter/flutter/issues/41563.
0.1.2+1
- Make the pedantic dev_dependency explicit.
0.1.2
- Add a
PlatformExceptionto the player'seventControllerwhen there's avideoElement.onError. Fixes https://github.com/flutter/flutter/issues/48884. - Handle DomExceptions on videoElement.play() and turn them into
PlatformExceptionas well, so we don't end up with unhandled Futures. - Update setup instructions in the README.
0.1.1+1
- Add an android/ folder with no-op implementation to workaround https://github.com/flutter/flutter/issues/46898.
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
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.1.0 | On demand | Download | d8797d3a…eb746f |
| 0.1.0+1 | On demand | Download | af65b73c…2074fd |
| 0.1.1 | On demand | Download | 6c4bd00b…5520dc |
| 0.1.1+1 | On demand | Download | 8d4eb424…89eef6 |
| 0.1.2 | On demand | Download | ba621664…1887ea |
| 0.1.2+1 | On demand | Download | f9c6ce28…7a529f |
| 0.1.2+3 | On demand | Download | 8e43bfd0…487d86 |
| 0.1.3 | On demand | Download | 09318b52…318be2 |
| 0.1.3+1 | On demand | Download | 82a08140…cc384e |
| 0.1.3+2 | On demand | Download | 6753d523…ecabda |
| 0.1.4 | On demand | Download | 55c9ac1c…bd32bf |
| 0.1.4+1 | On demand | Download | 1b0fb9d6…bb1241 |
| 2.0.0-nullsafety | On demand | Download | 8822fea3…295a85 |
| 2.0.0-nullsafety.1 | On demand | Download | 9544594d…f30f7d |
| 2.0.0-nullsafety.2 | On demand | Download | 23a88a47…75aa3a |
| 2.0.0-nullsafety.3 | On demand | Download | f44974fa…6c5492 |
| 2.0.0 | On demand | Download | c806616e…ad91ce |
| 2.0.1 | On demand | Download | e1b82f35…3c5505 |
| 2.0.2 | On demand | Download | a3aaf4c6…b83d62 |
| 2.0.3 | On demand | Download | 6d8f0c66…3dc9c1 |
| 2.0.4 | On demand | Download | 923344c8…e23526 |
| 2.0.5 | On demand | Download | 0c4c05b3…67f0fe |
| 2.0.6 | On demand | Download | bdf78cb2…a4503a |
| 2.0.7 | On demand | Download | 48de7d5f…56fc81 |
| 2.0.8 | On demand | Download | 68db6341…3052a9 |
| 2.0.9 | On demand | Download | 50c467f6…87deee |
| 2.0.10 | On demand | Download | cc4f6fbc…3bc48b |
| 2.0.11 | On demand | Download | e3c4a27d…21f785 |
| 2.0.12 | On demand | Download | ed949a3d…3f584b |
| 2.0.13 | On demand | Download | b649b07b…5ddb99 |
| 2.0.14 | On demand | Download | d635bb28…3289c8 |
| 2.0.15 | On demand | Download | fb3bbeaf…79940e |
| 2.0.16 | On demand | Download | 44ce4142…81c74c |
| 2.0.17 | On demand | Download | 9c34a243…02fcb7 |
| 2.0.18 | On demand | Download | 68bdd115…1541a9 |
| 2.1.0 | On demand | Download | 66fc0d56…122a4f |
| 2.1.1 | On demand | Download | 2dd24f7b…0fd62f |
| 2.1.2 | On demand | Download | ab7a462b…c5cb5b |
| 2.1.3 | On demand | Download | 34beb3a0…a6e2cb |
| 2.2.0 | On demand | Download | 8e9cb7fe…0e057b |
| 2.3.0 | On demand | Download | 41245cef…89d6e4 |
| 2.3.1 | On demand | Download | ff4d69a6…2b8fe2 |
| 2.3.2 | On demand | Download | 6dcdd298…caf774 |
| 2.3.3 | On demand | Download | 881b375a…064a10 |
| 2.3.4 | On demand | Download | 3ef40ea6…e13476 |
| 2.3.5 | On demand | Download | e8bba2e5…d365ba |
| 2.4.0 | Cached · Upstream SHA-256 matched | Download | 9f3c00be…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"