[TIMOB-703] allow audio to play even when phone is locked/sleeping
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:53:58.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.3.0 |
Components | iOS |
Labels | n/a |
Reporter | Nolan Wright |
Assignee | Blain Hamon |
Created | 2011-04-15T02:34:49.000+0000 |
Updated | 2011-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
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')
The switch that allows audio to play while locked also allows audio to play when silenced/muted. Your issue will be fixed.
(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...
Here are the new constants defined in Ti.Media that define audio modes:
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.