Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19633] iOS: AUDIO_SESSION_CATEGORY_AMBIENT stops background music

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2015-10-12T05:29:05.000+0000
Affected Version/sRelease 4.1.1
Fix Version/sRelease 5.2.0
ComponentsiOS
Labelsios, qe-5.2.0
ReporterDavide Ensini
AssigneeAngel Petkov
Created2015-08-06T10:40:39.000+0000
Updated2016-01-22T00:43:15.000+0000

Description

This command stops iPod music, while it shouldn't. Ti.Media.audioSessionCategory = Ti.Media.AUDIO_SESSION_CATEGORY_AMBIENT; Someone found a workaround for this, see [this link](https://community.appcelerator.com/topic/2819/ios-app-stops-device-audio-at-startup-music-app-pandora-etc/2) Summarized: >>I ended up solving this problem by editing TiApp.m on the SDK and adding the following code to didFinishLaunchingWithOptions: NSError *setCategoryError = nil; BOOL audioOk = [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: &setCategoryError];

Attachments

FileDateSize
alloy.js2015-08-12T10:24:33.000+0000602

Comments

  1. Motiur Rahman 2015-08-11

    Hello [~nsndvd], Could you please share a runnable test case with steps to reproduce and environment so that we can figure out this issue. Thanks.
  2. Davide Ensini 2015-08-11

    Nope, because, unless there is a way to use the ipod player in the simulator, this can only be reproduced on real devices, and you would need provisioning profiles and stuff. So you can try this way: On any project you have ready to be deployed on an iOS device, in alloy.js add the line: Ti.Media.audioSessionCategory = Ti.Media.AUDIO_SESSION_CATEGORY_AMBIENT; Deploy, then launch music, and start the app (start, not resume). Music will stop.
  3. Radamantis Torres-Lechuga 2015-08-11

    [~nsndvd] please provide a test case, we can test on our devices
  4. Davide Ensini 2015-08-12

    Please find at this [link](https://dl.dropboxusercontent.com/u/63904025/daddyhunt/test_case_audio_session_category_ambient.zip) a titanium alloy project that i just generated with studio. I only added the following line in alloy.js. Ti.Media.audioSessionCategory = Ti.Media.AUDIO_SESSION_CATEGORY_AMBIENT;" I'm also attaching the alloy.js file. You have to add an app id in tiapp.xml, I'm not giving you mine because you need a matching provisioning profile. I tested this on an iphone4 with iOS 7. Music from iPod is stopped when the app is started (not resumed). Thanks
  5. Chee Kiat Ng 2015-10-12

    PR Here: https://github.com/appcelerator/titanium_mobile/pull/7270 Approved and merged.
  6. Harry Bryant 2016-01-21

    Verified as fixed, Tested demo code both with speaker / headphone output. App no longer pauses background music when launched. Tested on: iPhone 6s Plus Device (9.2) & iPhone 6 Plus Device (8.4) Mac OSX El Capitan 10.11 (15A284) Ti SDK: 5.2.0.v20160114021251 Appc NPM: 4.2.3-1 App CLI: 5.2.0-231 Xcode 7.2 Node v4.2.3 *Closing Ticket.*

JSON Source