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

View File

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