{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/j2me.js/pulls/comments/24638095","id":24638095,"diff_hunk":"@@ -385,6 +388,121 @@ ImagePlayer.prototype.setVisible = function(visible) {\n     this.image.style.visibility = visible ? \"visible\" : \"hidden\";\n }\n \n+function VideoPlayer(playerContainer) {\n+    this.playerContainer = playerContainer;\n+\n+    this.video = document.createElement(\"video\");\n+    this.video.style.position = \"absolute\";\n+    this.video.style.visibility = \"hidden\";\n+\n+    this.isVideoControlSupported = true;\n+    this.isVolumeControlSupported = true;\n+\n+    // VideoPlayer::start could be called while the video element\n+    // is hidden, causing the call to HTMLVideoElement::play to be\n+    // ignored.\n+    // Thus, we need to call HTMLVideoElement::play when the element\n+    // gets visible.\n+    this.isPlaying = false;\n+}\n+\n+VideoPlayer.prototype.realize = function() {\n+    var ctx = $.ctx;\n+\n+    var p = new Promise((function(resolve, reject) {\n+        this.video.addEventListener(\"canplay\", (function onCanPlay() {\n+            this.video.removeEventListener(\"canplay\", onCanPlay);\n+            resolve(1);\n+        }).bind(this));\n+\n+        this.video.onerror = function() {\n+            ctx.setAsCurrentContext();\n+            reject($.newMediaException(\"Failed to load video\"));\n+        };\n+\n+        if (this.playerContainer.url.startsWith(\"file\")) {\n+            fs.open(this.playerContainer.url.substring(7), (function(fd) {\n+                var videoData = fs.read(fd);\n+                fs.close(fd);\n+                this.video.src = URL.createObjectURL(new Blob([ videoData ]),\n+                                                     { type: this.playerContainer.contentType });\n+            }).bind(this));\n+        } else {\n+            this.video.src = this.playerContainer.url;\n+        }\n+    }).bind(this));\n+\n+    p.done(function() {\n+        if (!this.video.src) {\n+            return;\n+        }\n+        URL.revokeObjectURL(this.video.src);\n+    }.bind(this));\n+\n+    return p;\n+}\n+\n+VideoPlayer.prototype.start = function() {\n+    if (this.video.style.visibility === \"hidden\") {\n+        this.isPlaying = true;\n+    } else {\n+        this.video.play();\n+    }\n+}\n+\n+VideoPlayer.prototype.pause = function() {\n+    this.video.pause();\n+    this.isPlaying = false;\n+}\n+\n+VideoPlayer.prototype.close = function() {\n+    if (this.video.parentNode) {\n+        this.video.parentNode.removeChild(this.video);\n+    }\n+    this.pause();\n+}\n+\n+VideoPlayer.prototype.getMediaTime = function() {\n+    return Math.round(this.video.currentTime * 1000);\n+}\n+\n+VideoPlayer.prototype.getWidth = function() {\n+    return this.video.videoWidth;\n+}\n+\n+VideoPlayer.prototype.getHeight = function() {\n+    return this.video.videoHeight;\n+}\n+\n+VideoPlayer.prototype.setLocation = function(x, y, w, h) {\n+    this.video.style.left = x + \"px\";\n+    this.video.style.top = y + \"px\";\n+    this.video.style.width = w + \"px\";\n+    this.video.style.height = h + \"px\";\n+    document.getElementById(\"main\").appendChild(this.video);\n+}\n+\n+VideoPlayer.prototype.setVisible = function(visible) {\n+    this.video.style.visibility = visible ? \"visible\" : \"hidden\";\n+    if (this.isPlaying) {","path":"midp/media.js","position":null,"original_position":124,"commit_id":"3bbdd3b01402f858a345cd1c082d95742f7cf61d","original_commit_id":"e35f64e0c3a286a9d2abfb5175786c0a8499f1b3","user":{"login":"marco-c","id":1616846,"avatar_url":"https://avatars.githubusercontent.com/u/1616846?v=3","gravatar_id":"","url":"https://api.github.com/users/marco-c","html_url":"https://github.com/marco-c","followers_url":"https://api.github.com/users/marco-c/followers","following_url":"https://api.github.com/users/marco-c/following{/other_user}","gists_url":"https://api.github.com/users/marco-c/gists{/gist_id}","starred_url":"https://api.github.com/users/marco-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marco-c/subscriptions","organizations_url":"https://api.github.com/users/marco-c/orgs","repos_url":"https://api.github.com/users/marco-c/repos","events_url":"https://api.github.com/users/marco-c/events{/privacy}","received_events_url":"https://api.github.com/users/marco-c/received_events","type":"User","site_admin":false},"body":"Done in 3bbdd3b (play is ignored if the element is hidden, so even without this change we wouldn't have started the video, but it's clearer this way).\r\nThere might be other things that we need to do when a MIDlet modifies the player's visibility several times, but it's hard to tell until we find a MIDlet that uses the video player in a more complicated way.","created_at":"2015-02-13T01:29:35Z","updated_at":"2015-02-13T01:29:35Z","html_url":"https://github.com/mozilla/j2me.js/pull/1088#discussion_r24638095","pull_request_url":"https://api.github.com/repos/mozilla/j2me.js/pulls/1088","_links":{"self":{"href":"https://api.github.com/repos/mozilla/j2me.js/pulls/comments/24638095"},"html":{"href":"https://github.com/mozilla/j2me.js/pull/1088#discussion_r24638095"},"pull_request":{"href":"https://api.github.com/repos/mozilla/j2me.js/pulls/1088"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/j2me.js/pulls/1088","id":29193322,"html_url":"https://github.com/mozilla/j2me.js/pull/1088","diff_url":"https://github.com/mozilla/j2me.js/pull/1088.diff","patch_url":"https://github.com/mozilla/j2me.js/pull/1088.patch","issue_url":"https://api.github.com/repos/mozilla/j2me.js/issues/1088","number":1088,"state":"open","locked":false,"title":"Support playing videos","user":{"login":"marco-c","id":1616846,"avatar_url":"https://avatars.githubusercontent.com/u/1616846?v=3","gravatar_id":"","url":"https://api.github.com/users/marco-c","html_url":"https://github.com/marco-c","followers_url":"https://api.github.com/users/marco-c/followers","following_url":"https://api.github.com/users/marco-c/following{/other_user}","gists_url":"https://api.github.com/users/marco-c/gists{/gist_id}","starred_url":"https://api.github.com/users/marco-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marco-c/subscriptions","organizations_url":"https://api.github.com/users/marco-c/orgs","repos_url":"https://api.github.com/users/marco-c/repos","events_url":"https://api.github.com/users/marco-c/events{/privacy}","received_events_url":"https://api.github.com/users/marco-c/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-12T16:29:46Z","updated_at":"2015-02-13T01:29:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9b62ce4493fa201d2cc8ba1650cc8585edd24d73","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/j2me.js/pulls/1088/commits","review_comments_url":"https://api.github.com/repos/mozilla/j2me.js/pulls/1088/comments","review_comment_url":"https://api.github.com/repos/mozilla/j2me.js/pulls/comments/{number}","comments_url":"https://api.github.com/repos/mozilla/j2me.js/issues/1088/comments","statuses_url":"https://api.github.com/repos/mozilla/j2me.js/statuses/3bbdd3b01402f858a345cd1c082d95742f7cf61d","head":{"label":"marco-c:support_video_playing","ref":"support_video_playing","sha":"3bbdd3b01402f858a345cd1c082d95742f7cf61d","user":{"login":"marco-c","id":1616846,"avatar_url":"https://avatars.githubusercontent.com/u/1616846?v=3","gravatar_id":"","url":"https://api.github.com/users/marco-c","html_url":"https://github.com/marco-c","followers_url":"https://api.github.com/users/marco-c/followers","following_url":"https://api.github.com/users/marco-c/following{/other_user}","gists_url":"https://api.github.com/users/marco-c/gists{/gist_id}","starred_url":"https://api.github.com/users/marco-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marco-c/subscriptions","organizations_url":"https://api.github.com/users/marco-c/orgs","repos_url":"https://api.github.com/users/marco-c/repos","events_url":"https://api.github.com/users/marco-c/events{/privacy}","received_events_url":"https://api.github.com/users/marco-c/received_events","type":"User","site_admin":false},"repo":{"id":22527203,"name":"j2me.js","full_name":"marco-c/j2me.js","owner":{"login":"marco-c","id":1616846,"avatar_url":"https://avatars.githubusercontent.com/u/1616846?v=3","gravatar_id":"","url":"https://api.github.com/users/marco-c","html_url":"https://github.com/marco-c","followers_url":"https://api.github.com/users/marco-c/followers","following_url":"https://api.github.com/users/marco-c/following{/other_user}","gists_url":"https://api.github.com/users/marco-c/gists{/gist_id}","starred_url":"https://api.github.com/users/marco-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marco-c/subscriptions","organizations_url":"https://api.github.com/users/marco-c/orgs","repos_url":"https://api.github.com/users/marco-c/repos","events_url":"https://api.github.com/users/marco-c/events{/privacy}","received_events_url":"https://api.github.com/users/marco-c/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marco-c/j2me.js","description":"J2ME VM in JavaScript","fork":true,"url":"https://api.github.com/repos/marco-c/j2me.js","forks_url":"https://api.github.com/repos/marco-c/j2me.js/forks","keys_url":"https://api.github.com/repos/marco-c/j2me.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marco-c/j2me.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marco-c/j2me.js/teams","hooks_url":"https://api.github.com/repos/marco-c/j2me.js/hooks","issue_events_url":"https://api.github.com/repos/marco-c/j2me.js/issues/events{/number}","events_url":"https://api.github.com/repos/marco-c/j2me.js/events","assignees_url":"https://api.github.com/repos/marco-c/j2me.js/assignees{/user}","branches_url":"https://api.github.com/repos/marco-c/j2me.js/branches{/branch}","tags_url":"https://api.github.com/repos/marco-c/j2me.js/tags","blobs_url":"https://api.github.com/repos/marco-c/j2me.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marco-c/j2me.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marco-c/j2me.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/marco-c/j2me.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marco-c/j2me.js/statuses/{sha}","languages_url":"https://api.github.com/repos/marco-c/j2me.js/languages","stargazers_url":"https://api.github.com/repos/marco-c/j2me.js/stargazers","contributors_url":"https://api.github.com/repos/marco-c/j2me.js/contributors","subscribers_url":"https://api.github.com/repos/marco-c/j2me.js/subscribers","subscription_url":"https://api.github.com/repos/marco-c/j2me.js/subscription","commits_url":"https://api.github.com/repos/marco-c/j2me.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/marco-c/j2me.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/marco-c/j2me.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/marco-c/j2me.js/issues/comments/{number}","contents_url":"https://api.github.com/repos/marco-c/j2me.js/contents/{+path}","compare_url":"https://api.github.com/repos/marco-c/j2me.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marco-c/j2me.js/merges","archive_url":"https://api.github.com/repos/marco-c/j2me.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marco-c/j2me.js/downloads","issues_url":"https://api.github.com/repos/marco-c/j2me.js/issues{/number}","pulls_url":"https://api.github.com/repos/marco-c/j2me.js/pulls{/number}","milestones_url":"https://api.github.com/repos/marco-c/j2me.js/milestones{/number}","notifications_url":"https://api.github.com/repos/marco-c/j2me.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marco-c/j2me.js/labels{/name}","releases_url":"https://api.github.com/repos/marco-c/j2me.js/releases{/id}","created_at":"2014-08-01T20:30:33Z","updated_at":"2015-02-12T22:12:55Z","pushed_at":"2015-02-13T01:25:51Z","git_url":"git://github.com/marco-c/j2me.js.git","ssh_url":"git@github.com:marco-c/j2me.js.git","clone_url":"https://github.com/marco-c/j2me.js.git","svn_url":"https://github.com/marco-c/j2me.js","homepage":null,"size":19682,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"6079a614f96329bbe4a3f81f4a07ba3bfba8971c","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":21724513,"name":"j2me.js","full_name":"mozilla/j2me.js","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/j2me.js","description":"J2ME VM in JavaScript","fork":false,"url":"https://api.github.com/repos/mozilla/j2me.js","forks_url":"https://api.github.com/repos/mozilla/j2me.js/forks","keys_url":"https://api.github.com/repos/mozilla/j2me.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/j2me.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/j2me.js/teams","hooks_url":"https://api.github.com/repos/mozilla/j2me.js/hooks","issue_events_url":"https://api.github.com/repos/mozilla/j2me.js/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/j2me.js/events","assignees_url":"https://api.github.com/repos/mozilla/j2me.js/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/j2me.js/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/j2me.js/tags","blobs_url":"https://api.github.com/repos/mozilla/j2me.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/j2me.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/j2me.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/j2me.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/j2me.js/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/j2me.js/languages","stargazers_url":"https://api.github.com/repos/mozilla/j2me.js/stargazers","contributors_url":"https://api.github.com/repos/mozilla/j2me.js/contributors","subscribers_url":"https://api.github.com/repos/mozilla/j2me.js/subscribers","subscription_url":"https://api.github.com/repos/mozilla/j2me.js/subscription","commits_url":"https://api.github.com/repos/mozilla/j2me.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/j2me.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/j2me.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/j2me.js/issues/comments/{number}","contents_url":"https://api.github.com/repos/mozilla/j2me.js/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/j2me.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/j2me.js/merges","archive_url":"https://api.github.com/repos/mozilla/j2me.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/j2me.js/downloads","issues_url":"https://api.github.com/repos/mozilla/j2me.js/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/j2me.js/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/j2me.js/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/j2me.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/j2me.js/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/j2me.js/releases{/id}","created_at":"2014-07-11T06:23:27Z","updated_at":"2015-02-13T01:08:20Z","pushed_at":"2015-02-13T01:08:17Z","git_url":"git://github.com/mozilla/j2me.js.git","ssh_url":"git@github.com:mozilla/j2me.js.git","clone_url":"https://github.com/mozilla/j2me.js.git","svn_url":"https://github.com/mozilla/j2me.js","homepage":null,"size":23786,"stargazers_count":54,"watchers_count":54,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":162,"forks":16,"open_issues":162,"watchers":54,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/j2me.js/pulls/1088"},"html":{"href":"https://github.com/mozilla/j2me.js/pull/1088"},"issue":{"href":"https://api.github.com/repos/mozilla/j2me.js/issues/1088"},"comments":{"href":"https://api.github.com/repos/mozilla/j2me.js/issues/1088/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/j2me.js/pulls/1088/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/j2me.js/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/mozilla/j2me.js/pulls/1088/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/j2me.js/statuses/3bbdd3b01402f858a345cd1c082d95742f7cf61d"}}}}