diff --git a/lib/models/dynamics/result.dart b/lib/models/dynamics/result.dart index de8dbc923..34f4c5ad4 100644 --- a/lib/models/dynamics/result.dart +++ b/lib/models/dynamics/result.dart @@ -7,6 +7,7 @@ import 'package:PiliPlus/models/model_avatar.dart'; import 'package:PiliPlus/models/model_owner.dart'; import 'package:PiliPlus/models_new/live/live_feed_index/watched_show.dart'; import 'package:PiliPlus/utils/extension/iterable_ext.dart'; +import 'package:PiliPlus/utils/parse_string.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; import 'package:PiliPlus/utils/utils.dart'; @@ -429,7 +430,7 @@ class ModuleAuthorModel extends Avatar { pendant = null; } isTop = json['is_top']; - badgeText = _parseString(json['icon_badge']?['text']); + badgeText = noneNullOrEmptyString(json['icon_badge']?['text']); } } @@ -682,7 +683,9 @@ class Vote { Vote.fromJson(Map json) { joinNum = Utils.safeToInt(json['join_num']); voteId = Utils.safeToInt(json['vote_id']); - title = _parseString(json['title']) ?? _parseString(json['desc']); + title = + noneNullOrEmptyString(json['title']) ?? + noneNullOrEmptyString(json['desc']); } } @@ -1170,18 +1173,13 @@ class Emoji { Emoji.fromJson(Map json) { url = - _parseString(json['webp_url']) ?? - _parseString(json['gif_url']) ?? - _parseString(json['icon_url']); + noneNullOrEmptyString(json['webp_url']) ?? + noneNullOrEmptyString(json['gif_url']) ?? + noneNullOrEmptyString(json['icon_url']); size = json['size'] ?? 1; } } -String? _parseString(String? value) { - if (value == null || value.isEmpty) return null; - return value; -} - class DynamicNoneModel { DynamicNoneModel({ this.tips, @@ -1297,7 +1295,7 @@ class ModuleTag { String? text; ModuleTag.fromJson(Map json) { - text = _parseString(json['text']); + text = noneNullOrEmptyString(json['text']); } } diff --git a/lib/models_new/video/video_detail/data.dart b/lib/models_new/video/video_detail/data.dart index e76113184..9f49712c2 100644 --- a/lib/models_new/video/video_detail/data.dart +++ b/lib/models_new/video/video_detail/data.dart @@ -9,6 +9,7 @@ import 'package:PiliPlus/models_new/video/video_detail/stat.dart'; import 'package:PiliPlus/models_new/video/video_detail/subtitle.dart'; import 'package:PiliPlus/models_new/video/video_detail/ugc_season.dart'; import 'package:PiliPlus/models_new/video/video_detail/user_garb.dart'; +import 'package:PiliPlus/utils/parse_string.dart'; class VideoDetailData { String? bvid; @@ -177,6 +178,6 @@ class VideoDetailData { staff: (json["staff"] as List?) ?.map((item) => Staff.fromJson(item)) .toList(), - redirectUrl: json['redirect_url'], + redirectUrl: noneNullOrEmptyString(json['redirect_url']), ); } diff --git a/lib/pages/video/introduction/ugc/controller.dart b/lib/pages/video/introduction/ugc/controller.dart index f425a3993..80765dce5 100644 --- a/lib/pages/video/introduction/ugc/controller.dart +++ b/lib/pages/video/introduction/ugc/controller.dart @@ -90,6 +90,14 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { queryVideoTags(); final res = await VideoHttp.videoIntro(bvid: bvid); if (res case Success(:final response)) { + if (response.redirectUrl != null && + videoDetailCtr.epId == null && + videoDetailCtr.seasonId == null) { + if (!isClosed) { + PageUtils.viewPgcFromUri(response.redirectUrl!, off: true); + } + return; + } videoPlayerServiceHandler?.onVideoDetailChange( response, cid.value, diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index d707964fe..bb4b0b331 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -1592,6 +1592,9 @@ class PlPlayerController with BlockConfigMixin { if (playerStatus.isPlaying) { WakelockPlus.disable(); } + if (kDebugMode) { + debugPrint('dispose player'); + } _videoPlayerController?.dispose(); _videoPlayerController = null; _videoController = null; diff --git a/lib/utils/page_utils.dart b/lib/utils/page_utils.dart index 7fe09b9d9..97ca641a0 100644 --- a/lib/utils/page_utils.dart +++ b/lib/utils/page_utils.dart @@ -585,6 +585,7 @@ abstract final class PageUtils { bool isPgc = true, int? progress, // milliseconds int? aid, + bool off = false, }) { RegExpMatch? match = _pgcRegex.firstMatch(uri); if (match != null) { @@ -595,12 +596,14 @@ abstract final class PageUtils { seasonId: isSeason ? id : null, epId: isSeason ? null : id, progress: progress, + off: off, ); } else { viewPugv( seasonId: isSeason ? id : null, epId: isSeason ? null : id, aid: aid, + off: off, ); } return true; @@ -628,6 +631,7 @@ abstract final class PageUtils { dynamic seasonId, dynamic epId, int? progress, // milliseconds + bool off = false, }) async { try { SmartDialog.showLoading(msg: '资源获取中'); @@ -652,6 +656,7 @@ abstract final class PageUtils { 'pgcApi': true, 'pgcItem': response, }, + off: off, ); } @@ -700,6 +705,7 @@ abstract final class PageUtils { extraArguments: { 'pgcItem': response, }, + off: off, ); return; } else { @@ -725,6 +731,7 @@ abstract final class PageUtils { dynamic seasonId, dynamic epId, int? aid, + bool off = false, }) async { try { SmartDialog.showLoading(msg: '资源获取中'); @@ -752,6 +759,7 @@ abstract final class PageUtils { extraArguments: { 'pgcItem': response, }, + off: off, ); } else { SmartDialog.showToast('资源加载失败'); diff --git a/lib/utils/parse_string.dart b/lib/utils/parse_string.dart new file mode 100644 index 000000000..17da1d070 --- /dev/null +++ b/lib/utils/parse_string.dart @@ -0,0 +1,4 @@ +String? noneNullOrEmptyString(String? value) { + if (value == null || value.isEmpty) return null; + return value; +}