Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause on interruption #6

Closed
wants to merge 2 commits into from

Conversation

cosmok
Copy link
Contributor

@cosmok cosmok commented Jan 28, 2018

pause say when a call is received.
only on Android.

based off: https://gist.github.com/kuccello/5816882

@luanpotter
Copy link
Member

Thanks, @cosmok ! Nice addition! That's indeed a very useful feature to the lib. Some comments:

  • It seems that the stop function is not working, probably because of this typo:
    private static final String CMD_STOP = "pause";
  • It seems that there is some commented out code on BroadcastReceiver that causes it to misbehave in my tests

  • I'd add an option to allow this behavior to be disabled; someone might want to implement a background music player or something. But certainly the new way should be the default.

I'd add an optional parameter to the constructor (on Dart):

    AudioPlayer({ bool runOnBackground: false }) { /* ... */ }

Save that as a field and pass it in the play method on the channel:

    Future<int> play(String url, {bool isLocal: false, double volume: 1.0}) =>
_channel.invokeMethod('play', {"playerId": playerId, "url": url, "isLocal": isLocal, 'volume': volume, 'runOnBackground': runOnBackground });

And then receive this on the Android end and use it appropriately. Or something along those lines.

  • It'd be nice to have it on iOS as well, but since it's not a breaking change, we can merge this up and even release and then wait for someone with macbooks and idevices to come and help us out.

Thanks again for your contribution!

@luanpotter
Copy link
Member

Closing due to lack of response, please feel free to re-open or contact me anytime :))

@luanpotter luanpotter closed this Jun 6, 2018
@rajputvarun591 rajputvarun591 mentioned this pull request Jan 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants