Open andy-t-wang opened 3 years ago
Can you confirm that this is the unmodified official example? Does the bug also occur on the one-isolate
branch?
Yeah its unmodified, I just cloned the audio_service repo built it for web and deployed it.
According to @keaganhilliard in #457 there are some known issues with Safari, so for the moment this would not work for you currently. That being said, if you need a solution urgently, you can try #632 based on the one-isolate
branch, and then make your own local change to force it to use NoOpAudioService
for the web. This would completely disable the media session code but should allow everything else to work.
I have merged #632 so one thing you may try is overriding the platform manually to the new noop platform.
How would I override this? Would I need to fork the repo and make the change?
You would need to include the AudioServicePlatformInterface
in your pubspec like so:
audio_service_platform_interface:
git:
url: https://github.com/ryanheise/audio_service.git
ref: one-isolate
path: audio_service_platform_interface
And then at some point after you have detected that you are running in Safari. Set the instance like this:
AudioServicePlatform.instance = NoOpAudioService();
The issue is that Safari just flat out doesn't support the MediaSession APIs so there is probably an exception that is not being caught at some point (web debugging is still pretty painful even with Chrome). It would take some digging and unfortunately my Mac is no longer usable, so I can't really debug it myself.
Ok sounds good will take a look, also I think from memory the play button used to work in the version before null safety. The seekbar did not and just crashed.
You would need to include the
AudioServicePlatformInterface
in your pubspec like so:audio_service_platform_interface: git: url: https://github.com/ryanheise/audio_service.git ref: one-isolate path: audio_service_platform_interface
And then at some point after you have detected that you are running in Safari. Set the instance like this:
AudioServicePlatform.instance = NoOpAudioService();
Do I need to be using the one-isolate branch for my main audio service? I'm currently on null safety
Yeah all of this development has been focused on one-isolate
. The NoOpAudioService
only exists in that branch.
Which API doesn't behave as documented, and how does it misbehave? AudioService.positionStream and AudioService.playbackStateStream.distinct(), both streams are null on Safari
Minimal reproduction project Using the example code I hosted it and when on safari the seekbar doesn't move and play button doesn't switch to pause because the two streams are always returning null. https://andy-t-wang.github.io/audioservice/#/ Using the Null Safety version
To Reproduce (i.e. user steps, not code) Visit https://andy-t-wang.github.io/audioservice/#/ where I hosted the web version of the example code
Error messages
Expected behavior Streams expected to return playing state and position accurately
Screenshots If applicable, add screenshots to help explain your problem.
Runtime Environment (please complete the following information if relevant):
Flutter SDK version
Additional context Add any other context about the problem here.