Audio_service: dynamic audio file path in backgroundTask

Created on 11 Mar 2019  路  4Comments  路  Source: ryanheise/audio_service

The example has a hardcoded audio file URL, and since the backgroundTask callback is in an isolate, I am unable to pass the correct URL to the AudioPlayer.

How can I pass a dynamic file path to the audio player in the BackgroundTask callback?

I was thinking to use isolate ports in the backgroundTask, but not sure if thats the correct way, or if it would even work (im new to flutter/dart)

Thanks.

Most helpful comment

@ryanheise Thanks for the tip, I ended up using the onCustomAction method successfully.

Once Im done my Android integration, I will be working on the iOS native code for this package.

Thanks!

All 4 comments

There is a discussion in #17 which might help you. Let me know if the approaches discussed there do not work.

The example has a hardcoded audio file URL, and since the backgroundTask callback is in an isolate, I am unable to pass the correct URL to the AudioPlayer.

How can I pass a dynamic file path to the audio player in the BackgroundTask callback?

I was thinking to use isolate ports in the backgroundTask, but not sure if thats the correct way, or if it would even work (im new to flutter/dart)

Thanks.

I'm doing exactly this with isolate ports. See #8 .

@ryanheise Thanks for the tip, I ended up using the onCustomAction method successfully.

Once Im done my Android integration, I will be working on the iOS native code for this package.

Thanks!

I will be working on the iOS native code for this package.

Nice

Was this page helpful?
0 / 5 - 0 ratings