vk_video 1.0.3 vk_video: ^1.0.3 copied to clipboard
The vk_video package facilitates VK video playback integration in Flutter apps, supporting the VK Video API for seamless embedding and control.
vk_video #
The vk_video package simplifies the integration of VK video playback into your Flutter apps. It supports the VK Video API, allowing easy embedding and control for a seamless media experience.
Show some ❤️ and star the repo to support the project!
Getting Started #
To use this package, add it to your pubspec.yaml
:
dependencies:
vk_video: ^1.0.3
or run the command
flutter pub add vk_video
Using the player #
import
import 'package:vk_video/vk_video.dart';
Full screen disable mode
VKVideo(
videoOId: '-22822305',
videoId: '456241864',
),
Full screen mode
VKVideo(
videoOId: '-213200306',
videoId: '456239020',
isIframeAllowFullscreen: true,
isAllowsInlineMediaPlayback: false,
),
To add the permission for internet access in your Android app, you need to include it in your AndroidManifest.xml file. Here’s how to do that:
<uses-permission android:name="android.permission.INTERNET"/>
Controller
VKVideoController? _controller;
@override
void initState() {
_controller = VKVideoController();
super.initState();
}
VKVideo(
controller: _controller,
videoOId: '-213200306',
videoId: '456239020',
isAutoPlay: true,
videoResolutionEnum: VideoResolutionEnum.p480,
videoStartTime: Duration(seconds: 3),
backgroundColor: const Color(0xFF000000),
initialWidget: Text(
"Loading....",
style: TextStyle(
color: Color(0xFFFFFFFF),
),
),
),
Add a listener to track changes in video playback position
_controller?.addListener(() {
debugPrint("position: ${_controller!.getCurrentTime}");
debugPrint("currentTime: $currentTime");
debugPrint("isMute: $isMute");
debugPrint("duration: ${_controller?.getDuration}");
debugPrint("volume: ${_controller?.getVolume}");
debugPrint("quality: ${_controller?.getQuality}");
debugPrint("player state: ${_controller?.getPlayerState}");
};
);
Button to seek forward 5 seconds in the video
_controller?.onSeekTo(Duration(seconds: _controller!.getCurrentTime!) + Duration(seconds: 5));