audioplayers
audioplayers copied to clipboard
[ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: MissingPluginException(No implementation found for method getTemporaryDirectory on channel plugins.flutter.io/path_provider)
This is my code
import 'package:audioplayers/audio_cache.dart'; import 'package:flutter/material.dart';
void main() { runApp(MyApp()); }
class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: SafeArea( child: Center( child: FlatButton( onPressed: () { final player = AudioCache(); player.play('assets/note1.wav'); }, child: Text('Click Me'), ), )), ), ); } }
This is pubspec.yaml
name: untitled1 description: A new Flutter project.
publish_to: 'none'
https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment: sdk: ">=2.7.0 <3.0.0"
dependencies: flutter: sdk: flutter
cupertino_icons: ^0.1.3
audioplayers:
dev_dependencies: flutter_test: sdk: flutter
flutter:
The following line ensures that the Material Icons font is
included with your application, so that you can use the icons in
the material Icons class.
uses-material-design: true
To add assets to your application, add an assets section, like this:
assets: - assets/
An image asset can refer to one or more resolution-specific "variants", see
https://flutter.dev/assets-and-images/#resolution-aware.
For details regarding adding assets from package dependencies, see
https://flutter.dev/assets-and-images/#from-packages
To add custom fonts to your application, add a fonts section here,
in this "flutter" section. Each entry in this list should have a
"family" key with the font family name, and a "fonts" key with a
list giving the asset and other descriptors for the font. For
example:
fonts:
- family: Schyler
fonts:
- asset: fonts/Schyler-Regular.ttf
- asset: fonts/Schyler-Italic.ttf
style: italic
- family: Trajan Pro
fonts:
- asset: fonts/TrajanPro.ttf
- asset: fonts/TrajanPro_Bold.ttf
weight: 700
For details regarding fonts from package dependencies,
see https://flutter.dev/custom-fonts/#from-packages
kindly help
Hi, are you still facing this issue? If you are still facing this issue, try calling only player.play('note1.wav');
As from the docs
// call this method when desired
player.play('explosion.mp3');
This will play the explosion.mp3 file in your project's assets folder.
The file structure would be something like this:
. └── assets └── explosion.mp3 Don't forget to add these files to your pubspec.yaml file:
flutter: assets:
- assets/explosion.mp3 You can optionally pass a prefix to the constructor if all of your audios are in a specific folder inside the assets folder. Flame, for instance, uses the 'assets/audio/' prefix:
AudioCache player = AudioCache(prefix: 'assets/audio/');
player.play('explosion.mp3');
// now this file will be loaded from assets/audio/explosion.mp3
@AkhtarAli11 Doesn't seem to react on help, Thank you @ayinloya . Closing :)
For anyone having the same issue, rebuild the app solved my problem.
ref: https://stackoverflow.com/a/58082118/9511922