LoginSignup
0
0

More than 1 year has passed since last update.

audioplayersを実装する上で躓くポイントの解決方法

Posted at

初心者なので具体的なことは書けませんが自分が躓いていたことを解決した際の記録として残しています。

解決したこと

flutterでボタンを押すと音が再生されるものを作っている最中
audioplayersを実装する上でAudioPlayerStateなどがエラーになってしまった時の解決方法

発生している問題・エラー

Undefined class 'AudioPlayerState'.

このAudioPlayerStateがエラーになる

  AudioPlayer audioPlayer = AudioPlayer();
  AudioPlayerState audioPlayerState = AudioPlayerState.PAUSED;
  String url = 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-13.mp3';

解決方法

AudioPlayerStateをPlayerStateに.PAUSEDを小文字に変更する。
ついでに
.PLAYINGも小文字にすると、onAudioPositionChangedはonPositionChangedに変えるとエラーが治ります!!

  AudioPlayer audioPlayer = AudioPlayer();
  PlayerState audioPlayerState = PlayerState.paused;
  String url = 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-13.mp3';
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0