{ "id": "62240", "key": "TIMOB-1608", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "15564", "description": "2013 Sprint 15 API", "name": "2013 Sprint 15 API", "archived": true, "released": true, "releaseDate": "2013-07-29" }, { "id": "15567", "description": "2013 Sprint 15", "name": "2013 Sprint 15", "archived": true, "released": true, "releaseDate": "2013-07-29" } ], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2013-07-22T17:55:33.000+0000", "created": "2011-04-15T02:57:15.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "audioplayer", "interrupt", "ios", "ipass1", "supportTeam" ], "versions": [], "issuelinks": [ { "id": "30339", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "117472", "key": "TIMOB-14627", "fields": { "summary": "Android: Expose the constant \"android.intent.action.PHONE_STATE\"", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } } ], "assignee": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-29T16:05:08.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h6.Issue\r\ncreateAudioPlayer() do not stop audio playback on an incoming. No events actually passed through these objects in order to check for calls.\r\n\r\nh6.Target environment\r\nTiSDK 3.1.1.GA & new HTC One/Android 4.1.2 \r\n\r\nh6.Sample\r\nTo reproduce run snippet, start audio playback then call to phone. \r\n{code}\r\nvar win = Titanium.UI.createWindow({ \r\n title:'Audio Test',\r\n backgroundColor:'#fff',\r\n layout: 'vertical'\r\n});\r\n\r\nvar startStopButton = Titanium.UI.createButton({\r\n title:'Start/Stop Streaming',\r\n top:10,\r\n width:200,\r\n height:40\r\n});\r\n\r\nvar pauseResumeButton = Titanium.UI.createButton({\r\n title:'Pause/Resume Streaming',\r\n top:10,\r\n width:200,\r\n height:40,\r\n enabled:false\r\n});\r\n\r\nwin.add(startStopButton);\r\nwin.add(pauseResumeButton);\r\n\r\n// allowBackground: true on Android allows the \r\n// player to keep playing when the app is in the \r\n// background. \r\nvar audioUrl = 'http://broadcast.infomaniak.net:80/energyzuerich-high.mp3';\r\nvar audioPlayer = Ti.Media.createAudioPlayer({ \r\n url: audioUrl,\r\n allowBackground: true\r\n}); \r\n \r\nstartStopButton.addEventListener('click',function() {\r\n // When paused, playing returns false.\r\n // If both are false, playback is stopped.\r\n if (audioPlayer.playing || audioPlayer.paused)\r\n {\r\n audioPlayer.stop();\r\n pauseResumeButton.enabled = false;\r\n if (Ti.Platform.name === 'android')\r\n { \r\n audioPlayer.release();\r\n } \r\n }\r\n else\r\n {\r\n audioPlayer.start();\r\n pauseResumeButton.enabled = true;\r\n }\r\n});\r\n\r\npauseResumeButton.addEventListener('click', function() {\r\n if (audioPlayer.paused) {\r\n audioPlayer.start();\r\n }\r\n else {\r\n audioPlayer.pause();\r\n }\r\n});\r\n\r\naudioPlayer.addEventListener('progress',function(e) {\r\n Ti.API.info('Time Played: ' + Math.round(e.progress) + ' milliseconds');\r\n});\r\n\r\naudioPlayer.addEventListener('change',function(e)\r\n{\r\n Ti.API.info('State: ' + e.description + ' (' + e.state + ')');\r\n});\r\n\r\nwin.addEventListener('close',function() {\r\n audioPlayer.stop();\r\n if (Ti.Platform.osname === 'android')\r\n { \r\n audioPlayer.release();\r\n }\r\n});\r\n\r\nwin.open();\r\n{code}", "attachment": [ { "id": "40442", "filename": "Razr_2.3.5_AudioPlayer_CallIncoming.txt", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-07-01T20:25:21.000+0000", "size": 548291, "mimeType": "text/plain" } ], "flagged": false, "summary": "Android: Audio not stopped on incoming call", "creator": { "name": "andrewheebner", "key": "andrewheebner", "displayName": "Andrew Heebner", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "andrewheebner", "key": "andrewheebner", "displayName": "Andrew Heebner", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "TiSDK 3.1.1.GA\r\nNew HTC One/Android 4.1.2 or Razr 2.3.5", "comment": { "comments": [ { "id": "126180", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

May actually be valid; not necessarily a call interrupt (which\nwe do check for, I believe, and which users can handle). Would have\nto be fired on the media module.

\n

Tagging for both iOS and Android, though this was originally\nfiled for Android only.

{html}", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:15.000+0000", "updated": "2011-04-15T02:57:15.000+0000" }, { "id": "126181", "author": { "name": "gerrycardinaliii", "key": "gerrycardinaliii", "displayName": "Gerry Cardinal III", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

On iOS, it does not look like the AudioStreamerCUR is currently\nlistening for interruptions:

\n
\n#ifdef TARGET_OS_IPHONE         \n//\n// MyAudioSessionInterruptionListener\n//\n// Invoked if the audio session is interrupted (like when the phone rings)\n//\n// TODO: Need to add this into the interruption framework, it's a bug!\nvoid MyAudioSessionInterruptionListenerCUR(void *inClientData, UInt32 inInterruptionState)\n{\n    AudioStreamerCUR* streamer = (AudioStreamerCUR *)inClientData;\n    [streamer handleInterruptionChangeToState:inInterruptionState];\n}\n#endif\n
{html}", "updateAuthor": { "name": "gerrycardinaliii", "key": "gerrycardinaliii", "displayName": "Gerry Cardinal III", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:57:16.000+0000", "updated": "2011-04-15T02:57:16.000+0000" }, { "id": "215230", "author": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "body": "No test case, ticket marked as invalid.", "updateAuthor": { "name": "jyounus", "key": "jyounus", "displayName": "Junaid Younus", "active": true, "timeZone": "Europe/London" }, "created": "2012-08-20T16:04:58.000+0000", "updated": "2012-08-20T16:04:58.000+0000" }, { "id": "215267", "author": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "body": "We should be able to put together a simple test case based on the description here.", "updateAuthor": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-20T19:33:51.000+0000", "updated": "2012-08-20T19:33:51.000+0000" }, { "id": "256824", "author": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Audio streaming apps require background streaming and with the incoming call event not automatically handled on the appcelerator android audioplayer, it leaves our appcelerator app with playing a stream while a user is having a telephonic conversation. Request to change priority of this ticket from trivial to higher priority and a fix implemented. \r\n\r\nPlease do suggest if you need code examples, but this can typically be replicated in kitchensink itself with a remote stream / shoutcast stream and the audio player.\r\n", "updateAuthor": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-09T03:59:57.000+0000", "updated": "2013-06-09T03:59:57.000+0000" }, { "id": "258104", "author": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi all,\r\n\r\nAny updates? Can you atleast suggest a work around for now? \r\n\r\nI have exhausted all attempts with broadcast receivers, android modules, etc.\r\n\r\n- Rahul", "updateAuthor": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-16T05:32:52.000+0000", "updated": "2013-06-16T05:32:52.000+0000" }, { "id": "259118", "author": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi all,\r\n\r\nAnyone looking into this?\r\nWould be great if I could get a lead in the right direction for a work around in the meanwhile...\r\n\r\n- Rahul", "updateAuthor": { "name": "rahul002", "key": "rahul002", "displayName": "Rahul Dhingra", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-06-23T02:43:19.000+0000", "updated": "2013-06-23T02:43:19.000+0000" }, { "id": "262549", "author": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "body": "If the audio is created with {allowBackground: false}, it will stop on incoming call. Because setting allowBackground to false means the audio should stop playing when its activity is paused. Please see our [doc|http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Media.Sound-property-allowBackground].", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-19T23:35:53.000+0000", "updated": "2013-07-19T23:35:53.000+0000" }, { "id": "262705", "author": { "name": "joelhulen", "key": "joelhulen", "displayName": "Joel Hulen", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I don't see this request as invalid, because the requirement to set allowBackground to true is valid in most audio-based apps I've developed. Most people don't want to keep the application in the foreground while listening to music/streaming audio for long periods of time. To support this, you must have the allowBackground set to true, then you run across the issue of the audio not automatically pausing when a call comes in. Please re-open this support ticket to address this issue for audio applications that require background playback.", "updateAuthor": { "name": "joelhulen", "key": "joelhulen", "displayName": "Joel Hulen", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-22T19:37:40.000+0000", "updated": "2013-07-22T19:37:40.000+0000" }, { "id": "262736", "author": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The developers can use [BroadcastReceiver|http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Android.BroadcastReceiver] to get the phone state. But right now, we don't expose the intent constant [ACTION_PHONE_STATE_CHANGED|http://developer.android.com/reference/android/telephony/TelephonyManager.html#ACTION_PHONE_STATE_CHANGED]. Will file a feature request for that. For now, the developers can use the workaround attached below:\r\n{code}\r\nvar win = Titanium.UI.createWindow({ \r\n title:'Audio Test',\r\n backgroundColor:'#fff',\r\n layout: 'vertical'\r\n});\r\n \r\nvar startStopButton = Titanium.UI.createButton({\r\n title:'Start/Stop Streaming',\r\n top:10,\r\n width:200,\r\n //height:40\r\n});\r\n \r\nvar pauseResumeButton = Titanium.UI.createButton({\r\n title:'Pause/Resume Streaming',\r\n top:10,\r\n width:200,\r\n //height:40,\r\n enabled:false\r\n});\r\n \r\nwin.add(startStopButton);\r\nwin.add(pauseResumeButton);\r\n \r\n// allowBackground: true on Android allows the \r\n// player to keep playing when the app is in the \r\n// background. \r\nvar audioUrl = 'http://broadcast.infomaniak.net:80/energyzuerich-high.mp3';\r\nvar audioPlayer = Ti.Media.createAudioPlayer({ \r\n url: audioUrl,\r\n allowBackground: true\r\n}); \r\n \r\nstartStopButton.addEventListener('click',function() {\r\n // When paused, playing returns false.\r\n // If both are false, playback is stopped.\r\n if (audioPlayer.playing || audioPlayer.paused)\r\n {\r\n audioPlayer.stop();\r\n pauseResumeButton.enabled = false;\r\n if (Ti.Platform.name === 'android')\r\n { \r\n audioPlayer.release();\r\n } \r\n }\r\n else\r\n {\r\n audioPlayer.start();\r\n pauseResumeButton.enabled = true;\r\n }\r\n});\r\n \r\npauseResumeButton.addEventListener('click', function() {\r\n if (audioPlayer.paused) {\r\n audioPlayer.start();\r\n }\r\n else {\r\n audioPlayer.pause();\r\n }\r\n});\r\n \r\naudioPlayer.addEventListener('progress',function(e) {\r\n Ti.API.info('Time Played: ' + Math.round(e.progress) + ' milliseconds');\r\n});\r\n \r\naudioPlayer.addEventListener('change',function(e)\r\n{\r\n Ti.API.info('State: ' + e.description + ' (' + e.state + ')');\r\n});\r\n \r\nwin.addEventListener('close',function() {\r\n audioPlayer.stop();\r\n if (Ti.Platform.osname === 'android')\r\n { \r\n audioPlayer.release();\r\n }\r\n});\r\n\r\nvar bc = Ti.Android.createBroadcastReceiver({\r\n\tonReceived : function(e) {\r\n\t\tTi.API.info('****************** Handling broadcast: ');\r\n\t\tif (e.intent) {\r\n\t\t\tvar state = e.intent.getStringExtra(\"state\");\r\n\t\t\tTi.API.info(\"phone state: \" + state);\r\n\t\t\tif (state === \"RINGING\") {\r\n\t\t\t\t// Incoming call. Pause the audio.\r\n\t\t\t\tTi.API.info(\"RINGING\");\r\n\t\t\t\taudioPlayer.pause()\r\n\t\t\t}\r\n\t\t\tif (state === \"OFFHOOK\") {\r\n\t\t\t\t// A call is dialing, active or on hold\r\n\t\t\t\tTi.API.info(\"OFFHOOK\");\r\n\t\t\t}\r\n\t\t\tif (state === \"IDLE\") {\r\n\t\t\t\t// Not in call. Resume the audio.\r\n\t\t\t\tTi.API.info(\"IDLE\");\r\n\t\t\t\taudioPlayer.start()\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}); \r\n\r\nTi.Android.registerBroadcastReceiver(bc, [\"android.intent.action.PHONE_STATE\"]);\r\n \r\nwin.open();\r\n{code}\r\nIn order to get the phone state, the READ_PHONE_STATE permission is required. So please add the permission to the tiapp.xml:\r\n{code}\r\n\r\n \r\n \r\n \r\n \r\n{code}", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-07-22T22:21:35.000+0000", "updated": "2013-07-22T23:00:39.000+0000" }, { "id": "416154", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as invalid.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-29T16:05:08.000+0000", "updated": "2017-03-29T16:05:08.000+0000" } ], "maxResults": 13, "total": 13, "startAt": 0 } } }