udioplayers: 4.1.0
エラーはこちら。
1 |
Unhandled Exception: PlatformException(AndroidAudioError, assets/audio/whistle.wav: open failed: |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
E/flutter (12458): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(AndroidAudioError, assets/audio/whistle.wav: open failed: ENOENT (No such file or directory), java.io.FileNotFoundException: assets/audio/whistle.wav: open failed: ENOENT (No such file or directory) E/flutter (12458): at libcore.io.IoBridge.open(IoBridge.java:574) E/flutter (12458): at java.io.FileInputStream.<init>(FileInputStream.java:160) E/flutter (12458): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1209) E/flutter (12458): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1187) E/flutter (12458): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1152) E/flutter (12458): at xyz.luan.audioplayers.source.UrlSource.setForMediaPlayer(UrlSource.kt:16) E/flutter (12458): at xyz.luan.audioplayers.player.MediaPlayerPlayer.setSource(MediaPlayerPlayer.kt:53) E/flutter (12458): at xyz.luan.audioplayers.player.WrappedPlayer.setSource(WrappedPlayer.kt:29) E/flutter (12458): at xyz.luan.audioplayers.AudioplayersPlugin.methodHandler(AudioplayersPlugin.kt:126) E/flutter (12458): at xyz.luan.audioplayers.AudioplayersPlugin.access$methodHandler(AudioplayersPlugin.kt:29) E/flutter (12458): at xyz.luan.audioplayers.AudioplayersPlugin$onAttachedToEngine$1$1.invoke(AudioplayersPlugin.kt:50) E/flutter (12458): at xyz.luan.audioplayers.AudioplayersPlugin$onAttachedToEngine$1$1.invoke(AudioplayersPlugin.kt:50) E/flutter (12458): at xyz.luan.audioplayers.AudioplayersPlugin$safeCall$1.invokeSuspend(AudioplayersPlugin.kt:75) E/flutter (12458): at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) E/flutter (12458): at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) E/flutter (12458): at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) E/flutter (12458): at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) E/flutter (12458): at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) E/flutter (12458): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) E/flutter (12458): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) E/flutter (12458): at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) E/flutter (12458): Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory) E/flutter (12458): at libcore.io.Linux.open(Native Method) E/flutter (12458): at libcore.io.ForwardingOs.open(ForwardingOs.java:563) E/flutter (12458): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274) E/flutter (12458): at libcore.io.ForwardingOs.open(ForwardingOs.java:563) E/flutter (12458): at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7758) E/flutter (12458): at libcore.io.IoBridge.open(IoBridge.java:560) E/flutter (12458): ... 20 more |
assetsに配置しているローカルファイルを指定する場合は、AssetSourceを使うと治ると思います。
1 2 3 4 |
void _playAlarm() async { const localFile = "audio/s.mp3"; await player.play(AssetSource(localFile)); } |
https://stackoverflow.com/questions/76405192/unhandled-exception-platformexceptionandroidaudioerror-setdatasource-failed