From 391c11831dec845cf2b61e7ed0c244b8f6d9efef Mon Sep 17 00:00:00 2001 From: orz12 Date: Sun, 7 Jul 2024 15:15:53 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E9=BB=98=E8=AE=A4=E7=BC=93=E5=86=B2?= =?UTF-8?q?=E5=8C=BA=E8=B0=83=E5=B0=8F=EF=BC=9B=E5=BD=93=E5=89=8D=E8=A7=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=E6=9F=A5=E6=89=BE+=E5=85=9C?= =?UTF-8?q?=E5=BA=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/video/play/url.dart | 19 +++++++++++++++++++ lib/pages/setting/video_setting.dart | 2 +- lib/pages/video/detail/controller.dart | 18 +++++++++++------- lib/plugin/pl_player/controller.dart | 2 +- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/models/video/play/url.dart b/lib/models/video/play/url.dart index bd3e3f3e..239ab1c6 100644 --- a/lib/models/video/play/url.dart +++ b/lib/models/video/play/url.dart @@ -178,6 +178,25 @@ class VideoItem { codecid = json['codecid']; quality = VideoQuality.values.firstWhere((i) => i.code == json['id']); } + + Map toJson() { + Map data = {}; + data['id'] = id; + data['baseUrl'] = baseUrl; + data['backupUrl'] = backupUrl; + data['bandWidth'] = bandWidth; + data['mime_type'] = mimeType; + data['codecs'] = codecs; + data['width'] = width; + data['height'] = height; + data['frameRate'] = frameRate; + data['sar'] = sar; + data['startWithSap'] = startWithSap; + data['segmentBase'] = segmentBase; + data['codecid'] = codecid; + data['quality'] = quality; + return data; + } } class AudioItem { diff --git a/lib/pages/setting/video_setting.dart b/lib/pages/setting/video_setting.dart index e7d8f58b..91c40b24 100644 --- a/lib/pages/setting/video_setting.dart +++ b/lib/pages/setting/video_setting.dart @@ -207,7 +207,7 @@ class _VideoSettingState extends State { const SetSwitchItem( title: '扩大缓冲区', leading: Icon(Icons.storage_outlined), - subTitle: '默认缓冲区为视频5MB/直播32MB,开启后为32MB/64MB,加载时间变长', + subTitle: '默认缓冲区为视频3MB/直播16MB,开启后为32MB/64MB,加载时间变长', setKey: SettingBoxKey.expandBuffer, defaultVal: false, ), diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index 073b3cd6..655c6e16 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -206,7 +206,9 @@ class VideoDetailController extends GetxController } if (flag == 1) { //currentDecodeFormats - firstVideo = videoList.first; + firstVideo = videoList.firstWhere( + (i) => i.codecs!.startsWith(currentDecodeFormats.code), + orElse: () => videoList.first); } else { if (currentVideoQa == VideoQuality.dolbyVision) { currentDecodeFormats = @@ -217,12 +219,14 @@ class VideoDetailController extends GetxController currentDecodeFormats = defaultDecodeFormats; firstVideo = videoList.firstWhere( (i) => i.codecs!.startsWith(defaultDecodeFormats.code), + orElse: () => videoList.first, ); } else if (flag == 4) { //secondDecodeFormats currentDecodeFormats = secondDecodeFormats; firstVideo = videoList.firstWhere( (i) => i.codecs!.startsWith(secondDecodeFormats.code), + orElse: () => videoList.first, ); } else if (flag == 0) { currentDecodeFormats = @@ -312,11 +316,10 @@ class VideoDetailController extends GetxController defaultST = Duration.zero; // 实际为FLV/MP4格式,但已被淘汰,这里仅做兜底处理 firstVideo = VideoItem( - id: data.quality!, - baseUrl: videoUrl, - codecs: 'avc1', - quality: VideoQualityCode.fromCode(data.quality!)! - ); + id: data.quality!, + baseUrl: videoUrl, + codecs: 'avc1', + quality: VideoQualityCode.fromCode(data.quality!)!); currentDecodeFormats = VideoDecodeFormatsCode.fromString('avc1')!; currentVideoQa = VideoQualityCode.fromCode(data.quality!)!; if (autoPlay.value) { @@ -390,7 +393,8 @@ class VideoDetailController extends GetxController late AudioItem? firstAudio; final List audiosList = data.dash!.audio!; - if (data.dash!.dolby?.audio != null && data.dash!.dolby!.audio!.isNotEmpty) { + if (data.dash!.dolby?.audio != null && + data.dash!.dolby!.audio!.isNotEmpty) { // 杜比 audiosList.insert(0, data.dash!.dolby!.audio!.first); } diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 5c5736dd..32a5cfba 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -505,7 +505,7 @@ class PlPlayerController { int bufferSize = setting.get(SettingBoxKey.expandBuffer, defaultValue: false) ? (videoType.value == 'live' ? 64 * 1024 * 1024 : 32 * 1024 * 1024) - : (videoType.value == 'live' ? 32 * 1024 * 1024 : 5 * 1024 * 1024); + : (videoType.value == 'live' ? 16 * 1024 * 1024 : 3 * 1024 * 1024); Player player = _videoPlayerController ?? Player( configuration: PlayerConfiguration(