feat:更新视频播放组件
This commit is contained in:
58
lib/utils/showVideoPlay.dart
Normal file
58
lib/utils/showVideoPlay.dart
Normal file
@@ -0,0 +1,58 @@
|
||||
import 'dart:collection';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||
|
||||
class ShowVideoPlayPage extends StatefulWidget {
|
||||
final String url;
|
||||
const ShowVideoPlayPage({super.key, required this.url});
|
||||
|
||||
@override
|
||||
State<ShowVideoPlayPage> createState() => _ShowVideoPlayPageState();
|
||||
}
|
||||
|
||||
class _ShowVideoPlayPageState extends State<ShowVideoPlayPage> {
|
||||
|
||||
InAppWebViewController? webViewController;
|
||||
InAppWebViewSettings settings = InAppWebViewSettings(
|
||||
isInspectable: kDebugMode,
|
||||
mediaPlaybackRequiresUserGesture: false,
|
||||
allowsInlineMediaPlayback: true,
|
||||
iframeAllow: "camera; microphone",
|
||||
iframeAllowFullscreen: true);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
leading: GestureDetector(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Icon(
|
||||
Icons.navigate_before,
|
||||
color: Colors.white,
|
||||
size: 32,
|
||||
),
|
||||
),
|
||||
backgroundColor: Colors.black,
|
||||
),
|
||||
body: Container(
|
||||
color: Colors.black,
|
||||
child:InAppWebView(
|
||||
initialUrlRequest: URLRequest(url: WebUri(widget.url)),
|
||||
initialUserScripts: UnmodifiableListView<UserScript>([]),
|
||||
initialSettings: settings,
|
||||
onWebViewCreated: (controller) async {
|
||||
webViewController = controller;
|
||||
},
|
||||
onLoadStart: (controller, url) {
|
||||
setState(() {
|
||||
});
|
||||
},
|
||||
onConsoleMessage: (controller, consoleMessage) {
|
||||
print(consoleMessage);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user