Skip to content

Commit

Permalink
add some notify
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Jul 21, 2024
1 parent bd09408 commit d35c16e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/plugin/pl_player/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,8 @@ class PlPlayerController {
/// TODO _duration.value丢失
Future<void> play({bool repeat = false, bool hideControls = true}) async {
if (_playerCount.value == 0) return;
await audioSessionHandler.setActive(true);
SmartDialog.showToast(
(await audioSessionHandler.setActive(true)).toString());
// 播放时自动隐藏控制条
controls = !hideControls;
// repeat为true,将从头播放
Expand Down
10 changes: 8 additions & 2 deletions lib/services/audio_handler.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:PiliPalaX/services/service_locator.dart';
import 'package:audio_service/audio_service.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:hive/hive.dart';
import 'package:PiliPalaX/models/bangumi/info.dart';
import 'package:PiliPalaX/models/video_detail_res.dart';
Expand Down Expand Up @@ -41,6 +42,7 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {

@override
Future<void> play() async {
SmartDialog.showNotify(msg: "开始播放", notifyType: NotifyType.alert);
await PlPlayerController.playIfExists();
// player.play();
}
Expand Down Expand Up @@ -158,7 +160,9 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
if (!enableBackgroundPlay) return;

playbackState.add(playbackState.value.copyWith(
processingState: Platform.isIOS ? AudioProcessingState.ready : AudioProcessingState.idle,
processingState: Platform.isIOS
? AudioProcessingState.ready
: AudioProcessingState.idle,
playing: false,
));
if (_item.isNotEmpty) {
Expand All @@ -176,7 +180,9 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
if (!enableBackgroundPlay) return;
mediaItem.add(null);
playbackState.add(PlaybackState(
processingState: Platform.isIOS ? AudioProcessingState.ready : AudioProcessingState.idle,
processingState: Platform.isIOS
? AudioProcessingState.ready
: AudioProcessingState.idle,
playing: false,
));
_item.clear();
Expand Down

0 comments on commit d35c16e

Please sign in to comment.