{ "id": "80125", "key": "TIMOB-5239", "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": "14164", "description": "Release 3.0.2", "name": "Release 3.0.2", "archived": true, "released": true, "releaseDate": "2013-02-19" }, { "id": "14162", "description": "Release 3.1.0", "name": "Release 3.1.0", "archived": true, "released": true, "releaseDate": "2013-04-16" }, { "id": "14700", "description": "2012 Sprint 25", "name": "2012 Sprint 25", "archived": true, "released": true, "releaseDate": "2012-12-17" }, { "id": "14784", "description": "2012 Sprint 25 API", "name": "2012 Sprint 25 API", "archived": true, "released": true, "releaseDate": "2012-12-17" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-12-12T22:50:59.000+0000", "created": "2011-09-09T10:54:20.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "api", "insight", "module_filesystem", "notificationManager", "qe-testadded", "sound", "triage" ], "versions": [ { "id": "11570", "description": "", "name": "Release 1.7.2", "archived": true, "released": true, "releaseDate": "2011-07-21" }, { "id": "11331", "description": "", "name": "Release 1.8.0", "archived": true, "released": true, "releaseDate": "2011-10-31" } ], "issuelinks": [ { "id": "22281", "type": { "id": "10001", "name": "Cloners", "inward": "is cloned into", "outward": "is cloned from" }, "inwardIssue": { "id": "103942", "key": "TIDOC-857", "fields": { "summary": "APIDoc: if you add a sound to a notification the sound is not found", "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" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "23507", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "106039", "key": "TIMOB-11975", "fields": { "summary": "Android: API to expose res/raw directory", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false } } } }, { "id": "32012", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "112583", "key": "TIMOB-13495", "fields": { "summary": "Android: HTML5 audio tag does not play in WebView", "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" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2013-09-19T00:43:21.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": "h5.Problem\r\nIf you add a sound to a notification the sound is not found.\r\n\r\nhttp://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Android.NotificationManager-module\r\n\r\nh5.Repro sequence\r\n{code:title=app.js}\r\nvar win= Titanium.UI.createWindow();\r\n\r\nvar btn = Ti.UI.createButton({\r\n title: 'Add Notification'\r\n});\r\n\r\nbtn.addEventListener('click', function(e) {\r\n\r\n var activity = Ti.Android.currentActivity();\r\n var intent = Ti.Android.createIntent({\r\n });\r\n\r\n var pending = Ti.Android.createPendingIntent({ \r\n 'activity' : activity,\r\n 'intent' : intent,\r\n 'type' : Ti.Android.PENDING_INTENT_FOR_ACTIVITY,\r\n 'flags' : 1073741824\r\n });\r\n\r\n var ts = new Date().getTime();\r\n\r\n var notification = Ti.Android.createNotification({\r\n contentIntent : pending,\r\n contentTitle : 'Test',\r\n contentText : 'test',\r\n when : ts,\r\n //icon: 'KS_nav_ui.png',TIMOB-4651\r\n sound: '1.mp3',\r\n defaults: Titanium.Android.NotificationManager.DEFAULT_VIBRATE\r\n });\r\n\r\n Ti.Android.NotificationManager.notify(1, notification); \r\n});\r\nwin.add(btn);\r\n\r\n// testing if the image exist\r\nvar lbl = Titanium.UI.createLabel({\r\n text : ' ',\r\n backgroundImage: 'KS_nav_ui.png',\r\n top : 10,\r\n left: 10\r\n});\r\n\r\nwin.add(lbl);\r\n\r\nwin.open();\r\n{code}\r\n\r\nh5.Console Output - With customized Sound\r\nSound file is located at resources folder, so property is being set as:\r\nsound: '1.mp3'\r\n{noformat}\r\n I/StagefrightPlayer( 34): setDataSource('/android_asset/Resources/1.mp3')\r\nE/MediaPlayer( 60): error (1, -2147483648)\r\nW/NotificationService( 60): error loading sound for file:///android_asset/Resources/1.mp3\r\nW/NotificationService( 60): java.io.IOException: Prepare failed.: status=0x1\r\nW/NotificationService( 60): \tat android.media.MediaPlayer.prepare(Native Method)\r\nW/NotificationService( 60): \tat com.android.server.NotificationPlayer$CreationAndCompletionThread.run(NotificationPlayer.java:90)\r\n{noformat}\r\n\r\nh5.Tested on\r\nDevice: HTC Dream Android 2.2 OS version & Emulator: Android HGVA\r\n\r\nh5.Associated HD ticket\r\nPRO - http://appc.me/c/APP-923324\r\n\r\nh5.Additional info\r\nGet default vibrate by setting permissions in Tiapp.xml\r\n{noformat}\r\n \r\n \t \t\r\n \t\t\r\n \t\t\r\n \r\n{noformat}\r\n\r\nh5.Work Around\r\nTo allow the app at this time to play the default sound and vibration as well: \r\ndefaults: Titanium.Android.NotificationManager.DEFAULT_ALL\r\n\r\nTo play default sound:\r\ndefaults: Titanium.Android.NotificationManager.DEFAULT_SOUND\r\n\r\nTo get phone vibration:\r\ndefaults: Titanium.Android.NotificationManager.DEFAULT_VIBRATE\r\n", "attachment": [ { "id": "22884", "filename": "1.mp3", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-09-09T10:54:20.000+0000", "size": 8613, "mimeType": "audio/mpeg" }, { "id": "33999", "filename": "cricket.wav", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-12-06T23:44:42.000+0000", "size": 80923, "mimeType": "audio/wav" } ], "flagged": false, "summary": "Android: if you add a sound to a notification the sound is not found", "creator": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK: Mobile 1.7.2, 1.8 CI Build\r\nPlatform OS: Android Version: 2.3.4 ", "comment": { "comments": [ { "id": "224917", "author": { "name": "jpriebe", "key": "jpriebe", "displayName": "Jason Priebe", "active": true, "timeZone": "America/New_York" }, "body": "I do not believe this is trivial. This is one of many holes in the Ti API and documentation. Every one of these is a huge time-waster for developers. If the API worked as documented, or the documentation reflected the status of the API, I wouldn't have wasted time trying to get it to work.\r\n", "updateAuthor": { "name": "jpriebe", "key": "jpriebe", "displayName": "Jason Priebe", "active": true, "timeZone": "America/New_York" }, "created": "2012-10-25T14:04:27.000+0000", "updated": "2012-10-25T14:04:27.000+0000" }, { "id": "224977", "author": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I'm with Jason. This is not trivial. I think the handling of sound is incorrect and should be fixed.\n\nI was unable to get it to play a sound from the resources folder directly, and I wasn't able to play a sound from the raw Android assets either (either by placing them in Resources/android/assets or platform/android/res/raw). I tried referring to them using Ti.App.Android.R.raw.filename, and it turns out we don't support R.raw. I'll file a separate bug for that.\n\nWhat I was able to do after a little experimentation was play a sound from the SD card. Files in resources are all compressed by the Android build process into a single archive, so I'm guessing that extracting the file in this way makes it playable. But since we can play a sound directly from Resources using Ti.Media.Sound, I'm betting we could handle this case correctly for Notification.\n\nAnyway, here's my workaround:\n\n{code}\nfunction getAudioFile() {\n var outFile = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'sound', 'cricket.wav');\n var outPath = outFile.nativePath;\n if (! outFile.exists()) {\n var inFile = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'cricket.wav');\n inFile.copy(outPath);\n inFile = null;\n }\n outFile = null;\n return outPath;\n}\n{code}\n\nThen, when you create the notification, use:\n\n{code}\n sound: getAudioFile(),\n{code}\n\nI will open a doc bug to document this workaround, but the workaround shouldn't be required in the first place.\n\n\n\n", "updateAuthor": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-25T20:14:20.000+0000", "updated": "2012-10-25T20:14:20.000+0000" }, { "id": "224978", "author": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Possibly related to TIMOB-11036? Or it could be entirely specific to Notification.", "updateAuthor": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-25T20:18:48.000+0000", "updated": "2012-10-25T20:18:48.000+0000" }, { "id": "225223", "author": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Adding workaround to docs in:\nhttps://github.com/appcelerator/titanium_mobile/pull/3343\n\nWhen we fix this bug, we need to include an update to the docs to describe how the sound can be specified.", "updateAuthor": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-10-26T23:10:51.000+0000", "updated": "2012-10-26T23:10:51.000+0000" }, { "id": "229054", "author": { "name": "iamyellow", "key": "iamyellow", "displayName": "jordi domenech", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hi,\r\nI was able to make it work with no workaround, but with some 'rules'. It was quite easy, take a look at this commit on my 2_1_X fork branch:\r\nhttps://github.com/iamyellow/titanium_mobile/commit/dbd4ce7aa70e947c11c757bcaf8076b20c79b199#android\r\n\r\nThe 'rule' now is you must provide the sound in:\r\nTI_PROJECT_ROOT/platform/android/res/raw/yay.mp3\r\n\r\nThen, in Javascript just:\r\nvar notification = Ti.Android.createNotification({\r\n ...\r\n sound: 'yay'\r\n});\r\n(notice there's no extension!)\r\n\r\nHope it helps.\r\n\r\nps: I don't know why, but there's no sound in emulator, BUT there IS in a real device, which is the point, isn't it?", "updateAuthor": { "name": "iamyellow", "key": "iamyellow", "displayName": "jordi domenech", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-11-29T17:21:55.000+0000", "updated": "2012-11-29T17:23:58.000+0000" }, { "id": "229368", "author": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Hi Jordi,\n\nYes, the emulator doesn't support sound, so that's expected.\n\nGlad you found a way to make it work. I know we have existing apps that use audio from the SD card, so we can't fix it this way in the platform--it should accept both Android-style resource IDs _and_ Titanium resource URLs.\n", "updateAuthor": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-11-30T20:36:40.000+0000", "updated": "2012-11-30T20:36:40.000+0000" }, { "id": "230313", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-12-06T22:15:13.000+0000", "updated": "2012-12-06T22:15:13.000+0000" }, { "id": "230335", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Testing Preparations: Download cricket.wav and put it in /platform/android/res/raw (you can also get this file in KitchenSink)\r\n\r\nTest 1:\r\n{code}\r\nvar win= Titanium.UI.createWindow();\r\n \r\nvar btn = Ti.UI.createButton({\r\n title: 'Add Notification'\r\n});\r\n \r\nbtn.addEventListener('click', function(e) {\r\n \r\n var activity = Ti.Android.currentActivity;\r\n var intent = Ti.Android.createIntent({\r\n });\r\n \r\n var pending = Ti.Android.createPendingIntent({ \r\n 'activity' : activity,\r\n 'intent' : intent,\r\n 'type' : Ti.Android.PENDING_INTENT_FOR_ACTIVITY,\r\n 'flags' : 1073741824\r\n });\r\n \r\n var ts = new Date().getTime();\r\n \r\n var notification = Ti.Android.createNotification({\r\n contentIntent : pending,\r\n contentTitle : 'Test',\r\n contentText : 'test',\r\n sound: Ti.Filesystem.getResRawDirectory() + 'cricket.wav'\r\n });\r\n \r\n Ti.Android.NotificationManager.notify(1, notification); \r\n});\r\nwin.add(btn);\r\n \r\n// testing if the image exist\r\nvar lbl = Titanium.UI.createLabel({\r\n text : ' ',\r\n backgroundImage: 'KS_nav_ui.png',\r\n top : 10,\r\n left: 10\r\n});\r\n \r\nwin.add(lbl);\r\n \r\nwin.open();\r\n{code}\r\n- Click on button, you should hear sound\r\n\r\nTest 2:\r\n{code}\r\nvar win = Titanium.UI.createWindow({});\r\n\t\r\n\tvar sound = Titanium.Media.createSound();\r\n\tsound.url= Ti.Filesystem.getResRawDirectory() + 'cricket.wav';\r\n\t\r\n\t//\r\n\t// PLAY\r\n\t//\r\n\tvar play = Titanium.UI.createButton({\r\n\t\ttitle:'Play',\r\n\t\theight:40,\r\n\t\twidth:145,\r\n\t\tleft:10,\r\n\t\ttop:10\r\n\t});\r\n\tplay.addEventListener('click', function()\r\n\t{\r\n\t\tsound.play();\r\n\t});\r\n\twin.add(play);\r\n win.open();\r\n\t\r\n{code}\r\n1. Click on play, sound should play", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-12-06T23:43:15.000+0000", "updated": "2012-12-12T22:59:04.000+0000" }, { "id": "231141", "author": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/3546", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-12-12T22:49:08.000+0000", "updated": "2012-12-12T22:49:08.000+0000" }, { "id": "235697", "author": { "name": "pmishra", "key": "pmishra", "displayName": "Paras Mishra", "active": true, "timeZone": "Asia/Kolkata" }, "body": "Added sound, cricket.wav is being played when it's clicked.\r\n\r\nVerified on:\r\nAndroid version : 2.3.6, 4.0.4\r\n\r\nSDK version: 3.1.0.v20130123144204,3.0.2.v20130122172624\r\nCLI version : 3.0.23\r\nOS : MAC OSX 10.7.5\r\nXCode : 4.5.1\r\n", "updateAuthor": { "name": "pmishra", "key": "pmishra", "displayName": "Paras Mishra", "active": true, "timeZone": "Asia/Kolkata" }, "created": "2013-01-24T09:23:42.000+0000", "updated": "2013-01-24T09:23:42.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }