Package selection guidance compiled from public package information, community data, and project usage.
A Flutter package that enables video playback on iOS, Android, and macOS using native platform implementations. It provides a reliable and performant way to integrate video content into Flutter apps by leveraging the native video players of each operating system. This ensures better compatibility with various video formats and hardware acceleration. The package is designed for developers seeking seamless video playback without relying on cross-platform abstractions.
Use cases
Playing local video files
Streaming videos from URLs
Integrating video in media-rich applications
Supporting fullscreen video playback
Building video player interfaces with native performance
StreamSubscription<void>? _eventsSubscription;
_eventsSubscription = controller.events.listen((event) {
switch (event) {
casePlaybackStatusChangedEvent():
// Emitted when playback status changes (playing, paused, or stopped)final playbackStatus = controller.playbackStatus;
casePlaybackPositionChangedEvent():
// Emitted when playback position changesfinal position = controller.playbackPosition;
casePlaybackReadyEvent():
// Emitted when video is loaded and ready to playfinal height = controller.videoInfo?.height;
final width = controller.videoInfo?.width;
final duration = controller.videoInfo?.duration;
casePlaybackEndedEvent():
// Emitted when video playback endscasePlaybackSpeedChangedEvent():
// Emitted when playback speed changescaseVolumeChangedEvent():
// Emitted when volume changescasePlaybackErrorEvent():
// Emitted when an error occursprint('Playback error: ${event.errorMessage}');
}
});
// Don't forget to dispose the subscription@overridevoiddispose() {
_eventsSubscription?.cancel();
super.dispose();
}
It's important to properly dispose of both the controller and any event subscriptions when you're done with them to prevent memory leaks. This typically happens in the dispose() method of your widget's State.