Skip to content

Commit 1468661

Browse files
authored
chore : dependencies upgrade (#80)
1 parent 0fa83cb commit 1468661

File tree

9 files changed

+187
-151
lines changed

9 files changed

+187
-151
lines changed

lib/Screens/Anime/Player/Player.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,9 @@ class MediaPlayerState extends State<MediaPlayer>
385385
var _defaultBrightness = 0.0;
386386

387387
Future<void> _handleVolumeAndBrightness() async {
388-
VolumeController().showSystemUI = false;
389-
_volumeValue.value = await VolumeController().getVolume();
390-
VolumeController().listener((value) {
388+
VolumeController.instance.showSystemUI = false;
389+
_volumeValue.value = await VolumeController.instance.getVolume();
390+
VolumeController.instance.addListener((value) {
391391
if (mounted && !_volumeInterceptEventStream) {
392392
_volumeValue.value = value;
393393
}
@@ -409,7 +409,7 @@ class MediaPlayerState extends State<MediaPlayer>
409409
Future<void> setVolume(double value) async {
410410
if (!isMobile) return;
411411
try {
412-
VolumeController().setVolume(value);
412+
VolumeController.instance.setVolume(value);
413413
} catch (_) {}
414414
_volumeValue.value = value;
415415
_volumeIndicator.value = true;

lib/main.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import 'Theme/Colors.dart';
4343
import 'Theme/ThemeManager.dart';
4444
import 'Theme/ThemeProvider.dart';
4545
import 'logger.dart';
46+
import 'package:volume_controller/volume_controller.dart';
4647

4748
late Isar isar;
4849
WebViewEnvironment? webViewEnvironment;
@@ -240,13 +241,37 @@ late FloatingBottomNavBar navbar;
240241

241242
class MainActivityState extends State<MainActivity> {
242243
int _selectedIndex = 1;
244+
late final VolumeController _volumeController;
245+
late final StreamSubscription<double> _subscription;
246+
double _currentVolume = 0;
247+
double _volumeValue = 0;
248+
bool _isMuted = false;
243249

244250
void _onTabSelected(int index) => setState(() => _selectedIndex = index);
245251

246252
@override
247253
void initState() {
248254
super.initState();
249255
checkForUpdate();
256+
_volumeController = VolumeController.instance;
257+
258+
259+
// Listen to system volume change
260+
_subscription = _volumeController.addListener((volume) {
261+
setState(() => _volumeValue = volume);
262+
}, fetchInitialVolume: true);
263+
264+
_volumeController
265+
.isMuted()
266+
.then((isMuted) => setState(() => _isMuted = isMuted));
267+
268+
}
269+
@override
270+
void dispose(){
271+
_subscription.cancel();
272+
super.dispose();
273+
274+
250275
}
251276

252277
@override

linux/flutter/generated_plugin_registrant.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <media_kit_video/media_kit_video_plugin.h>
1616
#include <screen_retriever_linux/screen_retriever_linux_plugin.h>
1717
#include <url_launcher_linux/url_launcher_plugin.h>
18+
#include <volume_controller/volume_controller_plugin.h>
1819
#include <window_manager/window_manager_plugin.h>
1920
#include <window_to_front/window_to_front_plugin.h>
2021

@@ -46,6 +47,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
4647
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
4748
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
4849
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
50+
g_autoptr(FlPluginRegistrar) volume_controller_registrar =
51+
fl_plugin_registry_get_registrar_for_plugin(registry, "VolumeControllerPlugin");
52+
volume_controller_plugin_register_with_registrar(volume_controller_registrar);
4953
g_autoptr(FlPluginRegistrar) window_manager_registrar =
5054
fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin");
5155
window_manager_plugin_register_with_registrar(window_manager_registrar);

linux/flutter/generated_plugins.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
1212
media_kit_video
1313
screen_retriever_linux
1414
url_launcher_linux
15+
volume_controller
1516
window_manager
1617
window_to_front
1718
)

macos/Flutter/GeneratedPluginRegistrant.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import share_plus
2424
import shared_preferences_foundation
2525
import sqflite_darwin
2626
import url_launcher_macos
27+
import volume_controller
2728
import wakelock_plus
2829
import webview_flutter_wkwebview
2930
import window_manager
@@ -49,8 +50,9 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
4950
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
5051
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
5152
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
53+
VolumeControllerPlugin.register(with: registry.registrar(forPlugin: "VolumeControllerPlugin"))
5254
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
53-
FLTWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "FLTWebViewFlutterPlugin"))
55+
WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin"))
5456
WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin"))
5557
WindowToFrontPlugin.register(with: registry.registrar(forPlugin: "WindowToFrontPlugin"))
5658
}

0 commit comments

Comments
 (0)