cordova-plugin-media
cordova-plugin-media copied to clipboard
feat(android): Adding playAudioWhenScreenIsLocked for Android (CB-12146)
When loosing focus of the app in android (onPause()) the audio playback is paused when playAudioWhenScreenIsLocked is set to false.
Platforms affected
Android
What does this PR do?
Adds the playAudioWhenScreenIsLocked flag to the Android version. This makes it possible to selectively keep audios playing, when onPause is called.
What testing has been done on this change?
Manual testing on Android N
Checklist
- [X] Reported an issue in the JIRA database
- [X] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
- [ ] Added automated test coverage as appropriate for this change.
Old PR: #121
One question:
I couldn't test the
onMessage(String id, Object data) {
method and its affects. when is this triggered?
Cordova CI Build has one or more failures.
Commit - Link Dashboard - Link
| Builder Name | Console Output | Test Report | Device Logs |
|---|---|---|---|
| Windows 10 Store | Link | Link | Link |
| iOS 9.3 | Link | Link | Link |
| iOS 10.0 | Link | Link | Link |
| Android 4.4 | Link | Link | Link |
| Android 5.1 | Link | Link | Link |
Let there be tests
Cordova CI Build has one or more failures.
Commit - Link Dashboard - Link
81 tests run, 15 skipped, 0 failed.
Hmm, looks like all three CI runs against Android (4.4, 5.1, and 6.0) failed. Output for these three test runs:
- Android 4.4: http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-media-pr/121/PLATFORM=android-4.4/console
- Android 5.1: http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-media-pr/121/PLATFORM=android-5.1/
- Android 6.0: http://cordova-ci.cloudapp.net:8080/job/cordova-plugin-media-pr/121/PLATFORM=android-6.0/
All three fail because of a missing import, PermissionHelper, which you removed in your PR:
Error: /private/var/folders/nd/5vd2nqsn3tlc6kljds0c95200000gp/T/tmp-8821EyOxfsP58Sxv/platforms/android/gradlew: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
/private/var/folders/nd/5vd2nqsn3tlc6kljds0c95200000gp/T/tmp-8821EyOxfsP58Sxv/platforms/android/src/org/apache/cordova/media/AudioHandler.java:83: error: cannot find symbol
PermissionHelper.requestPermission(this, requestCode, permissions[WRITE_EXTERNAL_STORAGE]);
^
symbol: variable PermissionHelper
location: class AudioHandler
We cannot accept this PR if it causes Cordova apps that add the plugin to not be able to compile.
Let there be tests
(hopefully this triggers the CI)
Cordova CI Build has completed successfully.
Commit - Link Dashboard - Link
162 tests run, 24 skipped, 0 failed.
Sweet, I'm down with merging this in. Small nit: if you could rebase w/ latest master and combine the commits into one that'd be fantastic!
@infil00p any concerns from you on this one?
Worth noting that the media plugin will likely be sunset down the road, in favour of the Media Capture plugin (which is more aligned with the latest W3C specs). For more info, see CB-12714.