voca_youtube_player 0.0.4
voca_youtube_player: ^0.0.4 copied to clipboard
A lightweight YouTube clip player widget for Flutter.
voca_youtube_player #
A lightweight Flutter widget for playing YouTube videos within a specific time range (clip mode).
This package uses WebView and the YouTube IFrame API to enable short, controlled video playback scenarios such as language learning apps, quiz flows, and micro-content experiences.
Features #
- Play only between selected seconds (
startSecondstoendSeconds) - Controlled startup flow until the first visual frame is ready
- Optional custom control overlay (
showControls) - Optional UI reduction strategies (
hideLogo,hideAdvice) - End-of-clip countdown (
timerCount) with completion callback - Playback lifecycle callbacks:
onReadyToPlayonPlaybackStartedonTimerCompleted
- Option to open the video externally (YouTube app or browser)
Installation #
Add the package to your pubspec.yaml:
dependencies:
voca_youtube_player: ^0.0.2
Then run:
flutter pub get
Basic Usage #
import 'package:flutter/material.dart';
import 'package:voca_youtube_player/voca_youtube_player.dart';
class ExamplePage extends StatelessWidget {
const ExamplePage({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(
body: SafeArea(
child: VocaPlayer(
videoId: 'E0BY209ZNEY',
startSeconds: 12.0,
endSeconds: 20.0,
hideLogo: true,
hideAdvice: true,
showControls: true,
timerCount: 25,
onReadyToPlay: () {
debugPrint('Player is ready');
},
onPlaybackStarted: () {
debugPrint('Playback started');
},
onTimerCompleted: () {
debugPrint('Clip completed');
},
),
),
);
}
}
Parameters #
Parameter Type Required Description
appId String? No Optional domain/app
identifier used to
build origin and
widget_referrer.
Defaults to
https://localhost.
videoId String Yes YouTube video ID.
startSeconds double Yes Clip start time in
seconds.
endSeconds double Yes Clip end time in
seconds.
hideLogo bool No Attempts to reduce
YouTube logo/title
visibility. Default:
false.
hideAdvice bool No Attempts to reduce
end-screen
suggestions. Default:
false.
showControls bool No Enables or disables
the custom control
overlay. Default:
true.
timerCount int No End-of-clip countdown
start value. Disabled
when less than or
equal to zero.
onReadyToPlay VoidCallback? No Triggered when the
player is ready.
onPlaybackStarted VoidCallback? No Triggered when the
first visual frame is
considered started.
onTimerCompleted VoidCallback? No Triggered when the
countdown reaches
zero. #
Playback Flow #
- The widget initializes WebView and loads the YouTube IFrame API.
- When
READY_TO_PLAYis received,onReadyToPlayis triggered. - Playback seeks to
startSeconds. - When the first visual frame is detected,
onPlaybackStartedis triggered. - Playback pauses before the full YouTube end-screen recommendations.
- If
timerCountis greater than zero, countdown begins andonTimerCompletedis triggered when it reaches zero.
Platform Support #
- Android
- iOS
Web and desktop platforms are not officially supported due to WebView limitations.
Notes #
- This package depends on YouTube IFrame API behavior. Future YouTube changes may affect UI or playback behavior.
hideLogoandhideAdviceare reduction strategies and may not fully remove all overlays in every scenario.- Autoplay and gesture behavior may vary by device and WebView version.
License #
MIT