[TIMOB-20234] Streaming Audio not working on Android Marshmallow with Alloy
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-03-02T07:08:54.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 5.4.0 |
Components | Android |
Labels | qe-5.4.0 |
Reporter | Ashraf Abu |
Assignee | Ashraf Abu |
Created | 2016-01-14T02:23:04.000+0000 |
Updated | 2016-07-08T21:12:48.000+0000 |
Description
As mentioned in ticket: TIMOB-20140 reported by [~patrickmounteney]
{quote}I did try a nightly build about a week ago and again today and found that although some of my Shoutcast streams now played under Android 6.0 (on a Nexus 7), others did not and produced our old friend error (1, -2147483648)
Examples:
Won't play: http://sc2.radiocaroline.net:10558
Will play: http://sc2.radiocaroline.net:8000
The error starts at: E/NuCachedSource2(16101): source returned error -1, 10 retries left
In a further test using 'Classic' Ti the stream that would not play in an Alloy build now plays and we see the following printed in the Console, which I have never seen in an Alloy implementation:
AAS: Asking for stream handler for protocol: 'http'
Audio in Android seems to be a bit of a lottery - if it works great. If it does't we're stuffed as nobody seems to be able to say what the cause is!{quote}
{quote}As far as I can tell both of the above Shoutcast streams are the same protocol as they come from the same server (Shoutcast 1.9.8), be it different ports. But read on as I spent some time testing this yesterday and my conclusion is that there is some difference between the way the 'Classic Ti' implements AudioPlayer behind the scenes and the way Alloy does. I can run the same very simple test (below) and get two different results, depending on if it was built with Alloy or not and version of Android the test is run under.
Test code built with Ti. SDK 6.0.0.v20160112093414 and targeting Android API 23
var player = Titanium.Media.createAudioPlayer(
{ allowBackground: true, url: "http://sc2.radiocaroline.net:10558" }
);
function streamButtonClick()
{ Ti.API.info("Playing : "+ player.url); player.play(); }
Test 1:
Alloy build - run on Nexus 7 Tablet Android 6.0.1 - It doesn't play and throws error (1, -2147483648)
Classic build - run on Nexus 7 Tablet Android 6.0.1 - streams plays
Test 2:
Alloy build - run on Lenovo Tablet Android 4.2.2 - streams plays
Classic build - run on Lenovo Tablet Android 4.2.2 - streams plays
Observations: When it works we see this printed in the Ti Console:
[DEBUG] : AAS: Asking for stream handler for protocol: 'http'
[DEBUG] : MediaPlayer: setSubtitleAnchor in MediaPlayer
When it doesn't work we get:
[ERROR] : MediaPlayer: error (1, -2147483648)
And when it does work, in the Android log we see:
01-12 07:48:55.722: D/audio_hw_primary(16101): enable_audio_route: apply and update mixer path: low-latency-playback
01-12 07:48:55.988: E/NuCachedSource2(16101): source returned error -1, 10 retries left
Conclusion: There is something in an Alloy build, when run under Android 6.0, that is causing NuCachedSource2 to error and the stream never plays.{quote}
Further in this issue: It looks to be a case of needing permissions for WRITE_EXTERNAL_STORAGE for streaming to work when run under Android 6.0. - at least for an Alloy build. I did a number of tests, mainly with a Nexus 7 device, but it was not until trying a Genymotion emulated Galaxy 6 that its log gave more detail of the issue: 02-06 15:58:11.667: E/FFmpegExtractor(480): android-source:0xf60d9cc0|file:http://sc2.radiocaroline.net:8000: avformat_open_input failed, err:Operation not permitted But the clincher was that on deleting and reinstalling my app I noticed some images that need downloading and storing in the applicationDataDirectory were failing with a large number of errors to do with permissions. It was only after adding runtime permission for WRITE_EXTERNAL_STORAGE that the streams suddenly started working again. But this only seemed to affect apps built with Alloy - a 'Classic' built app did not need these permissions. But if the failure to play audio streams is to do with permissions - what is being written to the applicationDataDirectory? Surely not the buffer? That would be to RAM memory would it not?
Tested this with the fix in TIMOB-20251. Issue is resolved. Resolving ticket as fixed.
[~patrickmounteney] Thanks for the investigation.
[~msamah] if this is fixed with TIMOB-20251, which is in 5.2 then the fixVersion for this ticket should be 5.2 right?
[~fokkezb] You are right.
Reopening since a TiSlack user reported it's still not working with the RC. He'll leave a comment with his findings here.
Tested with SDK 5.2.0RC and the error is still there. Genimotion Nexus 5 - Android 6.0 Result: [ERROR] : MediaPlayer: error (1, -2147483648)
As I understood it the fix was in SDK 6.0.0 (which is what I tested using a continuous build) - it certainly said the fix was in 6.00 at the top of one of the tickets relating to this, which I thought was TIMOB-20140, but I now see it's saying the fix is in Release 5.4.0! But still nobody has been able to tell me and the others what this fix actually is (not the permissions one as that appears to be required on top of the '6.00' fix).
[~msamah] I guess [~patrickmounteney] is right and this is not included by TIMOB-20251 (5.2) but TIMOB-20140 (5.4) so this ticket should be re-linked and resolved as fixed in 5.4
[~macasfaj] Could you provide a sample code for me to test this out? The link that would reproduce this error.
Sure! alloy.js
index.js:
The result is:
Thanks [~macasfaj] for the test case!
Tested that link with both Alloy and Classic with Android 6.0, same error occurs.
Don't think it's an Alloy issue. More of an Android 6.0 (Marshmallow issue)
5.2.0.GA seems to have this bug and it's not working. Tried this with Master (5.4.0) and alloy and classic version both are able to work.
Resolving this as fixed in 5.4.0.
Verified as fixed. Tested on: Nexus 5 (6.0.1) android emulator (6.0, 4.2.2) Mac OSX El Capitan 10.11.5 Studio: 4.7.0.201607070843 Ti SDK: 5.4.0.v20160705213725 Appc NPM: 4.2.8-1 Appc CLI: 5.4.0-29 Node v4.4.4 * Closing Ticket*