На обоих iOS и Android при попытке изменить источник аудиофайла на активы я получаю сообщение об ошибке: unable to load asset
Я взял код из примера, расположенного по адресу здесь (pub.dev) и заменено
_player.setUrl("https://s3.amazonaws.com/scifri-episodes/scifri20181123-episode.mp3").catchError((error) {
// catch audio error ex: 404 url, wrong url ...
print(error);
});
на это: _player.setAsset("06 My Baby Left Me.mp3");
также создал папку в проекте под названием assets
с указанным выше файлом и соответственно обновил pubspec.yaml
.
Полный журнал ошибок:
W/o.justaudiodem(18220): Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (greylist, reflection, allowed)
I/ExoPlayerImpl(18220): Init b3b9aa8 [ExoPlayerLib/2.11.4] [a40, SM-A405FN, samsung, 29]
E/flutter (18220): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Unable to load asset: 06 My Baby Left Me.mp3
E/flutter (18220): #0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)
E/flutter (18220): <asynchronous suspension>
E/flutter (18220): #1 AudioPlayer.setAsset (package:just_audio/just_audio.dart:279:41)
E/flutter (18220): <asynchronous suspension>
E/flutter (18220): #2 _MyAppState.initState (package:justaudiodemo/main.dart:28:13)
E/flutter (18220): #3 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4640:58)
E/flutter (18220): #4 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4476:5)
E/flutter (18220): #5 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3446:14)
E/flutter (18220): #6 Element.updateChild (package:flutter/src/widgets/framework.dart:3214:18)
E/flutter (18220): #7 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1148:16)
E/flutter (18220): #8 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1119:5)
E/flutter (18220): #9 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:1061:17)
E/flutter (18220): #10 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2607:19)
E/flutter (18220): #11 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1060:13)
E/flutter (18220): #12 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:941:7)
E/flutter (18220): #13 WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:922:7)
E/flutter (18220): #14 _rootRun (dart:async/zone.dart:1180:38)
E/flutter (18220): #15 _CustomZone.run (dart:async/zone.dart:1077:19)
E/flutter (18220): #16 _CustomZone.runGuarded (dart:async/zone.dart:979:7)
E/flutter (18220): #17 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1019:23)
E/flutter (18220): #18 _rootRun (dart:async/zone.dart:1184:13)
E/flutter (18220): #19 _CustomZone.run (dart:async/zone.dart:1077:19)
E/flutter (18220): #20 _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1003:23)
E/flutter (18220): #21 Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:23:15)
E/flutter (18220): #22 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
E/flutter (18220): #23 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
E/flutter (18220): #24 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (18220):
любая помощь очень ценится.