From 07d1a0a7482b6cf6ae5a45cdf78a727f635468da Mon Sep 17 00:00:00 2001 From: Ritik Harchani Date: Sun, 11 Oct 2020 14:58:53 +0530 Subject: [PATCH] fix: Prevent screen from sleeping while streaming videos --- lib/screens/vlc_stream.dart | 3 ++ pubspec.lock | 89 ++++++++++++++++++++++++++++--------- pubspec.yaml | 1 + 3 files changed, 73 insertions(+), 20 deletions(-) diff --git a/lib/screens/vlc_stream.dart b/lib/screens/vlc_stream.dart index ca8326b..075a0c9 100644 --- a/lib/screens/vlc_stream.dart +++ b/lib/screens/vlc_stream.dart @@ -3,6 +3,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_vlc_player/flutter_vlc_player.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:rutorrentflutter/utilities/constants.dart'; +import 'package:wakelock/wakelock.dart'; class VlcStream extends StatefulWidget { final String streamUrl; @@ -77,6 +78,7 @@ class _VlcStreamState extends State { super.initState(); _initVlcPlayer(); SystemChrome.setEnabledSystemUIOverlays([]); + Wakelock.enable(); } @override @@ -193,6 +195,7 @@ class _VlcStreamState extends State { @override void dispose() { + Wakelock.disable(); SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); super.dispose(); } diff --git a/pubspec.lock b/pubspec.lock index 14a65ea..b8328a0 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,42 +7,42 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.2" + version: "2.5.0-nullsafety.1" boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0-nullsafety.3" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.1.3" + version: "1.2.0-nullsafety.1" clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.1.0-nullsafety.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.13" + version: "1.15.0-nullsafety.3" convert: dependency: transitive description: @@ -57,6 +57,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.0" + csslib: + dependency: transitive + description: + name: csslib + url: "https://pub.dartlang.org" + source: hosted + version: "0.16.2" cupertino_icons: dependency: "direct main" description: @@ -77,7 +84,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" ffi: dependency: transitive description: @@ -177,6 +184,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "8.8.1" + html: + dependency: transitive + description: + name: html + url: "https://pub.dartlang.org" + source: hosted + version: "0.14.0+4" http: dependency: "direct main" description: @@ -191,6 +205,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" + import_js_library: + dependency: transitive + description: + name: import_js_library + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" intl: dependency: "direct main" description: @@ -198,20 +219,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.16.1" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.2" matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.8" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" modal_bottom_sheet: dependency: "direct main" description: @@ -253,7 +281,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.1" path_provider: dependency: "direct main" description: @@ -377,56 +405,77 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.7.0" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.5" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.17" + version: "0.2.19-nullsafety.2" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0-nullsafety.3" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.3" + wakelock: + dependency: "direct main" + description: + name: wakelock + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+1" + wakelock_platform_interface: + dependency: transitive + description: + name: wakelock_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.0" + wakelock_web: + dependency: transitive + description: + name: wakelock_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.0+2" xdg_directories: dependency: transitive description: @@ -442,5 +491,5 @@ packages: source: hosted version: "3.6.1" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" - flutter: ">=1.16.0 <2.0.0" + dart: ">=2.10.0-110 <2.11.0" + flutter: ">=1.20.0 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 1020cee..c7e1828 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -30,6 +30,7 @@ dependencies: flare_splash_screen: ^3.0.1 flutter_vlc_player: ^3.0.6 package_info: ^0.4.3 + wakelock: ^0.2.0+1 dev_dependencies: flutter_test: