2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Flutter]audioplayersやjust_audioでマナーモードにしても音楽がなってしまう

Posted at

AudioSessionのAVAudioSessionCategory(.playback)が原因なので、上書きする

import 'package:audio_session/audio_session.dart'; // importする
final player = AudioPlayer(); // audioplayersやjust_audioのPlayer

// ↓ここから追加
final session = await AudioSession.instance;
await session.configure(const AudioSessionConfiguration(
    avAudioSessionCategory: AVAudioSessionCategory.ambient, // .playbackを.ambientで上書き
));
// ↑ここまでを追加

player.play();

これで、下記になります

マナーモード: 音楽ならない
通常モード: 音楽なる
2
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?