Add universal fullscreen option & minor fixes

Reverted to hybrid composition for webview due to pausing on Android
when rotating. Tradeoff is screen flicker/flash when toggling video.
This commit is contained in:
tommyxchow 2021-12-25 22:35:10 -05:00
parent ce20ab7256
commit 89b54ff08e
12 changed files with 142 additions and 115 deletions

View file

@ -9,49 +9,45 @@ import 'package:webview_flutter/webview_flutter.dart';
class Video extends StatelessWidget {
final String userLogin;
final String userName;
final String title;
final VideoStore videoStore;
const Video({
Key? key,
required this.title,
required this.userName,
required this.userLogin,
required this.videoStore,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Observer(
builder: (context) {
if (context.read<SettingsStore>().overlayEnabled) {
return Stack(
children: [
WebView(
initialUrl: 'https://player.twitch.tv/?channel=$userLogin&controls=false&muted=false&parent=frosty',
javascriptMode: JavascriptMode.unrestricted,
allowsInlineMediaPlayback: true,
initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow,
onWebViewCreated: (controller) {
videoStore.controller = controller;
},
onPageFinished: (string) {
videoStore.initVideo();
},
),
VideoOverlay(videoStore: videoStore),
],
);
} else {
return WebView(
initialUrl: 'https://player.twitch.tv/?channel=$userLogin&muted=false&parent=frosty',
javascriptMode: JavascriptMode.unrestricted,
allowsInlineMediaPlayback: true,
initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow,
);
}
},
return SafeArea(
child: AspectRatio(
aspectRatio: 16 / 9,
child: Observer(
builder: (context) {
if (context.read<SettingsStore>().overlayEnabled) {
return Stack(
children: [
WebView(
initialUrl: 'https://player.twitch.tv/?channel=$userLogin&controls=false&muted=false&parent=frosty',
javascriptMode: JavascriptMode.unrestricted,
allowsInlineMediaPlayback: true,
initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow,
onWebViewCreated: (controller) => videoStore.controller = controller,
onPageFinished: (string) => videoStore.initVideo(),
),
VideoOverlay(videoStore: videoStore),
],
);
}
return WebView(
initialUrl: 'https://player.twitch.tv/?channel=$userLogin&muted=false&parent=frosty',
javascriptMode: JavascriptMode.unrestricted,
allowsInlineMediaPlayback: true,
initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow,
);
},
),
),
);
}
}