Skip to content

Commit

Permalink
add more notify
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Jul 29, 2024
1 parent 83cedcc commit fed7fd7
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/services/audio_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {

VideoPlayerServiceHandler() {
revalidateSetting();
mediaItem.listen((MediaItem? value) {
SmartDialog.showNotify(
msg: "value changed: $value",
alignment: Alignment.topCenter,
notifyType: NotifyType.alert);
});
}

revalidateSetting() {
Expand Down Expand Up @@ -72,9 +78,16 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
try {
audioSessionHandler.setActive(true);
queue.value.add(newMediaItem);
if (!mediaItem.isClosed) mediaItem.add(newMediaItem);

if (!mediaItem.isClosed) {
mediaItem.add(newMediaItem);
} else {
SmartDialog.showNotify(
msg: "mediaItem.isClosed", notifyType: NotifyType.failure);
}
} catch (e) {
SmartDialog.showToast("setMediaItem error $e");
SmartDialog.showNotify(
msg: "setMediaItem error $e", notifyType: NotifyType.error);
}
}

Expand All @@ -84,6 +97,8 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
late AudioProcessingState processingState;

if (playerStatus == null) {
SmartDialog.showNotify(
msg: "playerStatus null", notifyType: NotifyType.error);
processingState = AudioProcessingState.idle;
} else if (playerStatus == PlayerStatus.completed) {
processingState = AudioProcessingState.completed;
Expand Down Expand Up @@ -248,6 +263,8 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
clear() {
if (!enableBackgroundPlay) return;
mediaItem.add(null);
SmartDialog.showNotify(
msg: "playerStatus clear", notifyType: NotifyType.error);
playbackState.add(PlaybackState(
processingState: AudioProcessingState.idle,
playing: false,
Expand Down

0 comments on commit fed7fd7

Please sign in to comment.