mirror of
https://github.com/tommyxchow/frosty.git
synced 2025-08-06 17:48:14 +08:00

* Fix new lint issues * Upgrade packages and remove `device_preview` * Regenerate splash assets * Migrate to `webview_flutter` 4.0 * Upgrade to Flutter 3.10 and Dart 3 * Update Podfile * Fix video not disposing when leaving channel * Remove `tuple` package * Upgrade packages * Upgrade packages * Update podfile * Upgrade packages * Upgrade packages
51 lines
1.2 KiB
Dart
51 lines
1.2 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:frosty/screens/channel/video/video_store.dart';
|
|
import 'package:simple_pip_mode/simple_pip.dart';
|
|
import 'package:webview_flutter/webview_flutter.dart';
|
|
|
|
/// Creates a [WebView] widget that shows a channel's video stream.
|
|
class Video extends StatefulWidget {
|
|
final VideoStore videoStore;
|
|
|
|
const Video({
|
|
Key? key,
|
|
required this.videoStore,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
State<Video> createState() => _VideoState();
|
|
}
|
|
|
|
class _VideoState extends State<Video> with WidgetsBindingObserver {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
WidgetsBinding.instance.addObserver(this);
|
|
}
|
|
|
|
@override
|
|
Future<void> didChangeAppLifecycleState(
|
|
AppLifecycleState lifecycleState) async {
|
|
if (Platform.isAndroid &&
|
|
!await SimplePip.isAutoPipAvailable &&
|
|
lifecycleState == AppLifecycleState.inactive) {
|
|
widget.videoStore.requestPictureInPicture();
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return WebViewWidget(
|
|
controller: widget.videoStore.videoWebViewController,
|
|
);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
WidgetsBinding.instance.removeObserver(this);
|
|
super.dispose();
|
|
}
|
|
}
|