Merge pull request #3320 from pangeachat/fix-auto-play-bot-messages-on-android
chore: fix autoplay bot messages on android
This commit is contained in:
commit
90a41a57db
1 changed files with 16 additions and 6 deletions
|
|
@ -16,6 +16,7 @@ import 'package:go_router/go_router.dart';
|
|||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
|
@ -506,12 +507,21 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
);
|
||||
if (audioFile == null) return;
|
||||
|
||||
matrix.audioPlayer!.setAudioSource(
|
||||
BytesAudioSource(
|
||||
audioFile.bytes,
|
||||
audioFile.mimeType,
|
||||
),
|
||||
);
|
||||
if (!kIsWeb) {
|
||||
final tempDir = await getTemporaryDirectory();
|
||||
|
||||
File? file;
|
||||
file = File('${tempDir.path}/${audioFile.name}');
|
||||
await file.writeAsBytes(audioFile.bytes);
|
||||
matrix.audioPlayer!.setFilePath(file.path);
|
||||
} else {
|
||||
matrix.audioPlayer!.setAudioSource(
|
||||
BytesAudioSource(
|
||||
audioFile.bytes,
|
||||
audioFile.mimeType,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
matrix.audioPlayer!.play();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue