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) {
|
||||
Intent intent = new Intent(getContext(), AudioPlaybackService.class);
|
||||
intent.setAction("STOP");
|
||||
getContext().stopService(intent);
|
||||
call.resolve();
|
||||
try {
|
||||
Intent intent = new Intent(getContext(), AudioPlaybackService.class);
|
||||
intent.setAction("STOP");
|
||||
// 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