Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant play local sound #1054

Closed
shaco75 opened this issue Jan 10, 2022 · 8 comments
Closed

cant play local sound #1054

shaco75 opened this issue Jan 10, 2022 · 8 comments

Comments

@shaco75
Copy link

shaco75 commented Jan 10, 2022

when i press the sound button it show error :
E/flutter (30513): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Unable to load asset: assets/sound/1.mp3
E/flutter (30513): #0 PlatformAssetBundle.load
package:flutter/…/services/asset_bundle.dart:237
E/flutter (30513):
E/flutter (30513): #1 AudioCache.fetchToMemory
package:audioplayers/src/audio_cache.dart:89
E/flutter (30513):
E/flutter (30513): #2 AudioCache.load
package:audioplayers/src/audio_cache.dart:115
E/flutter (30513):
E/flutter (30513): #3 AudioCache.play
package:audioplayers/src/audio_cache.dart:159
E/flutter (30513):
E/flutter (30513):

and i have been edited the pubspec.yaml already :

flutter:

uses-material-design: true
assets:
- sound/

@innerk
Copy link

innerk commented Jan 16, 2022

i'm having the same issue, any update on this?

@mkay-42069
Copy link

You're importing it wrong.
It's - assets/sound/.

@shaco75
Copy link
Author

shaco75 commented Jan 17, 2022

You're importing it wrong.

It's - assets/sound/.

@mkay-42069
No i tried this too but it's fault and its show red line under the "assets" its mean there is no folder named like that , thank you for you comment .

@shaco75
Copy link
Author

shaco75 commented Jan 17, 2022

@innerk no sorry , if you find the answer please let me know , thank you .

@innerk
Copy link

innerk commented Jan 17, 2022

@shaco75 hey try this one https://pub.dev/packages/just_audio just import your assets and make sure it's the correct path, then use player.setAsset('assets/bird.mp3') or from url and voila

@mkay-42069
Copy link

You're importing it wrong.
It's - assets/sound/.

@mkay-42069 No i tried this too but it's fault and its show red line under the "assets" its mean there is no folder named like that , thank you for you comment .

Sorry for not being clearer. You have to have it in the literal assets folder, because its hardcoded.
See:

@shaco75
Copy link
Author

shaco75 commented Jan 17, 2022

Thanks a lot guys i will try the both ways ❤️❤️
@innerk @mkay-42069

@luanpotter
Copy link
Member

Sorry for not being clearer. You have to have it in the literal assets folder, because its hardcoded.

Exactly.
Or you can change the prefix if you don't want to go with the convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants