{ "id": "99357", "key": "TIMOB-10481", "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": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2012-08-20T11:17:49.000+0000", "created": "2012-08-16T18:18:22.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "api" ], "versions": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" }, { "id": "13572", "description": "Release 2.1.1", "name": "Release 2.1.1", "archived": true, "released": true, "releaseDate": "2012-07-31" } ], "issuelinks": [], "assignee": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-09T23:10:49.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": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "Audio recording functionality doesn't work after the Ti SDK 2.0.2.GA.\r\n\r\nh4. Repo Steps\r\n1. Run the below code in your app.js\r\n2. Open the application and you can't record the audio.\r\n\r\n{code}\r\nvar win = Titanium.UI.createWindow();\r\n\r\nTitanium.Media.audioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAY_AND_RECORD;\r\nvar recording = Ti.Media.createAudioRecorder();\r\nTi.Media.addEventListener('recordinginput', function(e) {\r\n\tTi.API.info('Input availability changed: '+e.available);\r\n\tif (!e.available && recording.recording) {\r\n\t\tb1.fireEvent('click', {});\r\n\t}\r\n});\r\n\r\nvar file;\r\nvar timer;\r\nvar sound;\r\n\r\n\r\nvar label = Titanium.UI.createLabel({\r\n\ttext:'',\r\n\ttop:150,\r\n\tcolor:'#999',\r\n\ttextAlign:'center',\r\n\twidth:'auto',\r\n\theight:'auto'\r\n});\r\n\r\nwin.add(label);\r\n\r\nfunction lineTypeToStr()\r\n{\r\n\tvar type = Ti.Media.audioLineType;\r\n\tswitch(type)\r\n\t{\r\n\t\tcase Ti.Media.AUDIO_HEADSET_INOUT:\r\n\t\t\treturn \"headset\";\r\n\t\tcase Ti.Media.AUDIO_RECEIVER_AND_MIC:\r\n\t\t\treturn \"receiver/mic\";\r\n\t\tcase Ti.Media.AUDIO_HEADPHONES_AND_MIC:\r\n\t\t\treturn \"headphones/mic\";\r\n\t\tcase Ti.Media.AUDIO_HEADPHONES:\r\n\t\t\treturn \"headphones\";\r\n\t\tcase Ti.Media.AUDIO_LINEOUT:\r\n\t\t\treturn \"lineout\";\r\n\t\tcase Ti.Media.AUDIO_SPEAKER:\r\n\t\t\treturn \"speaker\";\r\n\t\tcase Ti.Media.AUDIO_MICROPHONE:\r\n\t\t\treturn \"microphone\";\r\n\t\tcase Ti.Media.AUDIO_MUTED:\r\n\t\t\treturn \"silence switch on\";\r\n\t\tcase Ti.Media.AUDIO_UNAVAILABLE:\r\n\t\t\treturn \"unavailable\";\r\n\t\tcase Ti.Media.AUDIO_UNKNOWN:\r\n\t\t\treturn \"unknown\";\r\n\t}\r\n}\r\n\r\nvar linetype = Titanium.UI.createLabel({\r\n\ttext: \"audio line type: \"+lineTypeToStr(),\r\n\tbottom:20,\r\n\tcolor:'#999',\r\n\ttextAlign:'center',\r\n\twidth:'auto',\r\n\theight:'auto'\r\n});\r\n\r\nwin.add(linetype);\r\n\r\nvar volume = Titanium.UI.createLabel({\r\n\ttext: \"volume: \"+Ti.Media.volume,\r\n\tbottom:50,\r\n\tcolor:'#999',\r\n\ttextAlign:'center',\r\n\twidth:'auto',\r\n\theight:'auto'\r\n});\r\n\r\nwin.add(volume);\r\n\r\nTi.Media.addEventListener('linechange',function(e)\r\n{\r\n\tlinetype.text = \"audio line type: \"+lineTypeToStr();\r\n});\r\n\r\nTi.Media.addEventListener('volume',function(e)\r\n{\r\n\tvolume.text = \"volume: \"+e.volume;\r\n});\r\n\r\nvar duration = 0;\r\n\r\nfunction showLevels()\r\n{\r\n\tvar peak = Ti.Media.peakMicrophonePower;\r\n\tvar avg = Ti.Media.averageMicrophonePower;\r\n\tduration++;\r\n\tlabel.text = 'duration: '+duration+' seconds\\npeak power: '+peak+'\\navg power: '+avg;\r\n}\r\n\r\nvar b1 = Titanium.UI.createButton({\r\n\ttitle:'Start Recording',\r\n\twidth:200,\r\n\theight:40,\r\n\ttop:20\r\n});\r\nb1.addEventListener('click', function()\r\n{\r\n\tif (recording.recording)\r\n\t{\r\n\t\tfile = recording.stop();\r\n\t\tb1.title = \"Start Recording\";\r\n\t\tb2.show();\r\n\t\tpause.hide();\r\n\t\tclearInterval(timer);\r\n\t\tTi.Media.stopMicrophoneMonitor();\r\n\t}\r\n\telse\r\n\t{\r\n\t\tif (!Ti.Media.canRecord) {\r\n\t\t\tTi.UI.createAlertDialog({\r\n\t\t\t\ttitle:'Error!',\r\n\t\t\t\tmessage:'No audio recording hardware is currently connected.'\r\n\t\t\t}).show();\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tb1.title = \"Stop Recording\";\r\n\t\trecording.start();\r\n\t\tb2.hide();\r\n\t\tpause.show();\r\n\t\tTi.Media.startMicrophoneMonitor();\r\n\t\tduration = 0;\r\n\t\ttimer = setInterval(showLevels,1000);\r\n\t}\r\n});\r\nwin.add(b1);\r\n\r\nvar pause = Titanium.UI.createButton({\r\n\ttitle:'Pause recording',\r\n\twidth:200,\r\n\theight:40,\r\n\ttop:80\r\n});\r\nwin.add(pause);\r\npause.hide();\r\n\r\npause.addEventListener('click', function() {\r\n\tif (recording.paused) {\r\n\t\tpause.title = 'Pause recording';\r\n\t\trecording.resume();\r\n\t\ttimer = setInterval(showLevels,1000);\r\n\t}\r\n\telse {\r\n\t\tpause.title = 'Unpause recording';\r\n\t\trecording.pause();\r\n\t\tclearInterval(timer);\r\n\t}\r\n});\r\n\r\nvar b2 = Titanium.UI.createButton({\r\n\ttitle:'Playback Recording',\r\n\twidth:200,\r\n\theight:40,\r\n\ttop:80\r\n});\r\n\r\nwin.add(b2);\r\nb2.hide();\r\nb2.addEventListener('click', function()\r\n{\r\n\tif (sound && sound.playing)\r\n\t{\r\n\t\tsound.stop();\r\n\t\tsound.release();\r\n\t\tsound = null;\r\n\t\tb2.title = 'Playback Recording';\r\n\t}\r\n\telse\r\n\t{\r\n\t\tTi.API.info(\"recording file size: \"+file.size);\r\n\t\tsound = Titanium.Media.createSound({sound:file});\r\n\t\tsound.addEventListener('complete', function()\r\n\t\t{\r\n\t\t\tb2.title = 'Playback Recording';\r\n\t\t});\r\n\t\tsound.play();\r\n\t\tb2.title = 'Stop Playback';\r\n\t}\r\n});\r\n\r\nvar switchLabel = Titanium.UI.createLabel({\r\n\ttext:'Hi-fidelity:',\r\n\twidth:'auto',\r\n\theight:'auto',\r\n\ttextAlign:'center',\r\n\tcolor:'#999',\r\n\tbottom:115\r\n});\r\nvar switcher = Titanium.UI.createSwitch({\r\n\tvalue:false,\r\n\tbottom:80\r\n});\r\n\r\nswitcher.addEventListener('change',function(e)\r\n{\r\n\tif (!switcher.value)\r\n\t{\r\n\t\trecording.compression = Ti.Media.AUDIO_FORMAT_ULAW;\r\n\t}\r\n\telse\r\n\t{\r\n\t\trecording.compression = Ti.Media.AUDIO_FORMAT_LINEAR_PCM;\r\n\t}\r\n});\r\nwin.add(switchLabel);\r\nwin.add(switcher);\r\nwin.open();\r\n{code}", "attachment": [], "flagged": false, "summary": "iOS: Audio recording functionality only works up-to SDK v2.0.2 GA", "creator": { "name": "nsharma", "key": "nsharma", "displayName": "Nikhil Sharma", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "nsharma", "key": "nsharma", "displayName": "Nikhil Sharma", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "iOS5\r\niPhone4\r\nTi SDK 2.1.1.GA", "comment": { "comments": [ { "id": "214984", "author": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The support link hints to an exception raised by the audio driver within simulator. Is this the case in the TIMOB?\r\n\r\nIf so, this may be an Apple bug in simulator.\r\n\r\nhttps://discussions.apple.com/thread/3819439?start=0&tstart=0\r\nhttp://pastebin.com/jqfPcA8g\r\nhttp://www.openradar.me/10555404\r\n", "updateAuthor": { "name": "blainhamon", "key": "blainhamon", "displayName": "Blain Hamon", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-17T11:44:35.000+0000", "updated": "2012-08-17T11:44:35.000+0000" }, { "id": "215058", "author": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "body": "@Nikhil - Please confirm if the customer encounters this issue with the simulator or the device. This is an Apple bug if it occurs only on simulator.", "updateAuthor": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-17T20:26:34.000+0000", "updated": "2012-08-17T20:26:34.000+0000" }, { "id": "215163", "author": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "body": "It seems like the recording works fine on both simulator and on device . Though the test case is wrong, when trying to playback the recorded file they are trying to create a media sound file by passing `sound` property the recorded file. The sound property doesnot exist in our platform and instead `url` property should be used. try using the following code .\r\n\r\n{code}\r\n//At line 178\r\nsound = Titanium.Media.createSound({url:file});\r\n{code} \r\n\r\nTested on:\r\nXcode 4.4\r\niOS Sim . 4.3 and 5.0\r\ndevice : iPhone 4S running 5.1\r\nTiSDK : 2.2.0(master||commit:f51fd8cafaa84541470d1687c0e1aa9620289c8c) as on 08.20.2012\r\n\r\nMarking ticket as invalid.", "updateAuthor": { "name": "srahim", "key": "srahim", "displayName": "Sabil Rahim", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-08-20T11:17:03.000+0000", "updated": "2012-08-20T11:17:03.000+0000" }, { "id": "410933", "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-09T23:10:49.000+0000", "updated": "2017-03-09T23:10:49.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }