feat:更新视频播放组件
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
import 'package:flutter_common/utils/showVideoPlay.dart';
|
||||||
import 'package:omni_video_player/omni_video_player.dart';
|
|
||||||
|
|
||||||
class PlayVideoPage extends StatefulWidget {
|
class PlayVideoPage extends StatefulWidget {
|
||||||
|
|
||||||
@@ -13,7 +12,6 @@ class PlayVideoPage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PlayVideoPageState extends State<PlayVideoPage> {
|
class _PlayVideoPageState extends State<PlayVideoPage> {
|
||||||
OmniPlaybackController? _controller;
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
// TODO: implement initState
|
// TODO: implement initState
|
||||||
@@ -24,42 +22,10 @@ class _PlayVideoPageState extends State<PlayVideoPage> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
// TODO: implement dispose
|
// TODO: implement dispose
|
||||||
super.dispose();
|
super.dispose();
|
||||||
_controller?.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return ShowVideoPlayPage(url: widget.videoUrl);
|
||||||
body: Stack(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: EdgeInsets.only(bottom: 50.h,top: 150.h),
|
|
||||||
color: Colors.black,
|
|
||||||
child: OmniVideoPlayer(
|
|
||||||
configuration: VideoPlayerConfiguration(
|
|
||||||
videoSourceConfiguration: VideoSourceConfiguration.network(
|
|
||||||
videoUrl: Uri.parse(widget.videoUrl),
|
|
||||||
preferredQualities: [OmniVideoQuality.high1080],
|
|
||||||
),
|
|
||||||
), callbacks: VideoPlayerCallbacks(
|
|
||||||
onControllerCreated: (controller) {
|
|
||||||
setState(() {
|
|
||||||
controller.play();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: 60.h,
|
|
||||||
left: 20.w,
|
|
||||||
child: IconButton(
|
|
||||||
icon: Icon(Icons.arrow_back_ios, color: Colors.white,),
|
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
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);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
64
pubspec.lock
64
pubspec.lock
@@ -448,14 +448,6 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "10.12.0"
|
version: "10.12.0"
|
||||||
freezed_annotation:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: freezed_annotation
|
|
||||||
sha256: "7294967ff0a6d98638e7acb774aac3af2550777accd8149c90af5b014e6d44d8"
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "3.1.0"
|
|
||||||
get:
|
get:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -624,14 +616,6 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.2"
|
version: "0.7.2"
|
||||||
json_annotation:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: json_annotation
|
|
||||||
sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "4.9.0"
|
|
||||||
leak_tracker:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -744,14 +728,6 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.0"
|
||||||
omni_video_player:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: omni_video_player
|
|
||||||
sha256: e01ce74413c2eb1cfe042c81507ef2573af66e7ee2984b9ee45808d35a3ea9da
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "3.7.2"
|
|
||||||
package_info_plus:
|
package_info_plus:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1080,14 +1056,6 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.1"
|
version: "2.4.1"
|
||||||
simple_sparse_list:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: simple_sparse_list
|
|
||||||
sha256: aa648fd240fa39b49dcd11c19c266990006006de6699a412de485695910fbc1f
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "0.1.4"
|
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -1221,14 +1189,6 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.4.0"
|
version: "1.4.0"
|
||||||
unicode:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: unicode
|
|
||||||
sha256: a6f7bcfc8ea1d5ce1f6c0b1c39117a9919f4953edd9fd7a64090a9796c499b57
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.9"
|
|
||||||
url_launcher:
|
url_launcher:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -1349,14 +1309,6 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0"
|
version: "2.4.0"
|
||||||
visibility_detector:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: visibility_detector
|
|
||||||
sha256: dd5cc11e13494f432d15939c3aa8ae76844c42b723398643ce9addb88a5ed420
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "0.4.0+2"
|
|
||||||
vm_service:
|
vm_service:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -1365,14 +1317,6 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "15.0.2"
|
version: "15.0.2"
|
||||||
volume_controller:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: volume_controller
|
|
||||||
sha256: "5c1a13d2ea99d2f6753e7c660d0d3fab541f36da3999cafeb17b66fe49759ad7"
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "3.4.1"
|
|
||||||
wakelock_plus:
|
wakelock_plus:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -1437,14 +1381,6 @@ packages:
|
|||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.3"
|
version: "3.1.3"
|
||||||
youtube_explode_dart:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: youtube_explode_dart
|
|
||||||
sha256: "3d731d71df9901b1915bae806781df519cff32517e36db279f844ae619669e45"
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "3.0.5"
|
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.10.3 <4.0.0"
|
dart: ">=3.10.3 <4.0.0"
|
||||||
flutter: ">=3.38.4"
|
flutter: ">=3.38.4"
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ dependencies:
|
|||||||
device_info_plus: ^11.3.0
|
device_info_plus: ^11.3.0
|
||||||
image_editor_plus: ^1.0.6
|
image_editor_plus: ^1.0.6
|
||||||
path_provider: ^2.1.5
|
path_provider: ^2.1.5
|
||||||
omni_video_player: ^3.5.3
|
|
||||||
cached_network_image: ^3.4.1
|
cached_network_image: ^3.4.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user