Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20140] Streaming Audio not working on Android Marshmallow

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-12-17T22:09:10.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.4.0
ComponentsAndroid
Labelsandroid, supportTeam
ReporterWouter Versluijs
AssigneeAshraf Abu
Created2015-10-26T16:15:59.000+0000
Updated2016-07-15T00:58:53.000+0000

Description

I'm having an issue with audio streaming on any Android device running the newest Android version (Marshmallow). I'm using the following code to play the audio stream (works on iOS, and android prior to Marshmallow); *Test case*
AudioPlayer = Ti.Media.createAudioPlayer({ allowBackground: true });
AudioPlayer.setUrl( 'http://icecast.omroep.nl/3fm-bb-mp3' );
AudioPlayer.start();
*Expected Result* Stream starts playing *Actual Result* Stream doesn't start playing, instead i'm getting an error saying “unknown media error”. --- Like I said, this was working on both iOS and Android (prior to Marshmallow). Does anyone know a workaround or a fix for this? Any help is appreciated!

Comments

  1. Mostafizur Rahman 2015-10-27

    Hello We tested this issue in our environment. Streaming audio is working properly. *Testing Environment:* Appc CLI - version 5.0.4-2 Appc Studio - 4.3.1 Mac OSx - 10.9.5 Node.js - 0.10.33 npm - 1.4.28 Ti SDK - 5.0.2 GA Android Emulator - Google Nexus 6p - 6.0.0 app.js
       var win = Titanium.UI.createWindow({
       title:'Audio Test',
       backgroundColor:'#fff',
       layout: 'vertical'
       });
       
       var startStopButton = Titanium.UI.createButton({
       title:'Start/Stop Streaming',
       top:10,
       width:200,
       height:40
       });
       
       var pauseResumeButton = Titanium.UI.createButton({
       title:'Pause/Resume Streaming',
       top:10,
       width:200,
       height:40,
       enabled:false
       });
       
       win.add(startStopButton);
       win.add(pauseResumeButton);
       
       // allowBackground: true on Android allows the
       // player to keep playing when the app is in the
       // background.
       var audioPlayer = Ti.Media.createAudioPlayer({
       url: 'http://icecast.omroep.nl/3fm-bb-mp3',
       allowBackground: true
       });
       
       startStopButton.addEventListener('click',function() {
       // When paused, playing returns false.
       // If both are false, playback is stopped.
       if (audioPlayer.playing || audioPlayer.paused)
       {
       audioPlayer.stop();
       pauseResumeButton.enabled = false;
       if (Ti.Platform.name === 'android')
       {
       audioPlayer.release();
       }
       }
       else
       {
       audioPlayer.start();
       pauseResumeButton.enabled = true;
       }
       });
       
       pauseResumeButton.addEventListener('click', function() {
       if (audioPlayer.paused) {
       audioPlayer.start();
       }
       else {
       audioPlayer.pause();
       }
       });
       
       audioPlayer.addEventListener('progress',function(e) {
       Ti.API.info('Time Played: ' + Math.round(e.progress) + ' milliseconds');
       });
       
       audioPlayer.addEventListener('change',function(e)
       {
       Ti.API.info('State: ' + e.description + ' (' + e.state + ')');
       });
       
       win.addEventListener('close',function() {
       audioPlayer.stop();
       if (Ti.Platform.osname === 'android')
       {
       audioPlayer.release();
       }
       });
       
       win.open();
       
    Thanks.
  2. Wouter Versluijs 2015-10-28

    Hi, Thanks for the quick response! I have tested the above code on a few Android devices and it still doesn't seem to work. *Testing Environment:* Appc CLI - Version 4.1.2 Mac OSx - 10.10.5 Node.js - v0.10.37 npm - 1.4.28 Ti SDK - 5.0.1.GA *Devices:* Sony Xperia Z3 - Android 4.4.4 (Works) Samsung Galaxy S4 - Android 5.0.1 (Works) Samsung Galaxy S6 Edge - Android 5.1.1 (Works) *LG Nexus 5 - Android 6.0 Marshmallow (Does not work)* Below is the logcat output that I get when trying to play the stream on the LG Nexus 5 with Android 6.0. So this issue only persists on Android 6.0 and not on prior releases.
       10-28 10:29:26.439   199   787 D audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
       10-28 10:29:26.450   199   786 D audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
       10-28 10:29:26.450   199   786 D msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15)
       10-28 10:29:26.450   199   786 D audio_hw_primary: enable_snd_device: snd_device(2: speaker)
       10-28 10:29:26.454   199   786 D audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback
       10-28 10:29:26.466 28963 28990 I TiAPI   :  State: starting (4)
       10-28 10:29:26.871   199 29045 E NuCachedSource2: source returned error -1, 10 retries left
       10-28 10:29:29.681   199   787 D audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
       10-28 10:29:29.682   199   787 D audio_hw_primary: disable_snd_device: snd_device(2: speaker)
       10-28 10:29:30.067   199 29045 E NuCachedSource2: source returned error -1, 9 retries left
       10-28 10:29:31.705   796  3645 D NetlinkSocketObserver: NeighborEvent{elapsedMs=160692055, 192.168.1.1, [001DAAC25F80], RTM_NEWNEIGH, NUD_REACHABLE}
       10-28 10:29:33.188   199 29045 E NuCachedSource2: source returned error -1, 8 retries left
       10-28 10:29:36.305   199 29045 E NuCachedSource2: source returned error -1, 7 retries left
       10-28 10:29:39.485   199 29045 E NuCachedSource2: source returned error -1, 6 retries left
       10-28 10:29:42.619   199 29045 E NuCachedSource2: source returned error -1, 5 retries left
       10-28 10:29:45.768   199 29045 E NuCachedSource2: source returned error -1, 4 retries left
       10-28 10:29:46.312   199   787 D audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2
       10-28 10:29:46.315 28963 28990 I TiAPI   :  State: playing (3)
       10-28 10:29:46.324   199   786 D audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
       10-28 10:29:46.324   199   786 D msm8974_platform: platform_send_audio_calibration: sending audio calibration for snd_device(2) acdb_id(15)
       10-28 10:29:46.324   199   786 D audio_hw_primary: enable_snd_device: snd_device(2: speaker)
       10-28 10:29:46.329   199   786 D audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback
       10-28 10:29:48.891   199 29045 E NuCachedSource2: source returned error -1, 3 retries left
       10-28 10:29:49.537   199   787 D audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback
       10-28 10:29:49.537   199   787 D audio_hw_primary: disable_snd_device: snd_device(2: speaker)
       10-28 10:29:52.019   199 29045 E NuCachedSource2: source returned error -1, 2 retries left
       10-28 10:29:54.647 28963 29072 I APSAnalyticsService: Analytics Service Started
       10-28 10:29:54.726 28963 29072 I APSAnalyticsService: Stopping Analytics Service
       10-28 10:29:55.096   199 29045 E NuCachedSource2: source returned error -1, 1 retries left
       10-28 10:29:58.217   199 29045 E NuCachedSource2: source returned error -1, 0 retries left
       10-28 10:29:58.327   199 29039 E GenericSource: Failed to init from data source!
       10-28 10:29:58.329   199 29038 D NuPlayerDriver: notifyListener_l(0xb3678900), (100, 1, -2147483648)
       10-28 10:29:58.330 28963 29040 E MediaPlayer: error (1, -2147483648)
       10-28 10:29:58.330 28963 28990 E MediaPlayer: Error (1,-2147483648)
       10-28 10:29:58.331   199  1338 D NuPlayerDriver: reset(0xb3678900)
       10-28 10:29:58.331   199  1338 D NuPlayerDriver: notifyListener_l(0xb3678900), (8, 0, 0)
       10-28 10:29:58.331   199 29038 D NuPlayerDriver: notifyResetComplete(0xb3678900)
       10-28 10:30:00.219   796  3072 I AccountManagerService: getTypesVisibleToCaller: isPermitted? true
       10-28 10:30:00.237  7976 29086 I EventLogService: Opted in for usage reporting
       10-28 10:30:00.242  7976 29086 I EventLogService: Aggregate from 1446024316135 (log), 1446022800106 (data)
       10-28 10:30:00.392  7976 29086 I ServiceDumpSys: dumping service [account]
       10-28 10:30:01.017   796   809 I ActivityManager: Start proc 29096:com.google.android.deskclock/u0a69 for broadcast com.google.android.deskclock/com.android.alarmclock.DigitalAppWidgetProvider
       10-28 10:30:01.043 29096 29096 W System  : ClassLoader referenced unknown path: /data/app/com.google.android.deskclock-1/lib/arm
       10-28 10:30:01.064 29096 29096 I GAv4    : Google Analytics 7.8.95 is starting up. To enable debug logging on a device run:
       10-28 10:30:01.064 29096 29096 I GAv4    :   adb shell setprop log.tag.GAv4 DEBUG
       10-28 10:30:01.064 29096 29096 I GAv4    :   adb logcat -s GAv4
       10-28 10:30:01.076 29096 29096 W GAv4    : AnalyticsReceiver is not registered or is disabled. Register the receiver for reliable dispatching on non-Google Play devices. See http://goo.gl/8Rd3yj for instructions.
       10-28 10:30:01.081 29096 29096 W GAv4    : CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.
       10-28 10:30:01.088 29096 29118 W GAv4    : AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See http://goo.gl/8Rd3yj for instructions.
       
    Could you try this on an actual device with Android 6.0 and see if you can reproduce this issue? Also i'm using Titanium SDK 3.5.1.GA in the live version of the apps where I use streaming music, and this issue also occurs. And just for my information, is it still possible to build apps for the Playstore and Appstore with the newest Titanium release (5.0.2.GA) for free? Or do you now need a subscription (Indie, Team or Enterprise) to use the newer versions of Titanium?
  3. Patrick Mounteney 2015-11-10

    I can confirm that I am getting reports from users of my radio streaming apps on Google Play that they no longer play after the user has installed Android 6.0. I also installed Android 6.0 on my Nexus 7 last night and found this to be the case. I then re-built an app using the Android 6.0 SDK (was previously build targeting Android 5.0) but found it still won't play. The error thrown is Player error: Unknown media error. code is -2147483648 And I've just downloaded a Genymotion Nexus 5X with Android 6.0 and found it also won't play audio streams using the Appcelerator AudioPlayer API (mp3 streams from a streaming server).
  4. Pasquale 2015-11-11

    Hi to all, Yesterday my Nexus 7 2015 updated to Android 6.0 Marshmallow and my radio streaming dont work. I tried by Genymotion Nexus 5X but same result. No console errors and no sound. Some news? Thanks
  5. Patrick Mounteney 2015-11-16

    Thanks for opening this again. If you want a URL to test try http://sc6.radiocaroline.net:8040 I have also tried adding /;.mp3 on the end as some devices (Galaxy models) won't recognise this as a stream without it. Both produce Unknown media error -2147483648 I don't suppose this is a revival of the 'OKHTTP' bug from Android 5.0?
  6. Wouter Versluijs 2015-12-10

    Has there been any update regarding this issue? A fix or maybe a workaround?
  7. Stali Matos 2015-12-14

    I have the same problem... Marshmallow dont play audio streaming Icecast / shoutcas mp3.
  8. Ashraf Abu 2015-12-17

    PR: https://github.com/appcelerator/titanium_mobile/pull/7591
  9. Ashraf Abu 2015-12-18

    PR merged.
  10. Patrick Mounteney 2015-12-18

    Thanks Ashram - what was the actual problem then? And do you know when the fix will make it's way into the Ti SDK?
  11. Ashraf Abu 2015-12-22

    This is planned for fix release in SDK 6.0.0.
  12. Wouter Versluijs 2016-01-11

    Thanks Ashram! Is it possible to fix this in one of the current builds? 5.2 or maybe a 5.3?
  13. Ashraf Abu 2016-01-12

    If you need the latest and greatest right from the oven, you could try the master branch (which is currently set at 6.0.0) http://builds.appcelerator.com.s3.amazonaws.com/index.html#master from the builds. These are not GA or even RC, so be careful with this. These are continuous builds. I quote *Below are the latest untested continuous integrations builds of the Titanium SDK. * Alternatively, you could compile it yourself from github and take only the changes you need in to a 5.2.X branch.
  14. Patrick Mounteney 2016-01-12

    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!
  15. Ashraf Abu 2016-01-13

    [~patrickmounteney] Thanks for checking this out. {quote}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:{quote} So basically this is a good thing? Just that there is a weird log entry. Will need to investigate {quote}Won't play: http://sc2.radiocaroline.net:10558 Will play: http://sc2.radiocaroline.net:8000{quote}
  16. Ashraf Abu 2016-01-13

    Do you know if there is any difference between the 2 Shoutcast? (Slight protocol differences? etc...)
  17. Patrick Mounteney 2016-01-13

    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.
  18. Ashraf Abu 2016-01-14

    [~patrickmounteney] Created this ticket TIMOB-20234 to address this.
  19. Patrick Mounteney 2016-02-08

  20. Lokesh Choudhary 2016-07-15

JSON Source