Merge branch 'fix'
This commit is contained in:
@ -39,6 +39,14 @@ extension VideoQualityCode on VideoQuality {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int? toCode(VideoQuality quality) {
|
||||||
|
final index = VideoQuality.values.indexOf(quality);
|
||||||
|
if (index != -1 && index < _codeList.length) {
|
||||||
|
return _codeList[index];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension VideoQualityDesc on VideoQuality {
|
extension VideoQualityDesc on VideoQuality {
|
||||||
|
@ -236,6 +236,7 @@ class BangumiIntroController extends GetxController {
|
|||||||
videoDetailCtr.bvid = bvid;
|
videoDetailCtr.bvid = bvid;
|
||||||
videoDetailCtr.cid.value = cid;
|
videoDetailCtr.cid.value = cid;
|
||||||
videoDetailCtr.danmakuCid.value = cid;
|
videoDetailCtr.danmakuCid.value = cid;
|
||||||
|
videoDetailCtr.oid.value = aid;
|
||||||
videoDetailCtr.queryVideoUrl();
|
videoDetailCtr.queryVideoUrl();
|
||||||
// 重新请求评论
|
// 重新请求评论
|
||||||
try {
|
try {
|
||||||
|
@ -85,7 +85,9 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
|||||||
item.cid,
|
item.cid,
|
||||||
item.aid,
|
item.aid,
|
||||||
);
|
);
|
||||||
_bottomSheetController?.close();
|
if (_bottomSheetController != null) {
|
||||||
|
_bottomSheetController?.close();
|
||||||
|
}
|
||||||
currentIndex = i;
|
currentIndex = i;
|
||||||
scrollToIndex();
|
scrollToIndex();
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class VideoDetailController extends GetxController
|
|||||||
/// 播放器配置 画质 音质 解码格式
|
/// 播放器配置 画质 音质 解码格式
|
||||||
late VideoQuality currentVideoQa;
|
late VideoQuality currentVideoQa;
|
||||||
AudioQuality? currentAudioQa;
|
AudioQuality? currentAudioQa;
|
||||||
late VideoDecodeFormats currentDecodeFormats;
|
VideoDecodeFormats? currentDecodeFormats;
|
||||||
// 是否开始自动播放 存在多p的情况下,第二p需要为true
|
// 是否开始自动播放 存在多p的情况下,第二p需要为true
|
||||||
RxBool autoPlay = true.obs;
|
RxBool autoPlay = true.obs;
|
||||||
// 视频资源是否有效
|
// 视频资源是否有效
|
||||||
@ -107,6 +107,7 @@ class VideoDetailController extends GetxController
|
|||||||
BottomControlType.fullscreen,
|
BottomControlType.fullscreen,
|
||||||
].obs;
|
].obs;
|
||||||
RxDouble sheetHeight = 0.0.obs;
|
RxDouble sheetHeight = 0.0.obs;
|
||||||
|
RxString archiveSourceType = 'dash'.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
@ -189,37 +190,43 @@ class VideoDetailController extends GetxController
|
|||||||
plPlayerController.isBuffering.value = false;
|
plPlayerController.isBuffering.value = false;
|
||||||
plPlayerController.buffered.value = Duration.zero;
|
plPlayerController.buffered.value = Duration.zero;
|
||||||
|
|
||||||
/// 根据currentVideoQa和currentDecodeFormats 重新设置videoUrl
|
if (archiveSourceType.value == 'dash') {
|
||||||
List<VideoItem> videoList =
|
/// 根据currentVideoQa和currentDecodeFormats 重新设置videoUrl
|
||||||
data.dash!.video!.where((i) => i.id == currentVideoQa.code).toList();
|
List<VideoItem> videoList =
|
||||||
try {
|
data.dash!.video!.where((i) => i.id == currentVideoQa.code).toList();
|
||||||
firstVideo = videoList
|
try {
|
||||||
.firstWhere((i) => i.codecs!.startsWith(currentDecodeFormats.code));
|
firstVideo = videoList.firstWhere(
|
||||||
} catch (_) {
|
(i) => i.codecs!.startsWith(currentDecodeFormats?.code));
|
||||||
if (currentVideoQa == VideoQuality.dolbyVision) {
|
} catch (_) {
|
||||||
firstVideo = videoList.first;
|
if (currentVideoQa == VideoQuality.dolbyVision) {
|
||||||
currentDecodeFormats =
|
firstVideo = videoList.first;
|
||||||
VideoDecodeFormatsCode.fromString(videoList.first.codecs!)!;
|
currentDecodeFormats =
|
||||||
} else {
|
VideoDecodeFormatsCode.fromString(videoList.first.codecs!)!;
|
||||||
// 当前格式不可用
|
} else {
|
||||||
currentDecodeFormats = VideoDecodeFormatsCode.fromString(setting.get(
|
// 当前格式不可用
|
||||||
SettingBoxKey.defaultDecode,
|
currentDecodeFormats = VideoDecodeFormatsCode.fromString(setting.get(
|
||||||
defaultValue: VideoDecodeFormats.values.last.code))!;
|
SettingBoxKey.defaultDecode,
|
||||||
firstVideo = videoList
|
defaultValue: VideoDecodeFormats.values.last.code))!;
|
||||||
.firstWhere((i) => i.codecs!.startsWith(currentDecodeFormats.code));
|
firstVideo = videoList.firstWhere(
|
||||||
|
(i) => i.codecs!.startsWith(currentDecodeFormats?.code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
videoUrl = firstVideo.baseUrl!;
|
||||||
|
|
||||||
|
/// 根据currentAudioQa 重新设置audioUrl
|
||||||
|
if (currentAudioQa != null) {
|
||||||
|
final AudioItem firstAudio = data.dash!.audio!.firstWhere(
|
||||||
|
(AudioItem i) => i.id == currentAudioQa!.code,
|
||||||
|
orElse: () => data.dash!.audio!.first,
|
||||||
|
);
|
||||||
|
audioUrl = firstAudio.baseUrl ?? '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
videoUrl = firstVideo.baseUrl!;
|
|
||||||
|
|
||||||
/// 根据currentAudioQa 重新设置audioUrl
|
if (archiveSourceType.value == 'durl') {
|
||||||
if (currentAudioQa != null) {
|
cacheVideoQa = VideoQualityCode.toCode(currentVideoQa);
|
||||||
final AudioItem firstAudio = data.dash!.audio!.firstWhere(
|
queryVideoUrl();
|
||||||
(AudioItem i) => i.id == currentAudioQa!.code,
|
|
||||||
orElse: () => data.dash!.audio!.first,
|
|
||||||
);
|
|
||||||
audioUrl = firstAudio.baseUrl ?? '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playerInit();
|
playerInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +279,8 @@ class VideoDetailController extends GetxController
|
|||||||
|
|
||||||
// 视频链接
|
// 视频链接
|
||||||
Future queryVideoUrl() async {
|
Future queryVideoUrl() async {
|
||||||
var result = await VideoHttp.videoUrl(cid: cid.value, bvid: bvid);
|
var result =
|
||||||
|
await VideoHttp.videoUrl(cid: cid.value, bvid: bvid, qn: cacheVideoQa);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
data = result['data'];
|
data = result['data'];
|
||||||
if (data.acceptDesc!.isNotEmpty && data.acceptDesc!.contains('试看')) {
|
if (data.acceptDesc!.isNotEmpty && data.acceptDesc!.contains('试看')) {
|
||||||
@ -290,8 +298,22 @@ class VideoDetailController extends GetxController
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
if (data.durl != null) {
|
||||||
|
archiveSourceType.value = 'durl';
|
||||||
|
videoUrl = data.durl!.first.url!;
|
||||||
|
audioUrl = '';
|
||||||
|
defaultST = Duration.zero;
|
||||||
|
firstVideo = VideoItem();
|
||||||
|
currentVideoQa = VideoQualityCode.fromCode(data.quality!)!;
|
||||||
|
if (autoPlay.value) {
|
||||||
|
await playerInit();
|
||||||
|
isShowCover.value = false;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
final List<VideoItem> allVideosList = data.dash!.video!;
|
final List<VideoItem> allVideosList = data.dash!.video!;
|
||||||
try {
|
try {
|
||||||
|
archiveSourceType.value = 'dash';
|
||||||
// 当前可播放的最高质量视频
|
// 当前可播放的最高质量视频
|
||||||
int currentHighVideoQa = allVideosList.first.quality!.code;
|
int currentHighVideoQa = allVideosList.first.quality!.code;
|
||||||
// 预设的画质为null,则当前可用的最高质量
|
// 预设的画质为null,则当前可用的最高质量
|
||||||
@ -321,7 +343,7 @@ class VideoDetailController extends GetxController
|
|||||||
// 当前视频没有对应格式返回第一个
|
// 当前视频没有对应格式返回第一个
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
for (var i in supportDecodeFormats) {
|
for (var i in supportDecodeFormats) {
|
||||||
if (i.startsWith(currentDecodeFormats.code)) {
|
if (i.startsWith(currentDecodeFormats?.code)) {
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,7 +357,7 @@ class VideoDetailController extends GetxController
|
|||||||
/// 取出符合当前解码格式的videoItem
|
/// 取出符合当前解码格式的videoItem
|
||||||
try {
|
try {
|
||||||
firstVideo = videosList.firstWhere(
|
firstVideo = videosList.firstWhere(
|
||||||
(e) => e.codecs!.startsWith(currentDecodeFormats.code));
|
(e) => e.codecs!.startsWith(currentDecodeFormats?.code));
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
firstVideo = videosList.first;
|
firstVideo = videosList.first;
|
||||||
}
|
}
|
||||||
|
@ -180,15 +180,16 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
'当前音质 ${widget.videoDetailCtr!.currentAudioQa!.description}',
|
'当前音质 ${widget.videoDetailCtr!.currentAudioQa!.description}',
|
||||||
style: subTitleStyle),
|
style: subTitleStyle),
|
||||||
),
|
),
|
||||||
ListTile(
|
if (widget.videoDetailCtr!.currentDecodeFormats != null)
|
||||||
onTap: () => {Get.back(), showSetDecodeFormats()},
|
ListTile(
|
||||||
dense: true,
|
onTap: () => {Get.back(), showSetDecodeFormats()},
|
||||||
leading: const Icon(Icons.av_timer_outlined, size: 20),
|
dense: true,
|
||||||
title: const Text('解码格式', style: titleStyle),
|
leading: const Icon(Icons.av_timer_outlined, size: 20),
|
||||||
subtitle: Text(
|
title: const Text('解码格式', style: titleStyle),
|
||||||
'当前解码格式 ${widget.videoDetailCtr!.currentDecodeFormats.description}',
|
subtitle: Text(
|
||||||
style: subTitleStyle),
|
'当前解码格式 ${widget.videoDetailCtr!.currentDecodeFormats!.description}',
|
||||||
),
|
style: subTitleStyle),
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
onTap: () => {Get.back(), showSetRepeat()},
|
onTap: () => {Get.back(), showSetRepeat()},
|
||||||
dense: true,
|
dense: true,
|
||||||
@ -541,16 +542,24 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
|
|
||||||
/// 可用的质量分类
|
/// 可用的质量分类
|
||||||
int userfulQaSam = 0;
|
int userfulQaSam = 0;
|
||||||
final List<VideoItem> video = videoInfo.dash!.video!;
|
if (videoInfo.dash != null) {
|
||||||
final Set<int> idSet = {};
|
// dash格式视频一次请求会返回所有可播放的清晰度video
|
||||||
for (final VideoItem item in video) {
|
final List<VideoItem> video = videoInfo.dash!.video!;
|
||||||
final int id = item.id!;
|
final Set<int> idSet = {};
|
||||||
if (!idSet.contains(id)) {
|
for (final VideoItem item in video) {
|
||||||
idSet.add(id);
|
final int id = item.id!;
|
||||||
userfulQaSam++;
|
if (!idSet.contains(id)) {
|
||||||
|
idSet.add(id);
|
||||||
|
userfulQaSam++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (videoInfo.durl != null) {
|
||||||
|
// durl格式视频一次请求返回对应清晰度video
|
||||||
|
userfulQaSam = videoFormat.length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
@ -707,7 +716,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
void showSetDecodeFormats() {
|
void showSetDecodeFormats() {
|
||||||
// 当前选中的解码格式
|
// 当前选中的解码格式
|
||||||
final VideoDecodeFormats currentDecodeFormats =
|
final VideoDecodeFormats currentDecodeFormats =
|
||||||
widget.videoDetailCtr!.currentDecodeFormats;
|
widget.videoDetailCtr!.currentDecodeFormats!;
|
||||||
final VideoItem firstVideo = widget.videoDetailCtr!.firstVideo;
|
final VideoItem firstVideo = widget.videoDetailCtr!.firstVideo;
|
||||||
// 当前视频可用的解码格式
|
// 当前视频可用的解码格式
|
||||||
final List<FormatItem> videoFormat = videoInfo.supportFormats!;
|
final List<FormatItem> videoFormat = videoInfo.supportFormats!;
|
||||||
|
Reference in New Issue
Block a user