You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2020/01/06 02:38:21 UTC
[GitHub] [cordova-plugin-media] pliniofm edited a comment on issue #239:
MIDI (or MP3) file does not stop to play in background
pliniofm edited a comment on issue #239: MIDI (or MP3) file does not stop to play in background
URL: https://github.com/apache/cordova-plugin-media/issues/239#issuecomment-570981351
Workaround.
I changed the plugin source code:
File:
C:\Dropbox\plinio\PRG\phonegap\myapp\plugins\cordova-plugin-media\src\android\AudioHandler.java
C:\Dropbox\plinio\PRG\phonegap\myapp\platforms\android\app\src\main\java\org\apache\cordova\media\AudioHandler.java
I included the code below at the end of these files (BEFORE the last close-brace):
`
@Override
public void onPause(boolean multitasking) {
for (AudioPlayer audio : this.players.values()) {
if (audio.getState() == AudioPlayer.STATE.MEDIA_RUNNING.ordinal()) {
this.pausedForPhone.add(audio);
audio.pausePlaying();
}
}
}
@Override
public void onResume (boolean multitasking) {
for (AudioPlayer audio : this.pausedForPhone) {
audio.startPlaying(null);
}
this.pausedForPhone.clear();
}
`
Now, when I put my app in the background, the music pauses. And it resumes when I came back to app. :-)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org