refactor: Use native uri data from bytes instead of html
This commit is contained in:
parent
e311c9573e
commit
bfcd78fcdf
2 changed files with 8 additions and 10 deletions
|
|
@ -10,7 +10,6 @@ import 'package:just_audio/just_audio.dart';
|
|||
import 'package:matrix/matrix.dart';
|
||||
import 'package:opus_caf_converter_dart/opus_caf_converter_dart.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
|
|
@ -203,12 +202,12 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
|
||||
if (file != null) {
|
||||
audioPlayer.setFilePath(file.path);
|
||||
} else if (kIsWeb) {
|
||||
final blob = html.Blob([matrixFile.bytes], matrixFile.mimeType);
|
||||
final url = html.Url.createObjectUrlFromBlob(blob);
|
||||
await audioPlayer.setAudioSource(AudioSource.uri(Uri.parse(url)));
|
||||
} else {
|
||||
throw Exception('No audio file provided!');
|
||||
await audioPlayer.setAudioSource(
|
||||
AudioSource.uri(
|
||||
Uri.dataFromBytes(matrixFile.bytes, mimeType: matrixFile.mimeType),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
audioPlayer.play().onError(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue