useAssetVideo function
VideoPlayerController
useAssetVideo({})
Creates VideoPlayerController
using video_player
(ref link), plays video
obtained from an asset, tracks its state, and exposes playback controls.
ref link
Implementation
VideoPlayerController useAssetVideo({
required String asset,
String? package,
bool autoPlay = false,
bool looping = false,
Future<ClosedCaptionFile>? closedCaptionFile,
VideoPlayerOptions? videoPlayerOptions,
}) {
final controller = useMemoized(
() => VideoPlayerController.asset(
asset,
package: package,
closedCaptionFile: closedCaptionFile,
videoPlayerOptions: videoPlayerOptions,
),
[asset, package, closedCaptionFile, videoPlayerOptions],
);
useEffect(() {
controller
..initialize()
..setLooping(looping);
if (autoPlay) {
controller.play();
}
return controller.dispose;
}, [asset, package, closedCaptionFile, videoPlayerOptions]);
return controller;
}