From 2562d3d4b6d23d294d4f561402982fee429098e5 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Fri, 21 Nov 2025 02:36:37 +0100 Subject: [PATCH] fix: linux audio output issues --- lib/screens/video_player_screen.dart | 29 +++++++++++-------- .../sheets/video_settings_sheet.dart | 2 +- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/screens/video_player_screen.dart b/lib/screens/video_player_screen.dart index 63522dcc..187ce3a0 100644 --- a/lib/screens/video_player_screen.dart +++ b/lib/screens/video_player_screen.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -206,6 +207,21 @@ class VideoPlayerScreenState extends State .getEnableHardwareDecoding(); final debugLoggingEnabled = settingsService.getEnableDebugLogging(); + // Build MPV configuration + final config = { + 'sub-font-size': settingsService.getSubtitleFontSize().toString(), + 'sub-color': settingsService.getSubtitleTextColor(), + 'sub-border-size': settingsService.getSubtitleBorderSize().toString(), + 'sub-border-color': settingsService.getSubtitleBorderColor(), + 'sub-back-color': + '#${(settingsService.getSubtitleBackgroundOpacity() * 255 / 100).toInt().toRadixString(16).padLeft(2, '0').toUpperCase()}${settingsService.getSubtitleBackgroundColor().replaceFirst('#', '')}', + 'sub-ass-override': 'no', + }; + + if (Platform.isIOS) { + config['audio-exclusive'] = 'yes'; + } + // Create player with configuration player = Player( configuration: PlayerConfiguration( @@ -214,18 +230,7 @@ class VideoPlayerScreenState extends State libassAndroidFontName: 'Droid Sans Fallback', bufferSize: bufferSizeBytes, logLevel: debugLoggingEnabled ? MPVLogLevel.debug : MPVLogLevel.error, - mpvConfiguration: { - 'sub-font-size': settingsService.getSubtitleFontSize().toString(), - 'sub-color': settingsService.getSubtitleTextColor(), - 'sub-border-size': settingsService - .getSubtitleBorderSize() - .toString(), - 'sub-border-color': settingsService.getSubtitleBorderColor(), - 'sub-back-color': - '#${(settingsService.getSubtitleBackgroundOpacity() * 255 / 100).toInt().toRadixString(16).padLeft(2, '0').toUpperCase()}${settingsService.getSubtitleBackgroundColor().replaceFirst('#', '')}', - 'sub-ass-override': 'no', - 'audio-exclusive': 'yes', - }, + mpvConfiguration: config, ), ); controller = VideoController( diff --git a/lib/widgets/video_controls/sheets/video_settings_sheet.dart b/lib/widgets/video_controls/sheets/video_settings_sheet.dart index 51ee84ed..a0c301c7 100644 --- a/lib/widgets/video_controls/sheets/video_settings_sheet.dart +++ b/lib/widgets/video_controls/sheets/video_settings_sheet.dart @@ -278,7 +278,7 @@ class _VideoSettingsSheetState extends State { snapshot.data ?? widget.player.state.audioDevice; final deviceLabel = currentDevice.description.isEmpty ? currentDevice.name - : currentDevice.description; + : '${currentDevice.name} ยท ${currentDevice.description}'; return _SettingsMenuItem( icon: Icons.speaker,