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,
}) async {
Duration? seek = defaultST ?? playedTime;
if (seek == null || seek == Duration.zero) {
seek = getFirstSegment();
}
if (seek == .zero) seek = null;
seek ??= getFirstSegment();
await plPlayerController.setDataSource(
isFileSource
? FileSource(
@@ -858,36 +857,49 @@ class VideoDetailController extends GetxController
displayTime: const Duration(seconds: 3),
);
}
if (data.dash == null && data.durl != null) {
final first = data.durl!.first;
videoUrl = VideoUtils.getCdnUrl(first.playUrls);
audioUrl = '';
// 实际为FLV/MP4格式但已被淘汰这里仅做兜底处理
final videoQuality = VideoQuality.fromCode(data.quality!);
firstVideo = VideoItem(
id: data.quality!,
baseUrl: videoUrl,
codecs: 'avc1',
quality: videoQuality,
);
_setVideoHeight();
currentDecodeFormats = VideoDecodeFormatType.AVC;
currentVideoQa.value = videoQuality;
await _initPlayerIfNeeded(autoFullScreenFlag);
isQuerying = false;
return;
}
if (data.dash == null) {
SmartDialog.showToast('视频资源不存在');
_autoPlay.value = false;
videoState.value = false;
if (plPlayerController.isFullScreen.value) {
plPlayerController.triggerFullScreen(status: false);
if (data.durl case final durl?) {
// 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 = '';
// 实际为FLV/MP4格式但已被淘汰这里仅做兜底处理
final videoQuality = VideoQuality.fromCode(data.quality!);
firstVideo = VideoItem(
id: data.quality!,
baseUrl: videoUrl,
codecs: 'avc1',
quality: videoQuality,
);
_setVideoHeight();
currentDecodeFormats = VideoDecodeFormatType.AVC;
currentVideoQa.value = videoQuality;
await _initPlayerIfNeeded(autoFullScreenFlag);
isQuerying = false;
return;
} else {
SmartDialog.showToast('视频资源不存在');
_autoPlay.value = false;
videoState.value = false;
if (plPlayerController.isFullScreen.value) {
plPlayerController.triggerFullScreen(status: false);
}
isQuerying = false;
return;
}
isQuerying = false;
return;
}
final List<VideoItem> videoList = data.dash!.video!;
// if (kDebugMode) debugPrint("allVideosList:${allVideosList}");
// 当前可播放的最高质量视频

View File

@@ -572,7 +572,17 @@ class HeaderControlState extends State<HeaderControl>
onTap: () {
plPlayerController.onlyPlayAudio.value =
!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: " 听视频 ",
selectStatus: onlyPlayAudio,