play static method

Future<void> play(
  1. BuildContext context, {
  2. required VideoData video,
})

Play video in a Flutter-based full-screen player with controls

This method launches a full-screen video player using InlineVideoPlayer with Flutter controls overlay, thumbnail support, and back button.

Usage:

await VideoPlayer.play(
  context,
  video: VideoData(
    localPath: '/path/to/video.mp4',
    snapshotLocalPath: '/path/to/thumbnail.jpg',
    width: 1920,
    height: 1080,
  ),
);

Implementation

static Future<void> play(
  BuildContext context, {
  required VideoData video,
}) async {
  if (video.videoPath == null || video.videoPath!.isEmpty) {
    debugPrint('VideoPlayer.play: No video path available');
    return;
  }

  if (!video.hasLocalFile) {
    debugPrint('VideoPlayer.play: Video file does not exist: ${video.localPath}');
    return;
  }

  await Navigator.of(context).push(
    MaterialPageRoute(
      builder: (context) => VideoPlayerWidget(video: video),
    ),
  );
}