Update android/app/src/main/java/tf/monochrome/music/BackgroundAudioPlugin.java
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
parent
b4db909d6a
commit
2dbd1aac7a
1 changed files with 10 additions and 5 deletions
|
|
@ -32,11 +32,16 @@ public class BackgroundAudioPlugin extends Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PluginMethod
|
`@PluginMethod`
|
||||||
public void stop(PluginCall call) {
|
public void stop(PluginCall call) {
|
||||||
Intent intent = new Intent(getContext(), AudioPlaybackService.class);
|
try {
|
||||||
intent.setAction("STOP");
|
Intent intent = new Intent(getContext(), AudioPlaybackService.class);
|
||||||
getContext().stopService(intent);
|
intent.setAction("STOP");
|
||||||
call.resolve();
|
// Use startService so onStartCommand receives the STOP action
|
||||||
|
getContext().startService(intent);
|
||||||
|
call.resolve();
|
||||||
|
} catch (Exception e) {
|
||||||
|
call.reject("Failed to stop audio service: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue