Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25682] iOS: Ti.Media.audioSessionCategory not working correctly for an audioRecorder app.

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionNot Our Bug
Resolution Date2018-01-21T08:26:51.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsios
ReporterJose
AssigneeHans Knöchel
Created2018-01-17T18:49:39.000+0000
Updated2018-08-06T17:52:07.000+0000

Description

We are building an app wherein audio recording and playing audio files is a requirement. The problem we are facing now is when a music app(Spotify/sound-cloud) is playing an audio while we record audio using app the music app pauses the audio but when recording is stopped the music app audio is not resumed. we have tried all sessionCategories but none of these works. AUDIO_SESSION_CATEGORY_AMBIENT AUDIO_SESSION_CATEGORY_PLAYBACK AUDIO_SESSION_CATEGORY_PLAY_AND_RECORD AUDIO_SESSION_CATEGORY_RECORD AUDIO_SESSION_CATEGORY_SOLO_AMBIENT

Comments

  1. Hans Knöchel 2018-01-17

    Do you have an example of this behavior? Maybe a simplified test-case that we can reproduce? We did much refactoring on the AudioRecorder API recently, so it may be possible that we missed something. Thanks! *EDIT*: Some background: We added precompiler-statements to compile out APIs that the developer does not actually use. For the AudioRecorder, all audio-session APIs should be available though. So constants like Ti.Media.AUDIO_SESSION_CATEGORY_AMBIENT should return a value. Also, (until you provide the test-case), how did you set the audio-session category? Since Titanium SDK 7, it's recommended to use Ti.Media.setAudioSessionCategory(<one-of-the-constants-above>) *EDIT 2*: Can you confirm this does not happen on Titanium SDK 6.x ? We definitely need a test-case to continue. Thanks!
  2. Jose 2018-01-19

    We definitely need a test-case to continue. Thanks! --- this happens in both 6.x and 7.0.0 and 7.0.1 ------------------------ test-case: ------------------------ var window = Ti.UI.createWindow({ backgroundColor: '#fff' }); var recordStart = Ti.UI.createButton({ title: 'Start', top: 30 }); var recordPause = Ti.UI.createButton({ title: 'Pause', top: 90 }); var recordStop = Ti.UI.createButton({ title: 'Stop', top: 140 }); var recordPlay = Ti.UI.createButton({ title: 'Play', top: 190 }); Ti.Media.setAudioSessionCategory(Ti.Media.AUDIO_SESSION_CATEGORY_RECORD); var audioRecorder = Ti.Media.createAudioRecorder(); audioRecorder.format = Ti.Media.AUDIO_FILEFORMAT_WAVE; var record; var audioPlayer; window.addEventListener('open', function(e) { if (!Ti.Media.hasAudioRecorderPermissions()) { Ti.Media.requestAudioRecorderPermissions(function(e) { if (e.success) { window.add(recordStart); } }); } else { window.add(recordStart); } }); recordStart.addEventListener('click', function(e) { audioRecorder.start(); }); recordPause.addEventListener('click', function(e) { if (audioRecorder.getPaused()) { recordPause.setTitle('Pause'); audioRecorder.resume(); } else { recordPause.setTitle('Resume'); audioRecorder.pause(); } }); recordStop.addEventListener('click', function(e) { record = audioRecorder.stop(); Ti.API.info("====record "+record); Ti.API.info("====record file "+record.getNativePath()); }); recordPlay.addEventListener('click', function(e) { audioPlayer = Ti.Media.createAudioPlayer({ url: record.getNativePath(), volume : 1, allowBackground : true }); audioPlayer.start(); }); window.add(recordPause); window.add(recordStop); window.add(recordPlay); window.open();
  3. Hans Knöchel 2018-01-21

    And did it work with any previous SDK you used? The code looks conspicuous at a few parts, like allowBackground which is Android only and record that is handled as a Ti.Blob but is assigned via audioRecorder.stop() which is void and doesn't return anything. Seeing that and knowing that other developers use this API without issues in production, I'll resolve this ticket know as this place is rather for reporting issues with the SDK instead of issues with an own configuration. You can still reach out for help using Stackoverflow or the TiSlack community with > 1500 registered developers waiting to help. And if it turns out that your (fixed) code still is unable to work in the background, let us know and we'll consider to reopen this ticket, thanks!
  4. Eric Merriman 2018-08-06

    Closing as "not our bug". If you disagree, please reopen.

JSON Source