保持屏幕 唤醒 + 隐藏 系统状态栏
This commit is contained in:
parent
1d621444fb
commit
174f3e9341
@ -1,8 +1,17 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.7.10'
|
ext.kotlin_version = '1.7.10'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||||
mavenCentral()
|
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||||
|
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
|
||||||
|
maven {
|
||||||
|
allowInsecureProtocol = true
|
||||||
|
url 'https://maven.aliyun.com/repository/jcenter'
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
allowInsecureProtocol = true
|
||||||
|
url 'http://maven.aliyun.com/nexus/content/groups/public'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -13,8 +22,17 @@ buildscript {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
maven { url 'https://maven.aliyun.com/repository/google' }
|
||||||
mavenCentral()
|
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||||
|
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
|
||||||
|
maven {
|
||||||
|
allowInsecureProtocol = true
|
||||||
|
url 'https://maven.aliyun.com/repository/jcenter'
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
allowInsecureProtocol = true
|
||||||
|
url 'http://maven.aliyun.com/nexus/content/groups/public'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
63
lib/animate/fade.dart
Normal file
63
lib/animate/fade.dart
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class Fade extends StatefulWidget {
|
||||||
|
final Duration duration;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const Fade({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
this.duration = const Duration(milliseconds: 500),
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() {
|
||||||
|
return _FadeTransitionState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FadeTransitionState extends State<Fade> with TickerProviderStateMixin {
|
||||||
|
late final AnimationController _controller = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: widget.duration,
|
||||||
|
)..forward();
|
||||||
|
|
||||||
|
late final Animation<double> _animation =
|
||||||
|
// 补间动画
|
||||||
|
// Tween<double>(
|
||||||
|
// begin: 0,
|
||||||
|
// end: 1,
|
||||||
|
// ).animate(_controller);
|
||||||
|
|
||||||
|
// 线性动画
|
||||||
|
CurvedAnimation(parent: _controller, curve: Curves.decelerate);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
body: Center(
|
||||||
|
child: FadeTransition(
|
||||||
|
opacity: _animation,
|
||||||
|
child: widget.child,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget fade({
|
||||||
|
required Widget child,
|
||||||
|
Duration duration = const Duration(milliseconds: 100),
|
||||||
|
}) {
|
||||||
|
return Fade(
|
||||||
|
duration: duration,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
74
lib/animate/slide.dart
Normal file
74
lib/animate/slide.dart
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
// 滑动动画
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class Slide extends StatefulWidget {
|
||||||
|
final Duration duration;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
const Slide({
|
||||||
|
super.key,
|
||||||
|
required this.child,
|
||||||
|
this.duration = const Duration(milliseconds: 1000),
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() {
|
||||||
|
return _SlideTransitionState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SlideTransitionState extends State<Slide> with TickerProviderStateMixin {
|
||||||
|
late final AnimationController _controller = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: widget.duration,
|
||||||
|
)..forward();
|
||||||
|
|
||||||
|
late final Animation<double> _animation =
|
||||||
|
// 补间动画
|
||||||
|
// Tween<double>(
|
||||||
|
// begin: 0,
|
||||||
|
// end: 1,
|
||||||
|
// ).animate(_controller);
|
||||||
|
|
||||||
|
// 线性动画
|
||||||
|
CurvedAnimation(parent: _controller, curve: Curves.decelerate);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
body: Center(
|
||||||
|
child: _slide(
|
||||||
|
animation: _animation,
|
||||||
|
child: widget.child,
|
||||||
|
dy: 0,
|
||||||
|
dx: 1
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AnimatedWidget _slide({
|
||||||
|
required Animation<double> animation,
|
||||||
|
required Widget child,
|
||||||
|
double dx = 0,
|
||||||
|
double dy = -1,
|
||||||
|
}) {
|
||||||
|
return SlideTransition(
|
||||||
|
position: animation.drive(
|
||||||
|
Tween<Offset>(
|
||||||
|
begin: Offset(dx, dy),
|
||||||
|
end: Offset.zero,
|
||||||
|
).chain(CurveTween(curve: Curves.easeInOutSine)),
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
@ -1,8 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:matrix_flutter_app_v2/animate/slide.dart';
|
||||||
import 'package:matrix_flutter_app_v2/view/home.dart';
|
import 'package:matrix_flutter_app_v2/view/home.dart';
|
||||||
import 'package:matrix_flutter_app_v2/view/media_query.dart';
|
import 'package:matrix_flutter_app_v2/view/media_query.dart';
|
||||||
import 'package:matrix_flutter_app_v2/view/video.dart';
|
import 'package:matrix_flutter_app_v2/view/video.dart';
|
||||||
|
|
||||||
|
import 'animate/fade.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
@ -23,9 +26,10 @@ class MyApp extends StatelessWidget {
|
|||||||
initialRoute: "/",
|
initialRoute: "/",
|
||||||
routes: {
|
routes: {
|
||||||
'/': (ctx) => const MyHomePage(title: 'Flutter Demo Home Page'),
|
'/': (ctx) => const MyHomePage(title: 'Flutter Demo Home Page'),
|
||||||
'/media': (ctx) => const CustomMediaQuery(),
|
'/media': (ctx) => const Slide(child: CustomMediaQuery()),
|
||||||
// '/video': (ctx)=> const CustomVideoPlayer(url: "http://[2409:8087:1e03:21::2]:6060/cms001/ch00000090990000001022/index.m3u8")
|
// '/video': (ctx)=> const CustomVideoPlayer(url: "http://[2409:8087:1e03:21::2]:6060/cms001/ch00000090990000001022/index.m3u8")
|
||||||
'/video': (ctx)=> const CustomVideoPlayer(url: "http://10.10.10.200:20480/d/sk-pi/sk-16t/Movie/%E5%A5%87%E5%BC%82%E5%8D%9A%E5%A3%AB.MP4?sign=6uVNOeLwBBCB-pVUz1WdLnAS7kWtXq6PQJ5TcCrXKFY=:0")
|
//'/video': (ctx)=> const CustomVideoPlayer(url: "http://10.10.10.200:20480/d/sk-pi/sk-16t/Movie/%E5%A5%87%E5%BC%82%E5%8D%9A%E5%A3%AB.MP4?sign=6uVNOeLwBBCB-pVUz1WdLnAS7kWtXq6PQJ5TcCrXKFY=:0")
|
||||||
|
'/video': (ctx)=> const CustomVideoPlayer(url: "http://[2409:8087:2001:20:2800:0:df6e:eb27]:80/wh7f454c46tw3352677969_1732462333/ott.mobaibox.com/PLTV/3/224/3221228524/index.m3u8")
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'dart:io' show Platform;
|
|
||||||
class MyHomePage extends StatefulWidget {
|
class MyHomePage extends StatefulWidget {
|
||||||
const MyHomePage({super.key, required this.title});
|
const MyHomePage({super.key, required this.title});
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:video_player/video_player.dart';
|
import 'package:video_player/video_player.dart';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:wakelock/wakelock.dart';
|
||||||
|
|
||||||
class CustomVideoPlayer extends StatefulWidget {
|
class CustomVideoPlayer extends StatefulWidget {
|
||||||
final String url;
|
final String url;
|
||||||
|
|
||||||
@ -26,9 +28,10 @@ class _CustomVideoPlayerState extends State<CustomVideoPlayer> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom]);
|
||||||
SystemChrome.setPreferredOrientations(
|
SystemChrome.setPreferredOrientations(
|
||||||
[DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
|
[DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
|
||||||
|
Wakelock.enable();
|
||||||
initVideoPlayer();
|
initVideoPlayer();
|
||||||
// initFijkPlayer();
|
// initFijkPlayer();
|
||||||
}
|
}
|
||||||
@ -117,6 +120,7 @@ class _CustomVideoPlayerState extends State<CustomVideoPlayer> {
|
|||||||
// appBar: AppBar(
|
// appBar: AppBar(
|
||||||
// toolbarHeight: 35,
|
// toolbarHeight: 35,
|
||||||
// ),
|
// ),
|
||||||
|
backgroundColor: Colors.black,
|
||||||
body: player == null
|
body: player == null
|
||||||
? PopScope(
|
? PopScope(
|
||||||
onPopInvoked: (val) {
|
onPopInvoked: (val) {
|
||||||
@ -173,9 +177,11 @@ class _CustomVideoPlayerState extends State<CustomVideoPlayer> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
Wakelock.disable();
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.top]);
|
||||||
SystemChrome.setPreferredOrientations([]);
|
SystemChrome.setPreferredOrientations([]);
|
||||||
player?.stop().then((value) => player?.dispose());
|
player?.stop().then((value) => player?.dispose());
|
||||||
_controller?.dispose();
|
_controller?.dispose();
|
||||||
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,9 @@ import FlutterMacOS
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
import video_player_avfoundation
|
import video_player_avfoundation
|
||||||
|
import wakelock_macos
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
|
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
|
||||||
|
WakelockMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockMacosPlugin"))
|
||||||
}
|
}
|
||||||
|
66
pubspec.lock
66
pubspec.lock
@ -65,6 +65,14 @@ packages:
|
|||||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.1"
|
version: "1.3.1"
|
||||||
|
ffi:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: ffi
|
||||||
|
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
fijkplayer:
|
fijkplayer:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -104,6 +112,14 @@ packages:
|
|||||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.15.4"
|
version: "0.15.4"
|
||||||
|
js:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: js
|
||||||
|
sha256: cf7243a0c29626284ada2add68a33f5b1102affe3509393e75136e0f6616bd68
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "0.6.8"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -253,6 +269,46 @@ packages:
|
|||||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.2"
|
||||||
|
wakelock:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: wakelock
|
||||||
|
sha256: "769ecf42eb2d07128407b50cb93d7c10bd2ee48f0276ef0119db1d25cc2f87db"
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "0.6.2"
|
||||||
|
wakelock_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: wakelock_macos
|
||||||
|
sha256: "047c6be2f88cb6b76d02553bca5a3a3b95323b15d30867eca53a19a0a319d4cd"
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "0.4.0"
|
||||||
|
wakelock_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: wakelock_platform_interface
|
||||||
|
sha256: "1f4aeb81fb592b863da83d2d0f7b8196067451e4df91046c26b54a403f9de621"
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.0"
|
||||||
|
wakelock_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: wakelock_web
|
||||||
|
sha256: "1b256b811ee3f0834888efddfe03da8d18d0819317f20f6193e2922b41a501b5"
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "0.4.0"
|
||||||
|
wakelock_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: wakelock_windows
|
||||||
|
sha256: "857f77b3fe6ae82dd045455baa626bc4b93cb9bb6c86bf3f27c182167c3a5567"
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.1"
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -261,6 +317,14 @@ packages:
|
|||||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.0"
|
version: "0.3.0"
|
||||||
|
win32:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: win32
|
||||||
|
sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.4"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.2.0-194.0.dev <4.0.0"
|
dart: ">=3.2.0-194.0.dev <4.0.0"
|
||||||
flutter: ">=1.12.0"
|
flutter: ">=3.13.0"
|
||||||
|
@ -37,6 +37,7 @@ dependencies:
|
|||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.2
|
||||||
fijkplayer: ^0.11.0
|
fijkplayer: ^0.11.0
|
||||||
video_player: ^2.8.1
|
video_player: ^2.8.1
|
||||||
|
wakelock: ^0.6.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
Reference in New Issue
Block a user