-
Notifications
You must be signed in to change notification settings - Fork 868
Open
Labels
Description
Checklist
- I read the troubleshooting guide before raising this issue
- I made sure that the issue I am raising doesn't already exist
Current bug behaviour
Now, when the plugin is initialized in the engine, AVAudioSession is set by default.
Lines 27 to 50 in f2269ae
init( | |
registrar: FlutterPluginRegistrar, | |
binaryMessenger: FlutterBinaryMessenger, | |
methodChannel: FlutterMethodChannel, | |
globalMethodChannel: FlutterMethodChannel, | |
globalEventChannel: FlutterEventChannel | |
) { | |
self.registrar = registrar | |
self.binaryMessenger = binaryMessenger | |
self.methods = methodChannel | |
self.globalMethods = globalMethodChannel | |
self.globalEvents = GlobalAudioPlayersStreamHandler() | |
do { | |
try globalContext.apply() | |
} catch { | |
// ignore error on initialization | |
} | |
super.init() | |
self.globalMethods.setMethodCallHandler(self.handleGlobalMethodCall) | |
globalEventChannel.setStreamHandler(self.globalEvents) | |
} |
In a pure flutter application, this is of course not a problem, as it makes the application to play without setting AVAudioSession. However, in a hybrid application, since AVAudioSession is a global singleton, In the native page, the AVAudioSession might have been modified. For instance, if a video is playing in the native context and the value of AVAudioSession is modified, when redirected to the flutter page, due to the engine's initialization, the original value may be overwritten, resulting in unexpected behavior. Especially, the default value of the current plugin is
.playback
, which will interrupt other audio.
Expected behaviour
The plugin does not call apply
during initialization but initializes it through manual invocation.
Steps to reproduce
- Write a hybrid application
- Open a native page and modified AVAudioSession
- Open a flutter page
- Then the AVAudioSession will be change
Code sample
Code sample
void main() {
}
Affected platforms
iOS
Platform details
No response
AudioPlayers Version
6.5.0
Build mode
release
Audio Files/URLs/Sources
No response
Screenshots
No response
Logs
my relevant logs
Full Logs
my full logs or a link to a gist
Flutter doctor:
Output of: flutter doctor -v
Related issues / more information
No response
Working on PR
no way