opt: edl file (#2455)

This commit is contained in:
My-Responsitories
2026-07-21 09:02:09 +00:00
committed by GitHub
parent 3a5636ecee
commit dae8df840a
3 changed files with 63 additions and 34 deletions

View File

@@ -717,9 +717,8 @@ class VideoDetailController extends GetxController
bool autoFullScreenFlag = false, bool autoFullScreenFlag = false,
}) async { }) async {
Duration? seek = defaultST ?? playedTime; Duration? seek = defaultST ?? playedTime;
if (seek == null || seek == Duration.zero) { if (seek == .zero) seek = null;
seek = getFirstSegment(); seek ??= getFirstSegment();
}
await plPlayerController.setDataSource( await plPlayerController.setDataSource(
isFileSource isFileSource
? FileSource( ? FileSource(
@@ -858,9 +857,21 @@ class VideoDetailController extends GetxController
displayTime: const Duration(seconds: 3), displayTime: const Duration(seconds: 3),
); );
} }
if (data.dash == null && data.durl != null) { if (data.dash == null) {
final first = data.durl!.first; if (data.durl case final durl?) {
videoUrl = VideoUtils.getCdnUrl(first.playUrls); // it will cause all files to be opened simultaneously
if (durl.length > 1) {
// TODO: refa
final sb = StringBuffer('edl://!no_clip;!no_chapters;');
for (var i in durl) {
final video = VideoUtils.getCdnUrl(i.playUrls);
sb.write('%${video.length}%$video,length=${i.length! / 1000};');
}
videoUrl = sb.toString();
} else {
videoUrl = VideoUtils.getCdnUrl(durl.single.playUrls);
}
audioUrl = ''; audioUrl = '';
// 实际为FLV/MP4格式但已被淘汰这里仅做兜底处理 // 实际为FLV/MP4格式但已被淘汰这里仅做兜底处理
@@ -877,8 +888,7 @@ class VideoDetailController extends GetxController
await _initPlayerIfNeeded(autoFullScreenFlag); await _initPlayerIfNeeded(autoFullScreenFlag);
isQuerying = false; isQuerying = false;
return; return;
} } else {
if (data.dash == null) {
SmartDialog.showToast('视频资源不存在'); SmartDialog.showToast('视频资源不存在');
_autoPlay.value = false; _autoPlay.value = false;
videoState.value = false; videoState.value = false;
@@ -888,6 +898,8 @@ class VideoDetailController extends GetxController
isQuerying = false; isQuerying = false;
return; return;
} }
}
final List<VideoItem> videoList = data.dash!.video!; final List<VideoItem> videoList = data.dash!.video!;
// if (kDebugMode) debugPrint("allVideosList:${allVideosList}"); // if (kDebugMode) debugPrint("allVideosList:${allVideosList}");
// 当前可播放的最高质量视频 // 当前可播放的最高质量视频

View File

@@ -572,7 +572,17 @@ class HeaderControlState extends State<HeaderControl>
onTap: () { onTap: () {
plPlayerController.onlyPlayAudio.value = plPlayerController.onlyPlayAudio.value =
!onlyPlayAudio; !onlyPlayAudio;
widget.videoDetailCtr.playerInit(); final player =
plPlayerController.videoPlayerController!;
if (onlyPlayAudio &&
player.state.tracks.video.length <= 2) {
videoDetailCtr.playerInit();
} else {
player.setProperty(
'file-local-options/vid',
onlyPlayAudio ? 'auto' : 'no',
);
}
}, },
text: " 听视频 ", text: " 听视频 ",
selectStatus: onlyPlayAudio, selectStatus: onlyPlayAudio,

View File

@@ -1,5 +1,5 @@
import 'dart:async' show StreamSubscription, Timer; import 'dart:async' show StreamSubscription, Timer;
import 'dart:convert' show ascii; import 'dart:convert' show ascii, utf8;
import 'dart:io' show Platform; import 'dart:io' show Platform;
import 'dart:math' show max, min; import 'dart:math' show max, min;
import 'dart:ui' as ui; import 'dart:ui' as ui;
@@ -816,8 +816,15 @@ class PlPlayerController with BlockConfigMixin {
if (onlyPlayAudio.value) { if (onlyPlayAudio.value) {
video = audio; video = audio;
} else { } else {
extras['audio-files'] = // dely_open need provide length
'"${Platform.isWindows ? audio.replaceAll(';', r'\;') : audio.replaceAll(':', r'\:')}"'; video =
('edl://'
'!no_clip;!no_chapters;'
// '!delay_open,media_type=video;'
'%${isFileSource ? utf8.encode(video).length : video.length}%$video;'
'!new_stream;!no_clip;!no_chapters;'
// '!delay_open,media_type=audio;'
'%${isFileSource ? utf8.encode(audio).length : audio.length}%$audio');
} }
if (enableAudioNormalization) { if (enableAudioNormalization) {
final String audioNormalization; final String audioNormalization;