ensureStopped in setUrl. Add missing success()'s.

This commit is contained in:
Ryan Heise 2019-12-29 21:15:43 +11:00
parent 9d01768f0d
commit 350f3951d5
1 changed files with 3 additions and 0 deletions

View File

@ -203,6 +203,7 @@ public class AudioPlayer implements MethodCallHandler {
if (state != PlaybackState.none && state != PlaybackState.stopped && state != PlaybackState.completed) { if (state != PlaybackState.none && state != PlaybackState.stopped && state != PlaybackState.completed) {
throw new IllegalStateException("Can call setUrl only from none/stopped/completed states"); throw new IllegalStateException("Can call setUrl only from none/stopped/completed states");
} }
ensureStopped();
transition(PlaybackState.connecting); transition(PlaybackState.connecting);
this.url = url; this.url = url;
if (extractor != null) { if (extractor != null) {
@ -277,9 +278,11 @@ public class AudioPlayer implements MethodCallHandler {
public void stop(final Result result) { public void stop(final Result result) {
switch (state) { switch (state) {
case stopped: case stopped:
result.success(null);
break; break;
case completed: case completed:
transition(PlaybackState.stopped); transition(PlaybackState.stopped);
result.success(null);
break; break;
// TODO: Allow stopping from buffered state. // TODO: Allow stopping from buffered state.
case playing: case playing: