Skip to content

Await execution of custom action #17

@BeMacized

Description

@BeMacized

As media items do not seem to contain any information about what to play (such as a streaming URL), I am trying to provide the background task with this information using the AudioService.customAction function.
After this, I would like to initiate playing with AudioService.play, roughly as such:

Map<String, String> sources = { 'mediaId': 'exampleUrl' }; 
await AudioService.customAction('addMediaSources', sources);
await AudioService.play();

However, it seems so that sometimes the onPlay callback in the background task is called before the onCustomAction callback completes. Because of this, there is yet no source to play from by the time the onPlay callback is called.
When adding a bit of a delay between the customAction and play calls, everything functions as normal.

It seems that the future returned by customAction can complete before the actual completion of the callback. Is it possible to change this behaviour, or is there maybe some other way I can wait for the custom action to complete before moving on?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions