import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
class YouTubeVideoPlayer extends StatefulWidget {
const YouTubeVideoPlayer({super.key});
@override
State<YouTubeVideoPlayer> createState() => _YouTubeVideoPlayerState();
}
class _YouTubeVideoPlayerState extends State<YouTubeVideoPlayer> {
final videoURL = "https://youtu.be/hccEUqoviH8";
late YoutubePlayerController _controller;
@override
void initState() {
final videoId = YoutubePlayer.convertUrlToId(videoURL);
_controller = YoutubePlayerController(
initialVideoId: videoId!,
flags: const YoutubePlayerFlags(
autoPlay: false,
));
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: ListView(
children: [
YoutubePlayer(
controller: _controller,
showVideoProgressIndicator: true,
onReady: () => debugPrint('Ready'),
bottomActions: [
CurrentPosition(),
ProgressBar(
isExpanded: true,
colors: const ProgressBarColors(
playedColor: Colors.amber,
handleColor: Colors.amber,
),
),
const PlaybackSpeedButton(),
const SizedBox(width: 10.0),
RemainingDuration(),
FullScreenButton(),
//const AspectRatio(aspectRatio: 16/9,)
],
),
],
),
);
}
}
Comments
Post a Comment