mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 代码整理
This commit is contained in:
@@ -96,7 +96,7 @@ class PlPlayerController {
|
|||||||
int _heartDuration = 0;
|
int _heartDuration = 0;
|
||||||
bool _enableHeart = true;
|
bool _enableHeart = true;
|
||||||
bool _isFirstTime = true;
|
bool _isFirstTime = true;
|
||||||
final RxList<Map<String,String>> _vttSubtitles = <Map<String,String>>[].obs;
|
final RxList<Map<String, String>> _vttSubtitles = <Map<String, String>>[].obs;
|
||||||
|
|
||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
Timer? _timerForSeek;
|
Timer? _timerForSeek;
|
||||||
@@ -282,8 +282,7 @@ class PlPlayerController {
|
|||||||
danmakuDurationVal =
|
danmakuDurationVal =
|
||||||
localCache.get(LocalCacheKey.danmakuDuration, defaultValue: 4.0);
|
localCache.get(LocalCacheKey.danmakuDuration, defaultValue: 4.0);
|
||||||
// 描边粗细
|
// 描边粗细
|
||||||
strokeWidth =
|
strokeWidth = localCache.get(LocalCacheKey.strokeWidth, defaultValue: 1.5);
|
||||||
localCache.get(LocalCacheKey.strokeWidth, defaultValue: 1.5);
|
|
||||||
playRepeat = PlayRepeat.values.toList().firstWhere(
|
playRepeat = PlayRepeat.values.toList().firstWhere(
|
||||||
(e) =>
|
(e) =>
|
||||||
e.value ==
|
e.value ==
|
||||||
@@ -377,7 +376,9 @@ class PlPlayerController {
|
|||||||
// 获取视频时长 00:00
|
// 获取视频时长 00:00
|
||||||
_duration.value = duration ?? _videoPlayerController!.state.duration;
|
_duration.value = duration ?? _videoPlayerController!.state.duration;
|
||||||
updateDurationSecond();
|
updateDurationSecond();
|
||||||
refreshSubtitles();
|
if (videoType.value != 'live') {
|
||||||
|
refreshSubtitles();
|
||||||
|
}
|
||||||
// 数据加载完成
|
// 数据加载完成
|
||||||
dataStatus.status.value = DataStatus.loaded;
|
dataStatus.status.value = DataStatus.loaded;
|
||||||
|
|
||||||
@@ -433,7 +434,10 @@ class PlPlayerController {
|
|||||||
await pp.setProperty("volume-max", "100");
|
await pp.setProperty("volume-max", "100");
|
||||||
await pp.setProperty("ao", "audiotrack,opensles");
|
await pp.setProperty("ao", "audiotrack,opensles");
|
||||||
}
|
}
|
||||||
|
// // vo=gpu-next & gpu-context=android & gpu-api=opengl
|
||||||
|
// await pp.setProperty("vo", "gpu-next");
|
||||||
|
// await pp.setProperty("gpu-context", "android");
|
||||||
|
// await pp.setProperty("gpu-api", "opengl");
|
||||||
await player.setAudioTrack(
|
await player.setAudioTrack(
|
||||||
AudioTrack.auto(),
|
AudioTrack.auto(),
|
||||||
);
|
);
|
||||||
@@ -950,8 +954,10 @@ class PlPlayerController {
|
|||||||
if (!isFullScreen.value && status) {
|
if (!isFullScreen.value && status) {
|
||||||
// StatusBarControl.setHidden(true, animation: StatusBarAnimation.FADE);
|
// StatusBarControl.setHidden(true, animation: StatusBarAnimation.FADE);
|
||||||
hideStatusBar();
|
hideStatusBar();
|
||||||
|
|
||||||
/// 按照视频宽高比决定全屏方向
|
/// 按照视频宽高比决定全屏方向
|
||||||
toggleFullScreen(true);
|
toggleFullScreen(true);
|
||||||
|
|
||||||
/// 进入全屏
|
/// 进入全屏
|
||||||
FullScreenMode mode = FullScreenModeCode.fromCode(
|
FullScreenMode mode = FullScreenModeCode.fromCode(
|
||||||
setting.get(SettingBoxKey.fullScreenMode, defaultValue: 0))!;
|
setting.get(SettingBoxKey.fullScreenMode, defaultValue: 0))!;
|
||||||
@@ -968,7 +974,7 @@ class PlPlayerController {
|
|||||||
// StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
// StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
||||||
showStatusBar();
|
showStatusBar();
|
||||||
toggleFullScreen(false);
|
toggleFullScreen(false);
|
||||||
if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)){
|
if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
|
||||||
await verticalScreen();
|
await verticalScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1086,8 +1092,7 @@ class PlPlayerController {
|
|||||||
|
|
||||||
void refreshSubtitles() async {
|
void refreshSubtitles() async {
|
||||||
_vttSubtitles.clear();
|
_vttSubtitles.clear();
|
||||||
Map res = await VideoHttp.subtitlesJson(
|
Map res = await VideoHttp.subtitlesJson(bvid: _bvid, cid: _cid);
|
||||||
bvid: _bvid, cid: _cid);
|
|
||||||
if (!res["status"]) {
|
if (!res["status"]) {
|
||||||
SmartDialog.showToast('查询字幕错误,${res["msg"]}');
|
SmartDialog.showToast('查询字幕错误,${res["msg"]}');
|
||||||
}
|
}
|
||||||
@@ -1110,29 +1115,29 @@ class PlPlayerController {
|
|||||||
title: const Text('选择字幕(测试)'),
|
title: const Text('选择字幕(测试)'),
|
||||||
content: StatefulBuilder(
|
content: StatefulBuilder(
|
||||||
builder: (BuildContext context, StateSetter setState) {
|
builder: (BuildContext context, StateSetter setState) {
|
||||||
return Wrap(
|
return Wrap(
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
runSpacing: 2,
|
runSpacing: 2,
|
||||||
children: [
|
children: [
|
||||||
FilledButton.tonal(
|
FilledButton.tonal(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await removeSubtitle();
|
await removeSubtitle();
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
child: const Text("关闭字幕"),
|
child: const Text("关闭字幕"),
|
||||||
),
|
),
|
||||||
for (final Map<String, String> i in _vttSubtitles) ...<Widget>[
|
for (final Map<String, String> i in _vttSubtitles) ...<Widget>[
|
||||||
FilledButton.tonal(
|
FilledButton.tonal(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await setSubtitle(i);
|
await setSubtitle(i);
|
||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
child: Text(i["title"]!),
|
child: Text(i["title"]!),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Get.back(),
|
onPressed: () => Get.back(),
|
||||||
@@ -1152,13 +1157,11 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设定字幕轨道
|
// 设定字幕轨道
|
||||||
setSubtitle(Map<String,String> s) {
|
setSubtitle(Map<String, String> s) {
|
||||||
_videoPlayerController?.setSubtitleTrack(
|
_videoPlayerController?.setSubtitleTrack(SubtitleTrack.data(
|
||||||
SubtitleTrack.data(
|
s['text']!,
|
||||||
s['text']!,
|
title: s['title']!,
|
||||||
title: s['title']!,
|
language: s['language']!,
|
||||||
language: s['language']!,
|
));
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user