{"action":"created","comment":{"url":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/comments/43474591","id":43474591,"diff_hunk":"@@ -0,0 +1,242 @@\n+/****************************************************************************\n+ Copyright (c) 2008-2010 Ricardo Quesada\n+ Copyright (c) 2011-2012 cocos2d-x.org\n+ Copyright (c) 2013-2014 Chukong Technologies Inc.\n+\n+ http://www.cocos2d-x.org\n+\n+ Permission is hereby granted, free of charge, to any person obtaining a copy\n+ of this software and associated documentation files (the \"Software\"), to deal\n+ in the Software without restriction, including without limitation the rights\n+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ copies of the Software, and to permit persons to whom the Software is\n+ furnished to do so, subject to the following conditions:\n+\n+ The above copyright notice and this permission notice shall be included in\n+ all copies or substantial portions of the Software.\n+\n+ THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ THE SOFTWARE.\n+ ****************************************************************************/\n+\n+/**\n+ * Audio Source.\n+ * @class\n+ * @name cc.AudioScource\n+ * @extend cc.CCComponent\n+ */\n+\n+var audioEngine = cc.audioEngine;\n+\n+var AudioSource = cc.Class({\n+    name: 'cc.Audio',\n+    extends: require('./CCComponent'),\n+\n+    ctor: function () {\n+        this.audio = null;\n+    },\n+\n+    properties: {\n+        _clip: '',\n+        _volume: 1,\n+        _mute: false,\n+        _loop: false,\n+        _buffer: null,\n+        _element: null,\n+        _playing: false,\n+        _paused: false,\n+\n+        /**\n+         * Is the audio source playing (Read Only)\n+         * @property isPlaying\n+         * @type {boolean}\n+         * @readOnly\n+         * @default false\n+         */\n+        isPlaying: {\n+            get: function () {\n+                return this._playing && !this._paused && this.audio.getPlaying();\n+            },\n+            visible: false\n+        },\n+\n+        /**\n+         * Is the audio source paused (Read Only)\n+         * @property isPaused\n+         * @type {boolean}\n+         * @readOnly\n+         * @default false\n+         */\n+        isPaused:{\n+            get: function () {\n+                return this._paused;\n+            },\n+            visible: false\n+        },\n+\n+        /**\n+         * The clip of the audio source.\n+         * @property volume\n+         * @type {number}\n+         * @default 1\n+         */\n+        clip: {\n+            get: function () {\n+                return this._clip;\n+            },\n+            set: function (value) {\n+                if ( this._clip === value ) { return; }\n+                this._clip = value;\n+                this.audio = audioEngine.playEffect(this._clip, this._loop);\n+            },\n+            url: cc.AudioClip\n+        },\n+\n+        /**\n+         * The volume of the audio source.\n+         * @property volume\n+         * @type {number}\n+         * @default 1\n+         */\n+        volume: {\n+            get: function () {\n+                return this._volume;\n+            },\n+            set: function (value) {\n+                if ( this._volume === value || !this.audio ) { return; }\n+                this._volume = value;\n+                this.audio.setVolume(value);\n+            }\n+        },\n+\n+        /**\n+         * Is the audio source mute?\n+         * @property mute\n+         * @type {boolean}\n+         * @default false\n+         */\n+        mute: {\n+            get: function () {\n+                return this._mute;\n+            },\n+            set: function (value) {\n+                if ( this._mute === value || !this.audio ) { return; }\n+                this._mute = value;\n+                if ( this._mute ) {\n+                    this.audio.setVolume(0);\n+                }\n+                else {\n+                    this.audio.setVolume(this._volume);\n+                }\n+            }\n+        },\n+\n+        /**\n+         * Is the audio source looping?\n+         * @property loop\n+         * @type {boolean}\n+         * @default false\n+         */\n+        loop: {\n+            get: function () {\n+                return this._loop;\n+            },\n+            set: function (value) {\n+                if ( this._loop === value || !this.audio ) { return; }\n+                this._loop = value;\n+                this.audio.loop = this._loop;\n+            }\n+        },\n+\n+        /**\n+         * If set to true, the audio source will automatically start playing on onLoad.\n+         * @property playOnLoad\n+         * @type {boolean}\n+         * @default true\n+         */\n+        playOnLoad: true\n+\n+    },\n+\n+    onLoad: function () {\n+        if ( this._clip ) {\n+            this.audio = audioEngine.playEffect(this._clip, this._loop);\n+        }\n+        if ( this._playing ) {\n+            this.stop();\n+        }\n+    },\n+\n+    onEnable: function () {\n+        if ( this.playOnLoad ) {\n+            this.play();\n+        }\n+    },\n+\n+    onDisable: function () {\n+        this.stop();\n+    },\n+\n+    onDestroy: function () {\n+        this.stop();\n+    },\n+\n+    /**\n+     * Plays the clip.\n+     * @method play\n+     */\n+    play: function () {\n+        if ( !this.audio ) { return; }\n+        this.audio.play()\n+        this._playing = true;\n+        this._paused = false;\n+    },\n+\n+    /**\n+     * Stops the clip\n+     * @method stop\n+     */\n+    stop: function () {\n+        if ( !this.audio ) { return; }\n+        this.audio.stop();\n+        this._playing = false;\n+        this._paused = false;\n+    },\n+\n+    /**\n+     * Pause the clip.\n+     * @method pause\n+     */\n+    pause: function () {\n+        if ( !this.audio ) { return; }\n+        this.audio.pause();\n+        this._paused = true;\n+    },\n+\n+    /**\n+     * Resume the clip.\n+     * @method resume\n+     */\n+    resume: function () {\n+        if ( !this.audio ) { return; }\n+        this.audio.resume();\n+    },\n+\n+    /**\n+     * Rewind playing music.\n+     * @method rewin\n+     */\n+    rewin: function(){","path":"cocos2d/core/components/CCAudioSource.js","position":234,"original_position":234,"commit_id":"6bdfccf4a4bbeb782ac93db42bd568520a094300","original_commit_id":"6bdfccf4a4bbeb782ac93db42bd568520a094300","user":{"login":"jareguo","id":1503156,"avatar_url":"https://avatars.githubusercontent.com/u/1503156?v=3","gravatar_id":"","url":"https://api.github.com/users/jareguo","html_url":"https://github.com/jareguo","followers_url":"https://api.github.com/users/jareguo/followers","following_url":"https://api.github.com/users/jareguo/following{/other_user}","gists_url":"https://api.github.com/users/jareguo/gists{/gist_id}","starred_url":"https://api.github.com/users/jareguo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jareguo/subscriptions","organizations_url":"https://api.github.com/users/jareguo/orgs","repos_url":"https://api.github.com/users/jareguo/repos","events_url":"https://api.github.com/users/jareguo/events{/privacy}","received_events_url":"https://api.github.com/users/jareguo/received_events","type":"User","site_admin":false},"body":"rewin**d**","created_at":"2015-10-30T06:17:56Z","updated_at":"2015-10-30T06:17:56Z","html_url":"https://github.com/fireball-x/cocos2d-html5/pull/50#discussion_r43474591","pull_request_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/50","_links":{"self":{"href":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/comments/43474591"},"html":{"href":"https://github.com/fireball-x/cocos2d-html5/pull/50#discussion_r43474591"},"pull_request":{"href":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/50"}}},"pull_request":{"url":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/50","id":49149239,"html_url":"https://github.com/fireball-x/cocos2d-html5/pull/50","diff_url":"https://github.com/fireball-x/cocos2d-html5/pull/50.diff","patch_url":"https://github.com/fireball-x/cocos2d-html5/pull/50.patch","issue_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/issues/50","number":50,"state":"open","locked":false,"title":"fireball-x/fireball#398 学习并理解现有的 Component 架构, EC化Audio","user":{"login":"knoxHuang","id":7564028,"avatar_url":"https://avatars.githubusercontent.com/u/7564028?v=3","gravatar_id":"","url":"https://api.github.com/users/knoxHuang","html_url":"https://github.com/knoxHuang","followers_url":"https://api.github.com/users/knoxHuang/followers","following_url":"https://api.github.com/users/knoxHuang/following{/other_user}","gists_url":"https://api.github.com/users/knoxHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/knoxHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knoxHuang/subscriptions","organizations_url":"https://api.github.com/users/knoxHuang/orgs","repos_url":"https://api.github.com/users/knoxHuang/repos","events_url":"https://api.github.com/users/knoxHuang/events{/privacy}","received_events_url":"https://api.github.com/users/knoxHuang/received_events","type":"User","site_admin":false},"body":"我真是磨人的小妖精！","created_at":"2015-10-29T14:48:40Z","updated_at":"2015-10-30T06:17:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3e4435a61e1dfe9f1d11d87bc91e0fd01caffe9a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/50/commits","review_comments_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/50/comments","review_comment_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/issues/50/comments","statuses_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/statuses/6bdfccf4a4bbeb782ac93db42bd568520a094300","head":{"label":"knoxHuang:ec","ref":"ec","sha":"6bdfccf4a4bbeb782ac93db42bd568520a094300","user":{"login":"knoxHuang","id":7564028,"avatar_url":"https://avatars.githubusercontent.com/u/7564028?v=3","gravatar_id":"","url":"https://api.github.com/users/knoxHuang","html_url":"https://github.com/knoxHuang","followers_url":"https://api.github.com/users/knoxHuang/followers","following_url":"https://api.github.com/users/knoxHuang/following{/other_user}","gists_url":"https://api.github.com/users/knoxHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/knoxHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knoxHuang/subscriptions","organizations_url":"https://api.github.com/users/knoxHuang/orgs","repos_url":"https://api.github.com/users/knoxHuang/repos","events_url":"https://api.github.com/users/knoxHuang/events{/privacy}","received_events_url":"https://api.github.com/users/knoxHuang/received_events","type":"User","site_admin":false},"repo":{"id":35714147,"name":"cocos2d-html5","full_name":"knoxHuang/cocos2d-html5","owner":{"login":"knoxHuang","id":7564028,"avatar_url":"https://avatars.githubusercontent.com/u/7564028?v=3","gravatar_id":"","url":"https://api.github.com/users/knoxHuang","html_url":"https://github.com/knoxHuang","followers_url":"https://api.github.com/users/knoxHuang/followers","following_url":"https://api.github.com/users/knoxHuang/following{/other_user}","gists_url":"https://api.github.com/users/knoxHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/knoxHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knoxHuang/subscriptions","organizations_url":"https://api.github.com/users/knoxHuang/orgs","repos_url":"https://api.github.com/users/knoxHuang/repos","events_url":"https://api.github.com/users/knoxHuang/events{/privacy}","received_events_url":"https://api.github.com/users/knoxHuang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/knoxHuang/cocos2d-html5","description":"cocos2d for Web Browsers. Built using JavaScript","fork":true,"url":"https://api.github.com/repos/knoxHuang/cocos2d-html5","forks_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/forks","keys_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/keys{/key_id}","collaborators_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/teams","hooks_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/hooks","issue_events_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/issues/events{/number}","events_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/events","assignees_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/assignees{/user}","branches_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/branches{/branch}","tags_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/tags","blobs_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/git/refs{/sha}","trees_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/git/trees{/sha}","statuses_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/statuses/{sha}","languages_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/languages","stargazers_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/stargazers","contributors_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/contributors","subscribers_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/subscribers","subscription_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/subscription","commits_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/commits{/sha}","git_commits_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/git/commits{/sha}","comments_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/comments{/number}","issue_comment_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/issues/comments{/number}","contents_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/contents/{+path}","compare_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/compare/{base}...{head}","merges_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/merges","archive_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/downloads","issues_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/issues{/number}","pulls_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/pulls{/number}","milestones_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/milestones{/number}","notifications_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/labels{/name}","releases_url":"https://api.github.com/repos/knoxHuang/cocos2d-html5/releases{/id}","created_at":"2015-05-16T07:23:54Z","updated_at":"2015-05-16T07:23:56Z","pushed_at":"2015-10-30T06:15:09Z","git_url":"git://github.com/knoxHuang/cocos2d-html5.git","ssh_url":"git@github.com:knoxHuang/cocos2d-html5.git","clone_url":"https://github.com/knoxHuang/cocos2d-html5.git","svn_url":"https://github.com/knoxHuang/cocos2d-html5","homepage":"http://www.cocos2d-html5.org","size":67611,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"fireball-x:ec","ref":"ec","sha":"8742fc0dc6c1e55f5e2ad0e9ec43e2b329faab61","user":{"login":"fireball-x","id":6937061,"avatar_url":"https://avatars.githubusercontent.com/u/6937061?v=3","gravatar_id":"","url":"https://api.github.com/users/fireball-x","html_url":"https://github.com/fireball-x","followers_url":"https://api.github.com/users/fireball-x/followers","following_url":"https://api.github.com/users/fireball-x/following{/other_user}","gists_url":"https://api.github.com/users/fireball-x/gists{/gist_id}","starred_url":"https://api.github.com/users/fireball-x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fireball-x/subscriptions","organizations_url":"https://api.github.com/users/fireball-x/orgs","repos_url":"https://api.github.com/users/fireball-x/repos","events_url":"https://api.github.com/users/fireball-x/events{/privacy}","received_events_url":"https://api.github.com/users/fireball-x/received_events","type":"Organization","site_admin":false},"repo":{"id":43405650,"name":"cocos2d-html5","full_name":"fireball-x/cocos2d-html5","owner":{"login":"fireball-x","id":6937061,"avatar_url":"https://avatars.githubusercontent.com/u/6937061?v=3","gravatar_id":"","url":"https://api.github.com/users/fireball-x","html_url":"https://github.com/fireball-x","followers_url":"https://api.github.com/users/fireball-x/followers","following_url":"https://api.github.com/users/fireball-x/following{/other_user}","gists_url":"https://api.github.com/users/fireball-x/gists{/gist_id}","starred_url":"https://api.github.com/users/fireball-x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fireball-x/subscriptions","organizations_url":"https://api.github.com/users/fireball-x/orgs","repos_url":"https://api.github.com/users/fireball-x/repos","events_url":"https://api.github.com/users/fireball-x/events{/privacy}","received_events_url":"https://api.github.com/users/fireball-x/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fireball-x/cocos2d-html5","description":"cocos2d for Web Browsers. Built using JavaScript","fork":true,"url":"https://api.github.com/repos/fireball-x/cocos2d-html5","forks_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/forks","keys_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/teams","hooks_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/hooks","issue_events_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/issues/events{/number}","events_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/events","assignees_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/assignees{/user}","branches_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/branches{/branch}","tags_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/tags","blobs_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/git/refs{/sha}","trees_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/statuses/{sha}","languages_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/languages","stargazers_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/stargazers","contributors_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/contributors","subscribers_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/subscribers","subscription_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/subscription","commits_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/commits{/sha}","git_commits_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/git/commits{/sha}","comments_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/comments{/number}","issue_comment_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/issues/comments{/number}","contents_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/contents/{+path}","compare_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/merges","archive_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/downloads","issues_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/issues{/number}","pulls_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls{/number}","milestones_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/milestones{/number}","notifications_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/labels{/name}","releases_url":"https://api.github.com/repos/fireball-x/cocos2d-html5/releases{/id}","created_at":"2015-09-30T01:55:36Z","updated_at":"2015-09-30T01:55:42Z","pushed_at":"2015-10-30T06:15:09Z","git_url":"git://github.com/fireball-x/cocos2d-html5.git","ssh_url":"git@github.com:fireball-x/cocos2d-html5.git","clone_url":"https://github.com/fireball-x/cocos2d-html5.git","svn_url":"https://github.com/fireball-x/cocos2d-html5","homepage":"http://www.cocos2d-html5.org","size":68098,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":5,"mirror_url":null,"open_issues_count":2,"forks":5,"open_issues":2,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/50"},"html":{"href":"https://github.com/fireball-x/cocos2d-html5/pull/50"},"issue":{"href":"https://api.github.com/repos/fireball-x/cocos2d-html5/issues/50"},"comments":{"href":"https://api.github.com/repos/fireball-x/cocos2d-html5/issues/50/comments"},"review_comments":{"href":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/50/comments"},"review_comment":{"href":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fireball-x/cocos2d-html5/pulls/50/commits"},"statuses":{"href":"https://api.github.com/repos/fireball-x/cocos2d-html5/statuses/6bdfccf4a4bbeb782ac93db42bd568520a094300"}}}}