creating a youtube video player in flutter

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

Popular posts from this blog

swapping the alternate values in given array's element ! 17/11/2022

Learning stage | c++ programs

c++ basic question