Compare commits
1 Commits
feature-ab
...
fix-issues
Author | SHA1 | Date | |
---|---|---|---|
35dc94014c |
@ -4,6 +4,8 @@ import 'package:pilipala/http/live.dart';
|
||||
import 'package:pilipala/models/live/room_info.dart';
|
||||
import 'package:pilipala/plugin/pl_player/index.dart';
|
||||
import '../../models/live/room_info_h5.dart';
|
||||
import '../../utils/storage.dart';
|
||||
import '../../utils/video_utils.dart';
|
||||
|
||||
class LiveRoomController extends GetxController {
|
||||
String cover = '';
|
||||
@ -16,6 +18,7 @@ class LiveRoomController extends GetxController {
|
||||
PlPlayerController plPlayerController =
|
||||
PlPlayerController.getInstance(videoType: 'live');
|
||||
Rx<RoomInfoH5Model> roomInfoH5 = RoomInfoH5Model().obs;
|
||||
late bool enableCDN;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@ -31,6 +34,8 @@ class LiveRoomController extends GetxController {
|
||||
cover = liveItem.cover;
|
||||
}
|
||||
}
|
||||
// CDN优化
|
||||
enableCDN = setting.get(SettingBoxKey.enableCDN, defaultValue: true);
|
||||
}
|
||||
|
||||
playerInit(source) async {
|
||||
@ -57,9 +62,11 @@ class LiveRoomController extends GetxController {
|
||||
List<CodecItem> codec =
|
||||
res['data'].playurlInfo.playurl.stream.first.format.first.codec;
|
||||
CodecItem item = codec.first;
|
||||
String videoUrl = (item.urlInfo?.first.host)! +
|
||||
item.baseUrl! +
|
||||
item.urlInfo!.first.extra!;
|
||||
String videoUrl = enableCDN
|
||||
? VideoUtils.getCdnUrl(item)
|
||||
: (item.urlInfo?.first.host)! +
|
||||
item.baseUrl! +
|
||||
item.urlInfo!.first.extra!;
|
||||
await playerInit(videoUrl);
|
||||
return res;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
import 'package:pilipala/models/video/play/url.dart';
|
||||
|
||||
import '../models/live/room_info.dart';
|
||||
|
||||
class VideoUtils {
|
||||
static String getCdnUrl(dynamic item) {
|
||||
var backupUrl = "";
|
||||
@ -12,13 +14,20 @@ class VideoUtils {
|
||||
} else if (item is AudioItem) {
|
||||
backupUrl = item.backupUrl ?? "";
|
||||
videoUrl = backupUrl.contains("http") ? backupUrl : (item.baseUrl ?? "");
|
||||
} else if (item is CodecItem) {
|
||||
backupUrl = (item.urlInfo?.first.host)! +
|
||||
item.baseUrl! +
|
||||
item.urlInfo!.first.extra!;
|
||||
videoUrl = backupUrl.contains("http") ? backupUrl : (item.baseUrl ?? "");
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
/// issues #70
|
||||
if (videoUrl.contains(".mcdn.bilivideo") ||
|
||||
videoUrl.contains("/upgcxcode/")) {
|
||||
if (videoUrl.contains(".mcdn.bilivideo")) {
|
||||
videoUrl =
|
||||
'https://proxy-tf-all-ws.bilivideo.com/?url=${Uri.encodeComponent(videoUrl)}';
|
||||
} else if (videoUrl.contains("/upgcxcode/")) {
|
||||
//CDN列表
|
||||
var cdnList = {
|
||||
'ali': 'upos-sz-mirrorali.bilivideo.com',
|
||||
|
Reference in New Issue
Block a user