Skip to content

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

License

Notifications You must be signed in to change notification settings

immich-app/native_video_player

This branch is 3 commits ahead of, 43 commits behind albemala/native_video_player:main.

Folders and files

NameName
Last commit message
Last commit date
Jan 10, 2025
Sep 6, 2024
Mar 4, 2025
Dec 6, 2024
Oct 1, 2022
Jun 5, 2023
May 5, 2022
May 5, 2022
Sep 30, 2023
May 6, 2022
Oct 19, 2023
May 5, 2022
Oct 3, 2022
Jun 5, 2023
May 5, 2022
Oct 19, 2023

Repository files navigation

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)

About

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

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 55.3%
  • Swift 20.6%
  • Kotlin 18.4%
  • Ruby 4.0%
  • Objective-C 1.3%
  • Shell 0.4%