Skip to content

Commit

Permalink
add listener before play, not wait seekto buffer.first, remove onVide…
Browse files Browse the repository at this point in the history
…oDetailDispose, remove seek playbackState updatePosition
  • Loading branch information
orz12 committed Jul 27, 2024
1 parent 58a1a28 commit a814d98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
9 changes: 4 additions & 5 deletions lib/pages/video/detail/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
final bool autoplay = autoPlayEnable;
videoDetailController.autoPlay.value =
!videoDetailController.isShowCover.value;
plPlayerController?.addStatusLister(playerListener);
if (plPlayerController != null) {
listenFullScreenStatus();
}
await videoDetailController.playerInit(autoplay: autoplay);

/// 未开启自动播放时,未播放跳转下一页返回/播放后跳转下一页返回
videoIntroController.isPaused = false;
// if (autoplay) {
Expand All @@ -337,10 +340,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
Future.delayed(const Duration(milliseconds: 600), () {
AutoOrientation.fullAutoMode();
});
plPlayerController?.addStatusLister(playerListener);
if (plPlayerController != null) {
listenFullScreenStatus();
}
}

@override
Expand Down
6 changes: 2 additions & 4 deletions lib/plugin/pl_player/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class PlPlayerController {
static Future<void> pauseIfExists(
{bool notify = true, bool isInterrupt = false}) async {
// if (_instance?.playerStatus.status.value == PlayerStatus.playing) {
await _instance?.pause(notify: notify, isInterrupt: isInterrupt);
await _instance?.pause(notify: notify, isInterrupt: isInterrupt);
// }
}

Expand Down Expand Up @@ -908,8 +908,7 @@ class PlPlayerController {

if (repeat) {
SmartDialog.showToast("stoping");
await seekTo(Duration.zero);
// await _videoPlayerController?.stop();
await seekTo(Duration.zero, type: "slider");
SmartDialog.showToast("stopped");
}
// playerStatus.status.value = PlayerStatus.playing;
Expand Down Expand Up @@ -1301,7 +1300,6 @@ class PlPlayerController {
Future<void> dispose({String type = 'single'}) async {
// 每次减1,最后销毁
if (type == 'single' && playerCount.value > 1) {
videoPlayerServiceHandler.onVideoDetailDispose();
_playerCount.value -= 1;
_heartDuration = 0;
pause();
Expand Down
12 changes: 3 additions & 9 deletions lib/services/audio_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,13 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
// player.pause();
}

seekToNotification(Duration position) {
playbackState.add(playbackState.value.copyWith(
updatePosition: position,
));
}

@override
Future<void> seek(Duration position) async {
SmartDialog.showNotify(
msg: "跳转至${position.inSeconds}秒", notifyType: NotifyType.alert);
playbackState.add(playbackState.value.copyWith(
updatePosition: position,
));
// playbackState.add(playbackState.value.copyWith(
// updatePosition: position,
// ));
await PlPlayerController.seekToIfExists(position);
// await player.seekTo(position);
}
Expand Down

0 comments on commit a814d98

Please sign in to comment.