creaste YT video playewr widget
This commit is contained in:
46
Frontend/lib/mih_components/mih_yt_video_player.dart
Normal file
46
Frontend/lib/mih_components/mih_yt_video_player.dart
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:youtube_player_iframe/youtube_player_iframe.dart';
|
||||||
|
|
||||||
|
class MIHYTVideoPlayer extends StatefulWidget {
|
||||||
|
final String videoYTLink;
|
||||||
|
const MIHYTVideoPlayer({
|
||||||
|
super.key,
|
||||||
|
required this.videoYTLink,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MIHYTVideoPlayer> createState() => _MIHYTVideoPlayerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MIHYTVideoPlayerState extends State<MIHYTVideoPlayer> {
|
||||||
|
late YoutubePlayerController _controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.close();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_controller = YoutubePlayerController(
|
||||||
|
params: const YoutubePlayerParams(
|
||||||
|
enableCaption: false,
|
||||||
|
showControls: true,
|
||||||
|
mute: false,
|
||||||
|
showFullscreenButton: false,
|
||||||
|
loop: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
_controller.loadVideoById(videoId: widget.videoYTLink);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return YoutubePlayer(
|
||||||
|
controller: _controller,
|
||||||
|
aspectRatio: 16 / 9,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user