View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0030373||Runner||Android||Public||2019-01-07 15:28||2019-01-30 16:20|
|Reporter||Stewart Bishop||Assigned To||Mike Rennie|
|Priority||Medium||Severity||B - Major||Reproducibility||100%|
|Target Version||2.2.2||Fixed in Version||2.2.2|
|Summary||0030373: Android: Audio recording doesn't work|
|Description||Created a sample to test audio recording and playback, which works as expected on Native, but on Android this will do nothing and throw you two errors:|
01-07 15:12:23.656 4353 4379 I yoyo : get configuration interface - Feature unsupported
01-07 15:12:23.660 4353 4379 I yoyo : recorder Realize - Content unsupported
|Steps To Reproduce||1) Plug in a microphone to your PC|
2) Run the sample on Windows
3) Press Record
4) Make some noise or talk
5) Press Play
6) Hear your sound played back as expected
7) Run the sample on Android
8) Press Record
9) See that the queue length doesn't increment and the errors appear in your ABD log
|1.4 Found In|
|2.x Runtime Found In||184.108.40.2063|
|2.x Runtime Verified In||220.127.116.112|
RecordAudioQueue.yyz (68,152 bytes)
I've attached a modified version of the sample which shows how to check for and request audio recording permissions on Android using the os_check_permission() and os_request_permission() functions.
<Removed old version as attached new version below>
In order to support audio recording on newer versions of Android permission must be explicitly given by the user. It turns out that we already had support for doing this but the functions were not exposed in the IDE, which I've now done.
The functions are:
- os_check_permission(permission) - this checks whether the specified permission is allowed and returns either 1, which means that permission is allowed, 0, which means that permission is denied, or -1, which means that permission is denied and furthermore shouldn't be requested. In the case of audio recording the permission to request is "android.permission.RECORD_AUDIO".
- os_request_permission(permission) - this shows an OS dialog which asks the user whether they wish to grant the specified permission. When the user responds it triggers an async System event. Within this system event a ds_map called "async_load" is available, which has a key called "type", which has the associated value "permission_request_result". There will also be a key which matches the name of the permission requested (in the sample this is "android.permission.RECORD_AUDIO") which will have a value of 0 if permission is allowed, or -1 if permission is denied.
I have now added some new GML constants to make this more user-friendly (and updated the sample appropriately):
- "os_permission_granted" - indicates that permission has been granted
- "os_permission_denied" - indicates that permission has been denied
- "os_permission_denied_dont_request" - indicates that permission has been denied, and either the user has selected "Dont ask again" or permission is blocked by the device settings
RecordAudioQueue_requestpermissions.yyz (76,716 bytes)
I've attached a slightly more Android friendly sample for anyone else that wants to use the above sample to implement, just adds some buttons rather than relying on mouse presses.
RecordAudioQueue_requestpermissions-2.yyz (83,022 bytes)