Skip to content

Commit

Permalink
fixed ios audio player error when file name contains chinese
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangzhiguo1992 committed Nov 16, 2021
1 parent 63d9657 commit 692a401
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/helpers/audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class AudioHelper with Tag {
if (isSame) return true;
}
// path
if (localPath.isEmpty || !File(localPath).existsSync()) {
File localFile = File(localPath);
if (localPath.isEmpty || !localFile.existsSync()) {
Toast.show(S.of(Global.appContext).file_not_exist);
return false;
}
Expand Down Expand Up @@ -125,7 +126,7 @@ class AudioHelper with Tag {
try {
await player.setSubscriptionDuration(Duration(milliseconds: 50));
await player.startPlayer(
fromURI: localPath,
fromDataBuffer: localFile.readAsBytesSync(),
codec: Codec.defaultCodec,
whenFinished: () {
logger.i("$TAG - playStart - whenFinished - playerId:$playerId");
Expand Down Expand Up @@ -212,7 +213,7 @@ class AudioHelper with Tag {
_record = await record.openAudioSession(
focus: AudioFocus.requestFocusAndStopOthers,
category: Sound.SessionCategory.record,
mode: SessionMode.modeVoiceChat,
mode: SessionMode.modeDefault,
device: AudioDevice.speaker,
);
} catch (e) {
Expand Down
4 changes: 3 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# 21/11/14
# version: 1.2.0+243
# 21/11/15
version: 1.2.0+244
# version: 1.2.0+244
# 21/11/16
version: 1.2.0+245

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit 692a401

Please sign in to comment.