Project: titanium
Issue TIMOB-20234: Streaming Audio not working on Android Marshmallow with Alloy
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 {code} var player = Titanium.Media.createAudioPlayer( { allowBackground: true, url: "http://sc2.radiocaroline.net:10558" } ); function streamButtonClick() { Ti.API.info("Playing : "+ player.url); player.play(); } {code} 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}
Story points: 3