voca_youtube_player 0.0.1
voca_youtube_player: ^0.0.1 copied to clipboard
A lightweight YouTube clip player widget for Flutter.
VocaPlayer #
VocaPlayer is a Flutter widget for playing YouTube videos within a specific
time range (clip mode). It uses WebView + YouTube IFrame API and adds a custom
control layer for clip-focused playback.
Features #
- Play only between selected seconds (
startSeconds-endSeconds) - Controlled startup flow until the first visual frame is ready
- Optional custom control overlay (
showControls) - Optional logo/recommendation reduction behaviors (
hideLogo,hideAdvice) - End-of-clip countdown (
timerCount) with completion callback - Open in external YouTube app/browser (via menu)
- Callback support:
onReadyToPlay,onPlaybackStarted,onTimerCompleted
Installation #
pubspec.yaml:
dependencies:
voca_player: ^1.0.0
Then run:
flutter pub get
Usage #
import 'package:flutter/material.dart';
import 'package:voca_player/voca_player.dart';
class ExamplePage extends StatelessWidget {
const ExamplePage({super.key});
@override
Widget build(BuildContext context) {
return 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('End timer completed');
},
),
),
);
}
}
Parameters #
appId(String?): Optional app/domain value used to buildoriginandwidget_referrer. If empty,https://localhostis used.videoId(String, required): YouTube video ID.startSeconds(double, required): Clip start time in seconds.endSeconds(double, required): Clip end time in seconds.hideLogo(bool, defaultfalse): Applies masking/preset rules to reduce YouTube logo/title visibility.hideAdvice(bool, defaultfalse): Stops playback near the end to reduce YouTube end-screen suggestions.showControls(bool, defaulttrue): Enables/disables the custom control overlay.timerCount(int, default0): End countdown start value. Disabled when<= 0.onReadyToPlay(VoidCallback?): Triggered when player is ready.onPlaybackStarted(VoidCallback?): Triggered when the first visual frame is considered started.onTimerCompleted(VoidCallback?): Triggered when countdown reaches zero.
Playback Flow #
- The widget initializes WebView + YouTube IFrame API.
- When
READY_TO_PLAYis received,onReadyToPlayis fired. - User starts playback, player seeks near
startSeconds. - When the first visual frame is detected,
onPlaybackStartedis fired. - At clip end (especially with
hideAdvice=true), playback is paused before full end-screen recommendations. - If
timerCount > 0, countdown starts andonTimerCompletedfires at zero.
Notes #
- This package depends on YouTube IFrame API behavior; upstream YouTube changes may affect UI and playback flow.
hideLogoandhideAdviceare reduction strategies, not guaranteed full removal of all overlays/recommendations in every case.- On Android, autoplay/gesture behavior may vary by device and WebView version.
License #
MIT