2022-08-29 20:38:28 -06:00
|
|
|
import 'package:wonders/common_libs.dart';
|
|
|
|
import 'package:wonders/ui/common/controls/app_loading_indicator.dart';
|
2023-02-16 00:32:07 -07:00
|
|
|
import 'package:youtube_player_iframe/youtube_player_iframe.dart';
|
2022-08-29 20:38:28 -06:00
|
|
|
|
2023-02-13 23:24:07 -07:00
|
|
|
class FullscreenVideoViewer extends StatefulWidget {
|
|
|
|
const FullscreenVideoViewer({Key? key, required this.id}) : super(key: key);
|
2022-08-29 20:38:28 -06:00
|
|
|
final String id;
|
|
|
|
|
|
|
|
@override
|
2023-02-13 23:24:07 -07:00
|
|
|
State<FullscreenVideoViewer> createState() => _FullscreenVideoViewerState();
|
2022-08-29 20:38:28 -06:00
|
|
|
}
|
|
|
|
|
2023-02-13 23:24:07 -07:00
|
|
|
class _FullscreenVideoViewerState extends State<FullscreenVideoViewer> {
|
2023-02-16 00:32:07 -07:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2022-08-29 20:38:28 -06:00
|
|
|
@override
|
2023-02-16 00:32:07 -07:00
|
|
|
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(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-08-29 20:38:28 -06:00
|
|
|
}
|