fix: 视频详情页null

This commit is contained in:
guozhigq
2024-01-21 11:37:19 +08:00
parent 32f84dc703
commit aa4e251295
4 changed files with 12 additions and 10 deletions

View File

@ -9,7 +9,8 @@ import './controller.dart';
class RelatedVideoPanel extends StatelessWidget { class RelatedVideoPanel extends StatelessWidget {
final ReleatedController _releatedController = final ReleatedController _releatedController =
Get.put(ReleatedController(), tag: Get.arguments['heroTag']); Get.put(ReleatedController(), tag: Get.arguments?['heroTag']);
RelatedVideoPanel({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

View File

@ -235,7 +235,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
videoIntroController.isPaused = false; videoIntroController.isPaused = false;
if (_extendNestCtr.position.pixels == 0 && autoplay) { if (_extendNestCtr.position.pixels == 0 && autoplay) {
await Future.delayed(const Duration(milliseconds: 300)); await Future.delayed(const Duration(milliseconds: 300));
plPlayerController!.seekTo(videoDetailController.defaultST); plPlayerController?.seekTo(videoDetailController.defaultST);
plPlayerController?.play(); plPlayerController?.play();
} }
plPlayerController?.addStatusLister(playerListener); plPlayerController?.addStatusLister(playerListener);

View File

@ -621,7 +621,7 @@ class PlPlayerController {
if (duration.value.inSeconds != 0) { if (duration.value.inSeconds != 0) {
if (type != 'slider') { if (type != 'slider') {
/// 拖动进度条调节时,不等待第一帧,防止抖动 /// 拖动进度条调节时,不等待第一帧,防止抖动
await _videoPlayerController!.stream.buffer.first; await _videoPlayerController?.stream.buffer.first;
} }
await _videoPlayerController?.seek(position); await _videoPlayerController?.seek(position);
// if (playerStatus.stopped) { // if (playerStatus.stopped) {
@ -1086,12 +1086,13 @@ class PlPlayerController {
localCache.put(LocalCacheKey.danmakuOpacity, opacityVal); localCache.put(LocalCacheKey.danmakuOpacity, opacityVal);
localCache.put(LocalCacheKey.danmakuFontScale, fontSizeVal); localCache.put(LocalCacheKey.danmakuFontScale, fontSizeVal);
localCache.put(LocalCacheKey.danmakuDuration, danmakuDurationVal); localCache.put(LocalCacheKey.danmakuDuration, danmakuDurationVal);
if (_videoPlayerController != null) {
var pp = _videoPlayerController!.platform as NativePlayer; var pp = _videoPlayerController!.platform as NativePlayer;
await pp.setProperty('audio-files', ''); await pp.setProperty('audio-files', '');
removeListeners(); removeListeners();
await _videoPlayerController?.dispose(); await _videoPlayerController?.dispose();
_videoPlayerController = null; _videoPlayerController = null;
}
_instance = null; _instance = null;
// 关闭所有视频页面恢复亮度 // 关闭所有视频页面恢复亮度
resetBrightness(); resetBrightness();

View File

@ -703,7 +703,7 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
), ),
); );
} else { } else {
return nil; return const SizedBox();
} }
}), }),