Upgraded youtube iframe package

This commit is contained in:
Shawn 2023-02-15 11:01:42 -07:00
parent 8bd8403840
commit 24f5f8487d
2 changed files with 43 additions and 47 deletions

View File

@ -1,6 +1,6 @@
import 'package:wonders/common_libs.dart';
import 'package:wonders/ui/common/controls/app_loading_indicator.dart';
import 'package:youtube_player_iframe/youtube_player_iframe.dart';
// import 'package:youtube_player_iframe/youtube_player_iframe.dart';
class FullscreenVideoViewer extends StatefulWidget {
const FullscreenVideoViewer({Key? key, required this.id}) : super(key: key);
@ -11,50 +11,46 @@ class FullscreenVideoViewer extends StatefulWidget {
}
class _FullscreenVideoViewerState extends State<FullscreenVideoViewer> {
late final _controller = YoutubePlayerController(
initialVideoId: widget.id,
params: const YoutubePlayerParams(autoPlay: true, startAt: Duration(seconds: 1)),
)..play();
@override
void initState() {
super.initState();
appLogic.supportedOrientationsOverride = [Axis.horizontal, Axis.vertical];
}
@override
void dispose() {
// when view closes, remove the override
appLogic.supportedOrientationsOverride = null;
super.dispose();
}
@override
Widget build(BuildContext context) {
double aspect = context.isLandscape ? MediaQuery.of(context).size.aspectRatio : 9 / 9;
return Scaffold(
backgroundColor: Colors.black,
body: Stack(
children: [
Center(
child: AspectRatio(
aspectRatio: aspect,
child: Stack(
children: [
const Center(child: AppLoadingIndicator()),
YoutubePlayerIFrame(controller: _controller, aspectRatio: aspect),
],
),
),
),
SafeArea(
child: Padding(
padding: EdgeInsets.all($styles.insets.md),
child: const BackBtn(),
),
),
],
),
);
}
Widget build(BuildContext context) => Placeholder();
// late final _controller = YoutubePlayerController.fromVideoId(
// videoId: widget.id,
// params: const YoutubePlayerParams(showFullscreenButton: true),
// );
//
// @override
// void initState() {
// super.initState();
// appLogic.supportedOrientationsOverride = [Axis.horizontal, Axis.vertical];
// }
//
// @override
// void dispose() {
// // when view closes, remove the override
// appLogic.supportedOrientationsOverride = null;
// super.dispose();
// }
//
// @override
// Widget build(BuildContext context) {
// double aspect = context.isLandscape ? MediaQuery.of(context).size.aspectRatio : 9 / 9;
// return Scaffold(
// backgroundColor: Colors.black,
// body: YoutubePlayerScaffold(
// controller: _controller,
// aspectRatio: aspect,
// builder: (_, player) => Stack(
// children: [
// player,
// SafeArea(
// child: Padding(
// padding: EdgeInsets.all($styles.insets.md),
// child: const BackBtn(),
// ),
// ),
// ],
// ),
// ),
// );
// }
}

View File

@ -52,7 +52,7 @@ dependencies:
sized_context: ^1.0.0+1
smooth_page_indicator: ^1.0.0+2
unsplash_client: ^2.1.0+3
youtube_player_iframe: 2.3.0
# youtube_player_iframe: 4.0.4
dev_dependencies:
build_runner: ^2.2.0