cordova-plugin-media icon indicating copy to clipboard operation
cordova-plugin-media copied to clipboard

feat(android): Adding playAudioWhenScreenIsLocked for Android (CB-12146)

Open romedius opened this issue 8 years ago • 9 comments
trafficstars

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.

romedius avatar Mar 25 '17 01:03 romedius

Old PR: #121

One question: I couldn't test the onMessage(String id, Object data) { method and its affects. when is this triggered?

romedius avatar Mar 25 '17 01:03 romedius

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

cordova-qa avatar Mar 25 '17 02:03 cordova-qa

Let there be tests

filmaj avatar Apr 26 '17 01:04 filmaj

Cordova CI Build has one or more failures.

Commit - Link Dashboard - Link

81 tests run, 15 skipped, 0 failed.

cordova-qa avatar Apr 26 '17 02:04 cordova-qa

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.

filmaj avatar Apr 26 '17 14:04 filmaj

Let there be tests

romedius avatar Jun 06 '17 09:06 romedius

(hopefully this triggers the CI)

romedius avatar Jun 06 '17 09:06 romedius

Cordova CI Build has completed successfully.

Commit - Link Dashboard - Link

162 tests run, 24 skipped, 0 failed.

cordova-qa avatar Jun 06 '17 10:06 cordova-qa

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.

filmaj avatar Jun 06 '17 21:06 filmaj