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

outdated

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

Pub

native_video_player #

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: 'psth/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 playig, 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.

33
likes
0
pub points
89%
popularity

Publisher

verified publisheralbemala.me

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

Homepage

License

unknown (LICENSE)

Dependencies

flutter, json_annotation, path, path_provider

More

Packages that depend on native_video_player