Flutter-AssetsAudioPlayer icon indicating copy to clipboard operation
Flutter-AssetsAudioPlayer copied to clipboard

iOS ignores respectSilentMode: true flag when play sounds in silent mode

Open Mikhail-Ivanou opened this issue 4 years ago • 1 comments

Flutter Version

My version : Flutter (Channel stable, 2.2.3, on macOS 11.2.3 20D91 darwin-x64, locale ru-BY)

Lib Version

My version : 3.0.3+6

Platform (Android / iOS / web) + version

Platform : iOS 14.4

Describe the bug

Sounds are played with system volume when silent mode is on. Adding

Small code to reproduce

import 'package:assets_audio_player/assets_audio_player.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State {
  
  final AssetsAudioPlayer _assetsAudioPlayer = AssetsAudioPlayer();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: RaisedButton(
            child: Text("open"),
            onPressed: () {
              _playSound(Audio(%file in assets%) ) 
            }
          ),
        ),
      ),
    );
  }
}

Future<void> _playSound(Playable playable) async {
    final player = AssetsAudioPlayer.newPlayer();
    StreamSubscription? onFinished;
    onFinished = player.playlistFinished.listen((finished) {
      if (finished) {
        onFinished?.cancel();
        player.dispose();
      }
    });

    await player.open(playable, respectSilentMode: true);
  }

Mikhail-Ivanou avatar Sep 07 '21 10:09 Mikhail-Ivanou

same issue, any updates?

xweng1016 avatar Oct 29 '22 14:10 xweng1016