video_view 1.0.7
video_view: ^1.0.7 copied to clipboard
A lightweight media player with subtitle rendering and audio track switching support, leveraging system or app-level components for seamless playback.
About #
video_view
is a lightweight media player with subtitle rendering1 and audio track switching support, leveraging system or app-level components for seamless playback.
For API documentation, please visit here.
Demo #
You may try the online demo, or run the demo app locally by cloning this repository:
git clone -c core.symlinks=true https://github.com/xxoo/flutter_video_view.git
cd flutter_video_view/example
For basic usage, just run:
flutter run
For advanced usage, please run:
flutter run lib/main_advanced.dart
Installation #
- Run the following command in your project directory:
flutter pub add video_view
- Add the following code to your dart file:
import 'package:video_view/video_view.dart';
- If your project has web support, you may also need to add
VideoViewPlugin.js
to your project by running:
dart run video_view:webinit
- If you encounter "setState while widget is building or locked" issue, then you probably need to install
set_state_async
package as well.
Flutter support #
video_view
requires Flutter 3.32 or higher. For older versions, please use av_media_player instead.
Platform support #
Platform | Version | Backend |
---|---|---|
Android | 6+ | ExoPlayer |
iOS | 15+ | AVPlayer |
macOS | 12+ | AVPlayer |
Windows | 10+ | MediaPlayer |
Linux | N/A | libmpv2 |
Web | Chrome 84+ / Safari 15+ / Firefox 90+ | <video>, ShakaPlayer3 |
Supported media formats #
For user who only cares about Android and iOS, the following formats are supported without condition:
Type | Formats |
---|---|
Video Codec | H.264, H.265 |
Audio Codec | AAC, MP3 |
Container Format | MP4, TS |
Subtitle Format | WebVTT, CEA-608/708 |
Transfer Protocol | HTTP, HLS, LL-HLS |
A more complete list with conditions:
Type | Formats |
---|---|
Video Codec | H.264, H.265(HEVC)4, AV15 |
Audio Codec | AAC, MP3 |
Container Format | MP4, TS, WebM5 |
Subtitle Format | WebVTT6, CEA-608/708 |
Transfer Protocol | HTTP, HLS, LL-HLS, DASH7, MSS7 |
How to specify format manually #
Most backends don't support manually specifying media format, with Android and Web being the exceptions. Therefore, there's no formal API planned for this feature. However, supported platforms can automatically detect the format from the URL. You can simply append a file extension to the query string or hash fragment to specify the format. Please note that only 3 extensions are recognized: .m3u8
, .mpd
, and .ism/manifest
. If multiple extensions are found, the last one takes precedence. For example:
// No need to specify format, the url already contains `.m3u8`
final example0 = 'https://example.com/video.m3u8';
// Missing extension in path, add `.m3u8` in query string
final example1 = 'https://example.com/video?x=.m3u8';
// Override HLS to DASH format with query string
final example2 = 'https://example.com/video.m3u8?y=.mpd';
// Override HLS to DASH format with hash fragment
final example3 = 'https://example.com/video.m3u8#.mpd';