native_video_player 1.3.1 copy "native_video_player: ^1.3.1" to clipboard
native_video_player: ^1.3.1 copied to clipboard

A Flutter widget to play videos on iOS and Android using a native implementation.

native_video_player #

Pub

A Flutter widget to play videos on iOS and Android using a native implementation.

Android iOS
Support 16+ 9.0+

Implementation #

Usage #

Loading a video #

@override
Widget build(BuildContext context) {
  return NativeVideoPlayerView(
    onViewReady: (controller) async {
      final videoSource = await VideoSource.init(
        path: 'path/to/file',
        type: VideoSourceType,
      );
      await controller.loadVideoSource(videoSource);
    },
  );
}

Listen to events #

controller.onPlaybackReady.addListener(() {
  // Emitted when the video loaded successfully and it's ready to play.
  // At this point, videoInfo is available.
  final videoInfo = controller.videoInfo;
  final videoWidth = videoInfo.width;
  final videoHeight = videoInfo.height;
  final videoDuration = videoInfo.duration;
});
controller.onPlaybackStatusChanged.addListener(() {
  final playbackStatus = controller.playbackInfo.status;
  // playbackStatus can be playing, paused, or stopped. 
});
controller.onPlaybackPositionChanged.addListener(() {
  final playbackPosition = controller.playbackInfo.position;
});
controller.onPlaybackEnded.addListener(() {
  // Emitted when the video has finished playing.
});

Autoplay #

controller.onPlaybackReady.addListener(() {
  controller.play();
});

Playback loop #

controller.onPlaybackEnded.addListener(() {
  controller.play();
});

Advanced usage #

See the example app for a complete usage example.

Support this project #

Buy Me A Coffee

Other projects #

🧰 exabox β€” Essential tools for developers: All the tools you need in one single app.

πŸ˜ƒ Ejimo β€” Emoji and symbol picker

πŸ—ΊοΈ WMap β€” Create beautiful, minimal, custom map wallpapers and backgrounds for your phone or tablet.

🎨 iroβ€Ώiro β€” Rearrange the colors to form beautiful patterns in this relaxing color puzzle game.

Credits #

Created by @albemala (Twitter)

31
likes
140
pub points
89%
popularity

Publisher

verified publisheralbemala.me

A Flutter widget to play videos on iOS and Android using a native implementation.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, json_annotation, path, path_provider

More

Packages that depend on native_video_player