Skip to content

Commit

Permalink
feat: 播放器错误提示
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaoMint committed Aug 9, 2023
1 parent dfe62f4 commit 0048cf5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/pages/watch/video_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class VideoPlayerController extends GetxController {
// 自动切换下一集
player.stream.completed.listen((event) {
if (index.value == playList.length - 1 && event) {
addMessage(Message(Text('video.play-complete'.i18n)));
sendMessage(Message(Text('video.play-complete'.i18n)));
return;
}
if (!player.state.buffering) {
Expand All @@ -90,10 +90,15 @@ class VideoPlayerController extends GetxController {
history.episodeGroupId == episodeGroupId) {
_isAutoSeekPosition = true;
player.seek(Duration(seconds: int.parse(history.progress)));
addMessage(Message(Text('video.resume-last-playback'.i18n)));
sendMessage(Message(Text('video.resume-last-playback'.i18n)));
}
});

// 错误监听
player.stream.error.listen((event) {
sendMessage(Message(Text(event)));
});

super.onInit();
}

Expand All @@ -105,7 +110,7 @@ class VideoPlayerController extends GetxController {
player.open(Media(m3u8Url));
} catch (e) {
debugPrint(e.toString());
addMessage(
sendMessage(
Message(
Text(e.toString()),
time: const Duration(seconds: 5),
Expand Down Expand Up @@ -157,7 +162,7 @@ class VideoPlayerController extends GetxController {
});
}

addMessage(Message message) {
sendMessage(Message message) {
messageQueue.add(message);

if (messageQueue.length == 1) {
Expand Down

0 comments on commit 0048cf5

Please sign in to comment.