{ "id": "139261", "key": "AC-1196", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2014-11-18T09:19:54.000+0000", "created": "2014-11-07T16:31:13.000+0000", "labels": [ "audio", "audioPlayerAPIs", "audioplayer" ], "versions": [], "issuelinks": [], "assignee": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "updated": "2017-05-08T14:39:07.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "When I add an event listener to an AudioPlayer's 'change' event, I try to test e.state against the various constants, like Ti.Media.AudioPlayer.STATE_BUFFERING. When I do, I get an error because Ti.Media.AudioPlayer is undefined.\r\n\r\nI can work around the problem by referencing the constants from my AudioPlayer instance variable.\r\n\r\nvar _player = Ti.Media.createAudioPlayer ();\r\n_player.addEventListener ('change', function (e) {\r\n switch (e.state)\r\n {\r\n case Ti.Media.AudioPlayer.STATE_BUFFERING: // crash and burn\r\n break;\r\n\r\n case _player.STATE_BUFFERING: // this is OK\r\n break;\r\n }\r\n});", "attachment": [], "flagged": false, "summary": "Ti.Media.AudioPlayer undefined", "creator": { "name": "jpriebe", "key": "jpriebe", "displayName": "Jason Priebe", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "jpriebe", "key": "jpriebe", "displayName": "Jason Priebe", "active": true, "timeZone": "America/New_York" }, "environment": "OS X 10.8\r\niOS 8 simulator, iphone 6", "comment": { "comments": [ { "id": "332674", "author": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "body": "Hi,\r\n\r\nBased on your code, you have to write code like \"_player.STATE_BUFFERING\". As Ti.Media.AudioPlayer is just class name, not the exact Object. And the State_buffering is a property for that Object. Like can add event listener to _player not Ti.Media.AudioPlayer.", "updateAuthor": { "name": "sliang", "key": "sliang", "displayName": "Shuo Liang", "active": true, "timeZone": "Asia/Harbin" }, "created": "2014-11-18T09:19:12.000+0000", "updated": "2014-11-18T09:19:28.000+0000" }, { "id": "332704", "author": { "name": "jpriebe", "key": "jpriebe", "displayName": "Jason Priebe", "active": true, "timeZone": "America/New_York" }, "body": "I completely disagree with this being marked \"invalid\".\r\n\r\nHow is Ti.Media.AudioPlayer.STATE_BUFFERING any different from Ti.UI.SIZE? Or Ti.UI.PORTRAIT, Ti.UI.LANDSCAPE_LEFT, etc.?\r\n\r\nInconsistencies like this in the semantics of the library are one of the biggest obstacles to new user adoption of the Titanium platform. Many users would have given up when Ti.Media.AudioPlayer.STATE_BUFFERING threw errors. How many would bother to try checking for an *instance constant*??? I've been developing software for over 20 years, and I've never found an API that uses *instance constants*. Class constants, yes. Not instance constants.\r\n\r\nAt least fix the documentation so that users understand that these are not class constants.", "updateAuthor": { "name": "jpriebe", "key": "jpriebe", "displayName": "Jason Priebe", "active": true, "timeZone": "America/New_York" }, "created": "2014-11-18T13:13:03.000+0000", "updated": "2014-11-18T13:13:03.000+0000" }, { "id": "344982", "author": { "name": "kiafaldorius", "key": "kiafaldorius", "displayName": "Kia Kroas", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I agree.\r\n\r\nDocumentation for the 'change' event on AudioPlayer references these constants as though they were on the AudioPlayer object rather than its prototype--which is what makes it accessible only through an instance. There's no reason to put the constants in an instance: they don't change across instantiations and shouldn't ever be changed anyway.", "updateAuthor": { "name": "kiafaldorius", "key": "kiafaldorius", "displayName": "Kia Kroas", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-03-03T21:38:15.000+0000", "updated": "2015-03-03T21:38:15.000+0000" }, { "id": "419295", "author": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "gmathews", "key": "gmathews", "displayName": "Gary Mathews", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-05-08T14:39:07.000+0000", "updated": "2017-05-08T14:39:07.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }