Closed a-v-ebrahimi closed 3 years ago
I have the same issue, any update to this issue?
The same code works for me in iOs.
Try catching errors:
_positionSubscription = _audioPlayer.onAudioPositionChanged
.listen((_p) => _handlePosition(_p), onError: (_msg) {
print(_msg);
});
I've already tried this, no errors are produced!
After debugging from both sides (Dart platform channel API, Objective-C) code I just recognized that there is something wrong happening with the iOS platform channel events.
In AudioplayerPlugin.m line: 543 the following is getting called:
[_channel_audioplayer invokeMethod:@"audio.onCurrentPosition" arguments:@{@"playerId": playerId, @"value": @(mseconds)}];
on every time interval but Dart method audio.onCurrentPosition isn't getting called! In fact, even platformCallHandler isn't getting called at all on any received event, thus I'm only receiving the updated status (which is changing in the setter according to some dart written logic and not from a received event from native code).
Any ideas?
After more and more debugging, just realized that there is some conflict in my plugin registry, as I'm using
flutter_downloader dependency: https://pub.dev/packages/flutter_downloader
When I comment out the flutter downloader init method, everything works great.
The point is in order to use Flutter downloader plugin, you have to register the registrant callback like this: FlutterDownloaderPlugin.setPluginRegistrantCallback(registerPlugins) and as mentioned in the documentation:
In Flutter, in order to work in background isolate, plugins need to register with a special instance of
FlutterEngine
that serves for background execution only. Hence, all (and only) plugins that require background execution feature need to callregisterWithRegistrar
in this function.
But the method: optional static func setPluginRegistrantCallback(_ callback: @escaping FlutterPluginRegistrantCallback)
in protocol FlutterPlugin : FlutterApplicationLifeCycleDelegate isn;t overriden which is causing an exception on app opening.
Any ideas to fix?
Any updates on this issue?
Hi @alexeypodolian this works fine for me
I am experiencing the same issue @AnasMasri explained, but I don't have FlutterDownloader, rather, my application stops getting onPositionChanged event signals, when I start a background music with AudioService libary.
Closing this due to reports of this being fixed on newer versions. Feel free to open a new issue in case of this still happening
Salut
Est ce que le onAudioPositionchanged marche à nos jours, c'est à dire en 2022, car depuis là je suis entrain de regarder un tuto et essayer de reproduire mais je remarque que ça ne marche pas
@18BG
I used code below from your example to update player position in my UI, it works on Android perfectly, but doesn't work on iOS (listener is never called) :