{ "id": "139030", "key": "TIMOB-17951", "fields": { "issuetype": { "id": "4", "description": "An improvement or enhancement to an existing feature or task.", "name": "Improvement", "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": "17706", "name": "Release 5.4.0", "archived": false, "released": true, "releaseDate": "2016-08-11" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-01-06T18:23:48.000+0000", "created": "2014-11-03T21:56:07.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "camera", "media", "qe-3.4.1", "runtime" ], "versions": [ { "id": "15422", "description": "Release 3.3.0", "name": "Release 3.3.0", "archived": false, "released": true, "releaseDate": "2014-07-16" }, { "id": "15972", "description": "Release 3.4.0", "name": "Release 3.4.0", "archived": false, "released": true, "releaseDate": "2014-09-28" } ], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2016-07-13T18:33:45.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" }, { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "When Ti.Media.switchCamera(undefined); is called on a device/simulator with zero or one camera, a runtime error is thrown.\r\nIf Ti.Media.switchCamera(undefined); is called on a device/simulator with two camera's (and one has been opened) then no action is performed and no error occurs.\r\n*This is not a regression*.\r\n\r\n*Steps to reproduce*:\r\n1. Build a project with the attached files, for a device with 1 or no camera\r\n2. Click through the camera test buttons\r\n3. Notice that they correctly open the camera or not, depending on if that camera exists on the device\r\n3. Click on the \"Invalid Camera\" button\r\n4. Notice that a runtime error is thrown\r\n\r\n*Expected Result*:\r\nNo error is thrown and no action is performed (like the camera buttons for unsupported/nonexistent cameras).\r\n\r\n*Notes*:\r\nI was unable to encounter this error on devices with two cameras, despite the same code and 'undefined' parameter passed.", "attachment": [ { "id": "52303", "filename": "Archive.zip", "author": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2014-11-03T21:56:07.000+0000", "size": 1045, "mimeType": "application/zip" } ], "flagged": false, "summary": "Calling Ti.Media.switchCamera(undefined) yields unexpected results on devices with 1 or no camera", "creator": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "ewieber", "key": "ewieber", "displayName": "Eric Wieber", "active": false, "timeZone": "America/Los_Angeles" }, "environment": "Studio 3.4.0.201409261245\r\nTitanium SDK 3.4.0.GA and 3.3.0.GA\r\niPhone 5 Simulator, iOS 8.0\r\niPad 2 Simulator, iOS 8.1\r\nNexus 7, Android 4.3", "closedSprints": [ { "id": 543, "state": "closed", "name": "2015 Sprint 26 SDK", "startDate": "2015-12-19T01:30:23.690Z", "endDate": "2016-01-02T01:30:00.000Z", "completeDate": "2016-01-04T02:30:59.966Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "373469", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "[~ewieber] Both iOS and Android? EDIT: After some research on the existing code, -I don't think we should handle this edge case explicitly-. The method expects a constant of either {{Ti.Media.CAMERA_FRONT}} or {{Ti.Media.CAMERA_REAR}}, the developers should know that before using the method. Anyway, I would adjust the docs, since they list some constants that are not allowed there ([see here|http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Media-method-switchCamera]).", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-12-23T19:51:07.000+0000", "updated": "2015-12-23T20:21:33.000+0000" }, { "id": "373472", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "PR: https://github.com/appcelerator/titanium_mobile/pull/7598\r\n\r\nDemo\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow({layout: \"vertical\"});\r\n\r\nvar btn1 = createButtonWithTitleAndAction(\"Default Camera\", defCam);\r\nvar btn2 = createButtonWithTitleAndAction(\"Front Camera 1\", frontCam1);\r\nvar btn3 = createButtonWithTitleAndAction(\"Front Camera 2\", frontCam2);\r\nvar btn4 = createButtonWithTitleAndAction(\"Back Camera 1\", backCam1);\r\nvar btn5 = createButtonWithTitleAndAction(\"Back Camera 2\", backCam2);\r\nvar btn6 = createButtonWithTitleAndAction(\"Invalid camera\", invCam);\r\n\r\nwindow.add(btn1);\r\nwindow.add(btn2);\r\nwindow.add(btn3);\r\nwindow.add(btn4);\r\nwindow.add(btn5);\r\nwindow.add(btn6);\r\n\r\nwindow.open();\r\n\r\nfunction defCam() {\r\n\t\tTi.Media.showCamera({\r\n\t\tmediaType : Ti.Media.MEDIA_TYPE_PHOTO\r\n\t});\r\n\tTi.Media.vibrate();\r\n};\r\n\r\nfunction frontCam1() {\tTi.Media.showCamera({\r\n\t\tmediaType : Ti.Media.MEDIA_TYPE_PHOTO\r\n\t});\r\n\tTi.Media.switchCamera(Ti.Media.CAMERA_FRONT);\r\n\tTi.Media.vibrate();\r\n};\r\n\r\nfunction frontCam2() {\tTi.Media.showCamera({\r\n\t\tmediaType : Ti.Media.MEDIA_TYPE_PHOTO\r\n\t});\r\n\tTi.Media.switchCamera(Ti.Media.CAMERA_REAR);\r\n\tTi.Media.switchCamera(Ti.Media.CAMERA_FRONT);\r\n\tTi.Media.vibrate();\r\n};\r\n\r\nfunction backCam1() {\tTi.Media.showCamera({\r\n\t\tmediaType : Ti.Media.MEDIA_TYPE_PHOTO\r\n\t});\r\n\tTi.Media.switchCamera(Ti.Media.CAMERA_REAR);\r\n\tTi.Media.vibrate();\r\n};\r\n\r\nfunction backCam2() {\tTi.Media.showCamera({\r\n\t\tmediaType : Ti.Media.MEDIA_TYPE_PHOTO\r\n\t});\r\n\tTi.Media.switchCamera(Ti.Media.CAMERA_FRONT);\r\n\tTi.Media.switchCamera(Ti.Media.CAMERA_REAR);\r\n\tTi.Media.vibrate();\r\n};\r\n\r\nfunction invCam() {\tTi.Media.showCamera({\r\n\t\tmediaType : Ti.Media.MEDIA_TYPE_PHOTO\r\n\t});\r\n\tTi.Media.switchCamera(undefined);\r\n\tTi.Media.vibrate();\r\n};\r\n\r\nfunction createButtonWithTitleAndAction(title, action) {\r\n var btn = Ti.UI.createButton({\r\n top: 30,\r\n title: title\r\n });\r\n\r\n btn.addEventListener(\"click\", action);\r\n\r\n return btn;\r\n}\r\n{code}", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2015-12-23T20:20:47.000+0000", "updated": "2015-12-23T20:25:08.000+0000" }, { "id": "390621", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix.\r\nNo runtime error is thrown when Ti.Media.switchCamera(undefined) is called.\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.7.0.201607111053\r\nTi SDK : 5.4.0.v20160712013704\r\nTi CLI : 5.0.9\r\nAlloy : 1.9.1\r\nMAC El Capitan : 10.11.5\r\nAppc NPM : 4.2.8-1\r\nAppc CLI : 5.4.0-33\r\nNode: 4.4.4\r\nNexus 6 - Android 6.0.1", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-07-13T18:33:38.000+0000", "updated": "2016-07-13T18:33:38.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }