feat: 倍速、画质、音质调节

This commit is contained in:
guozhigq
2023-07-31 23:20:49 +08:00
parent e892452bcd
commit b947397333
11 changed files with 818 additions and 177 deletions

View File

@ -0,0 +1,91 @@
enum VideoQuality {
speed240,
flunt360,
clear480,
high720,
high72060,
high1080,
high1080plus,
high108060,
super4K,
hdr,
dolbyVision,
super8k
}
extension VideoQualityCode on VideoQuality {
static final List<int> _codeList = [
6,
16,
32,
64,
74,
80,
112,
116,
120,
125,
126,
127,
];
int get code => _codeList[index];
static VideoQuality? fromCode(int code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return VideoQuality.values[index];
}
return null;
}
}
extension VideoQualityDesc on VideoQuality {
static final List<String> _descList = [
'240P 极速',
'360P 流畅',
'480P 清晰',
'720P 高清',
'720P60 高帧率',
'1080P 高清',
'1080P+ 高码率',
'1080P60 高帧率',
'4K 超清',
'HDR 真彩色',
'杜比视界',
'8K 超高清'
];
get description => _descList[index];
}
///
enum AudioQuality { k64, k132, k192, dolby, hiRes }
extension AudioQualityCode on AudioQuality {
static final List<int> _codeList = [
30216,
30232,
30280,
30250,
30251,
];
int get code => _codeList[index];
static AudioQuality? fromCode(int code) {
final index = _codeList.indexOf(code);
if (index != -1) {
return AudioQuality.values[index];
}
return null;
}
}
extension AudioQualityDesc on AudioQuality {
static final List<String> _descList = [
'64K',
'132K',
'192K',
'杜比全景声',
'Hi-Res无损',
];
get description => _descList[index];
}

View File

@ -1,3 +1,5 @@
import 'package:pilipala/models/video/play/quality.dart';
class PlayUrlModel {
PlayUrlModel({
this.from,
@ -32,7 +34,7 @@ class PlayUrlModel {
String? seekParam;
String? seekType;
Dash? dash;
List? supportFormats;
List<FormatItem>? supportFormats;
// String? highFormat;
int? lastPlayTime;
int? lastPlayCid;
@ -51,7 +53,11 @@ class PlayUrlModel {
seekParam = json['seek_param'];
seekType = json['seek_type'];
dash = Dash.fromJson(json['dash']);
supportFormats = json['support_formats'];
supportFormats = json['support_formats'] != null
? json['support_formats']
.map<FormatItem>((e) => FormatItem.fromJson(e))
.toList()
: [];
lastPlayTime = json['last_play_time'];
lastPlayCid = json['last_play_cid'];
}
@ -101,6 +107,7 @@ class VideoItem {
this.startWithSap,
this.segmentBase,
this.codecid,
this.quality,
});
int? id;
@ -116,6 +123,7 @@ class VideoItem {
int? startWithSap;
Map? segmentBase;
int? codecid;
VideoQuality? quality;
VideoItem.fromJson(Map<String, dynamic> json) {
id = json['id'];
@ -131,6 +139,7 @@ class VideoItem {
startWithSap = json['startWithSap'];
segmentBase = json['segmentBase'];
codecid = json['codecid'];
quality = VideoQuality.values.firstWhere((i) => i.code == json['id']);
}
}
@ -149,6 +158,7 @@ class AudioItem {
this.startWithSap,
this.segmentBase,
this.codecid,
this.quality,
});
int? id;
@ -164,6 +174,7 @@ class AudioItem {
int? startWithSap;
Map? segmentBase;
int? codecid;
String? quality;
AudioItem.fromJson(Map<String, dynamic> json) {
id = json['id'];
@ -179,5 +190,31 @@ class AudioItem {
startWithSap = json['startWithSap'];
segmentBase = json['segmentBase'];
codecid = json['codecid'];
quality =
AudioQuality.values.firstWhere((i) => i.code == json['id']).description;
}
}
class FormatItem {
FormatItem({
this.quality,
this.format,
this.newDesc,
this.displayDesc,
this.codecs,
});
int? quality;
String? format;
String? newDesc;
String? displayDesc;
List? codecs;
FormatItem.fromJson(Map<String, dynamic> json) {
quality = json['quality'];
format = json['format'];
newDesc = json['new_description'];
displayDesc = json['display_desc'];
codecs = json['codecs'];
}
}