Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 61ad6daf
authored
2026-11-06 15:04:51 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
audioPlay指令播放失败,toast提示
1 parent
e939759f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletions
lib/data/repositories/message/audio_player_handler.dart
lib/data/repositories/message/audio_player_handler.dart
View file @
61ad6da
...
...
@@ -2,6 +2,8 @@ import 'package:appframe/bloc/web_cubit.dart';
import
'package:appframe/config/locator.dart'
;
import
'package:appframe/services/dispatcher.dart'
;
import
'package:appframe/services/player_service.dart'
;
import
'package:flutter/material.dart'
;
import
'package:fluttertoast/fluttertoast.dart'
;
import
'package:uuid/uuid.dart'
;
class
AudioPlayHandler
extends
MessageHandler
{
...
...
@@ -29,9 +31,17 @@ class AudioPlayHandler extends MessageHandler {
}
var
playerService
=
getIt
.
get
<
PlayerService
>();
var
result
=
await
playerService
.
playAudio
(
url
,
seek
,
playId
,
playRate
);
var
result
=
false
;
try
{
result
=
await
playerService
.
playAudio
(
url
,
seek
,
playId
,
playRate
);
}
catch
(
e
)
{
// 播放异常(下载失败/音频损坏/播放器重建失败等):提示用户后继续上抛,保持 H5 的错误回调语义
_showPlayFailedToast
();
rethrow
;
}
if
(!
result
)
{
_showPlayFailedToast
();
throw
Exception
(
'播放错误'
);
}
return
{
'playId'
:
playId
};
...
...
@@ -45,6 +55,11 @@ class AudioPlayHandler extends MessageHandler {
this
.
_webCubit
=
cubit
;
}
/// 播放失败统一提示
void
_showPlayFailedToast
()
{
Fluttertoast
.
showToast
(
msg:
'无法播放该音频'
,
gravity:
ToastGravity
.
CENTER
,
backgroundColor:
Colors
.
grey
);
}
void
_unfollowCubit
()
{
this
.
_webCubit
=
null
;
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment