mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 03:06:59 +08:00
fix(player): disable audio normalization on missing audio input (#1865)
* fix(player): disable audio normalization on missing audio input * fix(player): skip normalization when local audio input is missing * fix `hasDashAudio` --------- Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -788,33 +788,32 @@ class PlPlayerController with BlockConfigMixin {
|
||||
extras['audio-files'] =
|
||||
'"${Platform.isWindows ? audio.replaceAll(';', r'\;') : audio.replaceAll(':', r'\:')}"';
|
||||
}
|
||||
}
|
||||
|
||||
if (kDebugMode || Platform.isAndroid) {
|
||||
String audioNormalization = AudioNormalization.getParamFromConfig(
|
||||
Pref.audioNormalization,
|
||||
);
|
||||
if (volume != null && volume.isNotEmpty) {
|
||||
audioNormalization = audioNormalization.replaceFirstMapped(
|
||||
loudnormRegExp,
|
||||
(i) =>
|
||||
'loudnorm=${volume.format(
|
||||
Map.fromEntries(
|
||||
i.group(1)!.split(':').map((item) {
|
||||
final parts = item.split('=');
|
||||
return MapEntry(parts[0].toLowerCase(), num.parse(parts[1]));
|
||||
}),
|
||||
),
|
||||
)}',
|
||||
if (kDebugMode || Platform.isAndroid) {
|
||||
String audioNormalization = AudioNormalization.getParamFromConfig(
|
||||
Pref.audioNormalization,
|
||||
);
|
||||
} else {
|
||||
audioNormalization = audioNormalization.replaceFirst(
|
||||
loudnormRegExp,
|
||||
AudioNormalization.getParamFromConfig(Pref.fallbackNormalization),
|
||||
);
|
||||
}
|
||||
if (audioNormalization.isNotEmpty) {
|
||||
extras['lavfi-complex'] = '"[aid1] $audioNormalization [ao]"';
|
||||
if (volume != null && volume.isNotEmpty) {
|
||||
audioNormalization = audioNormalization.replaceFirstMapped(
|
||||
loudnormRegExp,
|
||||
(i) =>
|
||||
'loudnorm=${volume.format(
|
||||
Map.fromEntries(
|
||||
i.group(1)!.split(':').map((item) {
|
||||
final parts = item.split('=');
|
||||
return MapEntry(parts[0].toLowerCase(), num.parse(parts[1]));
|
||||
}),
|
||||
),
|
||||
)}',
|
||||
);
|
||||
} else {
|
||||
audioNormalization = audioNormalization.replaceFirst(
|
||||
loudnormRegExp,
|
||||
AudioNormalization.getParamFromConfig(Pref.fallbackNormalization),
|
||||
);
|
||||
}
|
||||
if (audioNormalization.isNotEmpty) {
|
||||
extras['lavfi-complex'] = '"[aid1] $audioNormalization [ao]"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -840,21 +839,21 @@ class PlPlayerController with BlockConfigMixin {
|
||||
SmartDialog.showToast('视频源为空,请重新进入本页面');
|
||||
return false;
|
||||
}
|
||||
String? audioUri;
|
||||
if (!isLive) {
|
||||
if (dataSource.audioSource.isNullOrEmpty) {
|
||||
SmartDialog.showToast('音频源为空');
|
||||
final Map<String, String> extras = {};
|
||||
String video = dataSource.videoSource;
|
||||
if (dataSource.audioSource case final audio? when (audio.isNotEmpty)) {
|
||||
if (onlyPlayAudio.value) {
|
||||
video = audio;
|
||||
} else {
|
||||
audioUri = Platform.isWindows
|
||||
? dataSource.audioSource!.replaceAll(';', '\\;')
|
||||
: dataSource.audioSource!.replaceAll(':', '\\:');
|
||||
extras['audio-files'] =
|
||||
'"${Platform.isWindows ? audio.replaceAll(';', r'\;') : audio.replaceAll(':', r'\:')}"';
|
||||
}
|
||||
}
|
||||
await _videoPlayerController!.open(
|
||||
Media(
|
||||
dataSource.videoSource,
|
||||
video,
|
||||
start: position,
|
||||
extras: audioUri == null ? null : {'audio-files': '"$audioUri"'},
|
||||
extras: extras.isEmpty ? null : extras,
|
||||
),
|
||||
play: true,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user