Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-703] allow audio to play even when phone is locked/sleeping

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:53:58.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.3.0
ComponentsiOS
Labelsn/a
ReporterNolan Wright
AssigneeBlain Hamon
Created2011-04-15T02:34:49.000+0000
Updated2011-04-17T01:53:58.000+0000

Description

see:

// Registers this class as the delegate of the audio session. [[AVAudioSession sharedInstance] setDelegate: self];
// Allow the app sound to continue to play when the screen is locked. [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];

this came from premium support:

http://helpdesk.appcelerator.net/tickets/1751">http://helpdesk.appcelerator.net/tickets/1751

need to decide on the property name

Comments

  1. kosso 2011-04-15

    As a further note to this (as it might be related), users have noticed that when playing a video using the VideoPlayer, switching the silent switch on the side of the phone on and off that audio continues to be heard from the speaker (without headphones plugged in) : this is expected, I believe.

    But when listening to audio playing using the Sound object, switching the silent/mute switch does turn the speaker off and on.

    Is this expected behavior?

    I guess using the AudioPlayer would have the same effect as the VideoPlayer?

    (ps: I use the Sound object for a remote url, since the AudioPlayer does not have the ability to provide the 'duration' of the remote audio - but only 'progress')

  2. Stephen Tramer 2011-04-15

    The switch that allows audio to play while locked also allows audio to play when silenced/muted. Your issue will be fixed.

  3. Jeff Haynie 2011-04-15

    (from [fecb672c56b4a807661607bce1eb4bc326189d69]) Closes #703: Support for different audio playback styles. See sound_local.js for an example. Descriptions of the audio modes will be posted to the lighthouse ticket for this bug. http://github.com/appcelerator/titanium_mobile/commit/fecb672c56b4a807661607bce1eb4bc326189d69"> http://github.com/appcelerator/titanium_mobile/commit/fecb672c56b4a...

  4. Stephen Tramer 2011-04-15

    Here are the new constants defined in Ti.Media that define audio modes:

       AUDIO_SESSION_MODE_AMBIENT: Audio is mixed with existing audio, does not play on mute/lock.
       AUDIO_SESSION_MODE_SOLO_AMBIENT: The default mode.  Audio is not mixed, does not play on mute/lock.
       AUDIO_SESSION_MODE_PLAYBACK: Audio is not mixed, does play on mute/lock.
       AUDIO_SESSION_MODE_RECORD: Default mode for recording.  Silences all playback audio.
       AUDIO_SESSION_MODE_PLAY_AND_RECORD: Allows for simultaneous playing and recording of audio.
       

    Please remember that while recording/playing, the setting for that media audio component is considered GLOBAL (this is how it's implemented natively; no way around it). This means that if you start playing one sound in the middle of another, you may get unpredictable results. Make sure that when mixing a window that supports both playing and recording to use the PLAY_AND_RECORD mode on everything if necessary, and to halt recording on playback (and possibly vice-versa) otherwise.

JSON Source