opt: audio uri

This commit is contained in:
My-Responsitories
2026-02-09 00:17:41 +08:00
parent 0460030a2b
commit 78739d9c0a

View File

@@ -817,6 +817,8 @@ class PlPlayerController with BlockConfigMixin {
}
}
final Map<String, String> extras = {};
// 音轨
final String audioUri;
if (isFileSource) {
@@ -825,12 +827,12 @@ class PlPlayerController with BlockConfigMixin {
: path.join(dirPath!, typeTag!, PathUtils.audioNameType2);
} else if (dataSource.audioSource?.isNotEmpty == true) {
audioUri = Platform.isWindows
? dataSource.audioSource!.replaceAll(';', '\\;')
: dataSource.audioSource!.replaceAll(':', '\\:');
? dataSource.audioSource!.replaceAll(';', r'\;')
: dataSource.audioSource!.replaceAll(':', r'\:');
} else {
audioUri = '';
}
await pp.setProperty('audio-files', audioUri);
if (audioUri.isNotEmpty) extras['audio-files'] = '"$audioUri"';
_videoController ??= VideoController(
player,
@@ -843,8 +845,7 @@ class PlPlayerController with BlockConfigMixin {
player.setPlaylistMode(looping);
final Map<String, String>? filters;
if (Platform.isAndroid) {
if (kDebugMode || Platform.isAndroid) {
String audioNormalization = AudioNormalization.getParamFromConfig(
Pref.audioNormalization,
);
@@ -867,11 +868,9 @@ class PlPlayerController with BlockConfigMixin {
AudioNormalization.getParamFromConfig(Pref.fallbackNormalization),
);
}
filters = audioNormalization.isEmpty
? null
: {'lavfi-complex': '"[aid1] $audioNormalization [ao]"'};
} else {
filters = null;
if (audioNormalization.isNotEmpty) {
extras['lavfi-complex'] = '"[aid1] $audioNormalization [ao]"';
}
}
// if (kDebugMode) debugPrint(filters.toString());
@@ -895,7 +894,7 @@ class PlPlayerController with BlockConfigMixin {
videoUri,
httpHeaders: dataSource.httpHeaders,
start: seekTo,
extras: filters,
extras: extras.isEmpty ? null : extras,
),
play: false,
);
@@ -915,16 +914,14 @@ class PlPlayerController with BlockConfigMixin {
SmartDialog.showToast('视频源为空,请重新进入本页面');
return false;
}
String? audioUri;
if (!isLive) {
if (dataSource.audioSource.isNullOrEmpty) {
SmartDialog.showToast('音频源为空');
} else {
await (_videoPlayerController!.platform!).setProperty(
'audio-files',
Platform.isWindows
? dataSource.audioSource!.replaceAll(';', '\\;')
: dataSource.audioSource!.replaceAll(':', '\\:'),
);
audioUri = Platform.isWindows
? dataSource.audioSource!.replaceAll(';', '\\;')
: dataSource.audioSource!.replaceAll(':', '\\:');
}
}
await _videoPlayerController!.open(
@@ -932,6 +929,7 @@ class PlPlayerController with BlockConfigMixin {
dataSource.videoSource!,
httpHeaders: dataSource.httpHeaders,
start: position.value,
extras: audioUri == null ? null : {'audio-files': '"$audioUri"'},
),
play: true,
);
@@ -1069,7 +1067,7 @@ class PlPlayerController with BlockConfigMixin {
if (kDebugMode)
controllerStream.log.listen(((PlayerLog log) {
if (log.level == 'error' || log.level == 'fatal') {
Utils.reportError('${log.prefix}: ${log.text}', null);
Utils.reportError('${log.level}: ${log.prefix}: ${log.text}', null);
} else {
debugPrint(log.toString());
}