mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 默认缓冲区调小;当前解码格式查找+兜底
This commit is contained in:
@@ -178,6 +178,25 @@ class VideoItem {
|
||||
codecid = json['codecid'];
|
||||
quality = VideoQuality.values.firstWhere((i) => i.code == json['id']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, dynamic> data = <String, dynamic>{};
|
||||
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 {
|
||||
|
||||
@@ -207,7 +207,7 @@ class _VideoSettingState extends State<VideoSetting> {
|
||||
const SetSwitchItem(
|
||||
title: '扩大缓冲区',
|
||||
leading: Icon(Icons.storage_outlined),
|
||||
subTitle: '默认缓冲区为视频5MB/直播32MB,开启后为32MB/64MB,加载时间变长',
|
||||
subTitle: '默认缓冲区为视频3MB/直播16MB,开启后为32MB/64MB,加载时间变长',
|
||||
setKey: SettingBoxKey.expandBuffer,
|
||||
defaultVal: false,
|
||||
),
|
||||
|
||||
@@ -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<AudioItem> 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);
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user