{"action":"created","comment":{"url":"https://api.github.com/repos/clappr/clappr/pulls/comments/122311289","pull_request_review_id":44416255,"id":122311289,"diff_hunk":"@@ -426,6 +447,96 @@ export default class HTML5Video extends Playback {\n     this.trigger(Events.PLAYBACK_READY, this.name)\n   }\n \n+  _checkForClosedCaptions() {\n+    // Check if CC available only if current playback is HTML5Video\n+    if (this.isHTML5Video && !this._ccIsSetup) {\n+      if (this.hasClosedCaptionsTracks) {\n+        this.trigger(Events.PLAYBACK_SUBTITLE_AVAILABLE)\n+        const trackId = this.closedCaptionsTrackId\n+        this.closedCaptionsTrackId = trackId\n+        this.handleTextTrackChange = this._handleTextTrackChange.bind(this)\n+        this.el.textTracks.addEventListener('change', this.handleTextTrackChange)\n+      }\n+      this._ccIsSetup = true\n+    }\n+  }\n+\n+  _handleTextTrackChange() {\n+    let tracks = this.closedCaptionsTracks\n+    let track = tracks.find((track) => {\n+      if (track.track.mode === 'showing') {\n+        return track\n+      }\n+    }) || {id: -1}\n+    if (this._ccTrackId !== track.id) {\n+      this._ccTrackId = track.id\n+      this.trigger(Events.PLAYBACK_SUBTITLE_CHANGED, {\n+        id: track.id\n+      })\n+    }\n+  }\n+\n+  get isHTML5Video() {\n+    return this.name === HTML5Video.prototype.name\n+  }\n+\n+  get closedCaptionsTracks() {\n+    let id = 0\n+    let newId = () => { return id++ }\n+    let onlySubtitles = (track) => { return track.kind === 'subtitles' }\n+    let makeTrack = (track) => { return {id: newId(), name: track.label, track: track} }\n+    let textTracks = this.el.textTracks ? Array.from(this.el.textTracks) : []\n+\n+    return textTracks.filter(onlySubtitles).map(makeTrack)","path":"src/playbacks/html5_video/html5_video.js","position":123,"original_position":123,"commit_id":"33931d815a05d7b67352e70f9e28fa59d0f29dd9","original_commit_id":"33931d815a05d7b67352e70f9e28fa59d0f29dd9","user":{"login":"leandromoreira","id":55913,"avatar_url":"https://avatars0.githubusercontent.com/u/55913?v=3","gravatar_id":"","url":"https://api.github.com/users/leandromoreira","html_url":"https://github.com/leandromoreira","followers_url":"https://api.github.com/users/leandromoreira/followers","following_url":"https://api.github.com/users/leandromoreira/following{/other_user}","gists_url":"https://api.github.com/users/leandromoreira/gists{/gist_id}","starred_url":"https://api.github.com/users/leandromoreira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leandromoreira/subscriptions","organizations_url":"https://api.github.com/users/leandromoreira/orgs","repos_url":"https://api.github.com/users/leandromoreira/repos","events_url":"https://api.github.com/users/leandromoreira/events{/privacy}","received_events_url":"https://api.github.com/users/leandromoreira/received_events","type":"User","site_admin":false},"body":"Cool!  :D `map` and `filter` seems to be guaranteed (see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/map?v=example https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/filter?v=example)\r\n\r\nSorry if I was nitpicking to change the code style =/, I believe that this style is easier to maintain in long term.","created_at":"2017-06-15T20:57:33Z","updated_at":"2017-06-15T21:05:04Z","html_url":"https://github.com/clappr/clappr/pull/1440#discussion_r122311289","pull_request_url":"https://api.github.com/repos/clappr/clappr/pulls/1440","_links":{"self":{"href":"https://api.github.com/repos/clappr/clappr/pulls/comments/122311289"},"html":{"href":"https://github.com/clappr/clappr/pull/1440#discussion_r122311289"},"pull_request":{"href":"https://api.github.com/repos/clappr/clappr/pulls/1440"}}},"pull_request":{"url":"https://api.github.com/repos/clappr/clappr/pulls/1440","id":124899974,"html_url":"https://github.com/clappr/clappr/pull/1440","diff_url":"https://github.com/clappr/clappr/pull/1440.diff","patch_url":"https://github.com/clappr/clappr/pull/1440.patch","issue_url":"https://api.github.com/repos/clappr/clappr/issues/1440","number":1440,"state":"open","locked":false,"title":"[WIP] feat: closed captions internal plugin","user":{"login":"kslimani","id":1758996,"avatar_url":"https://avatars0.githubusercontent.com/u/1758996?v=3","gravatar_id":"","url":"https://api.github.com/users/kslimani","html_url":"https://github.com/kslimani","followers_url":"https://api.github.com/users/kslimani/followers","following_url":"https://api.github.com/users/kslimani/following{/other_user}","gists_url":"https://api.github.com/users/kslimani/gists{/gist_id}","starred_url":"https://api.github.com/users/kslimani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kslimani/subscriptions","organizations_url":"https://api.github.com/users/kslimani/orgs","repos_url":"https://api.github.com/users/kslimani/repos","events_url":"https://api.github.com/users/kslimani/events{/privacy}","received_events_url":"https://api.github.com/users/kslimani/received_events","type":"User","site_admin":false},"body":"**do not merge**\r\n\r\nShould satisfy #1435.\r\n\r\nIt seems that hls.js [has no mechanisms](https://github.com/video-dev/hls.js/issues/1184) yet to switch subtitle track, so i added one in `html5_video` playback.\r\n\r\nClosed captions (subtitles) feature has been isolated in an `ClosedCaptions` internal plugin to be \"compatible\" with @thiagopnts current work.\r\n\r\nAll the CC switch mechanisms has been moved into `html5_video` playback. It introduce a small breaking change because i renamed some events (only subtitles events), but this should be acceptable because there is no release yet.\r\n\r\nIn Playback and Container base classes i added : \r\n* `closedCaptionsTracks` getter which return a \"normalized\" array of available subtitles tracks\r\n* `closedCaptionsTrackId` property to get or change the current enabled track index (-1 is disabled)\r\n\r\nThe plugin is heavily inspired from [level selector plugin](https://github.com/clappr/clappr-level-selector-plugin).\r\n\r\nI tested with HLS source ([this one](https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8)). (_native and hls.js playbacks_)\r\n\r\nAdded support for external tracks in html5_video playback (_webvtt if supported by browser_).\r\n\r\nThx again to @itsjamie for initial implementation !\r\n\r\nKnown issue: on Firefox, switching track may not instantly change text language displayed on video. It seems this is due to Gecko implementation.\r\n\r\nTODO LIST :\r\n\r\n- [x] hls.js playback support\r\n- [x] add CC detection in html5 video playback (to support mp4+vtt or native hls on iOS)\r\n- [x] add track change detection (to support native device mediacontrol interactions)\r\n- [x] add support for html5_video `<track />`\r\n- [x] add documentation for plugin and new `externalTracks` playback option\r\n","created_at":"2017-06-09T16:01:31Z","updated_at":"2017-06-15T21:05:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6fa79d8158f236e47b5f9d2729901e1f5e9ce977","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/clappr/clappr/pulls/1440/commits","review_comments_url":"https://api.github.com/repos/clappr/clappr/pulls/1440/comments","review_comment_url":"https://api.github.com/repos/clappr/clappr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/clappr/clappr/issues/1440/comments","statuses_url":"https://api.github.com/repos/clappr/clappr/statuses/33931d815a05d7b67352e70f9e28fa59d0f29dd9","head":{"label":"kslimani:fix-cc","ref":"fix-cc","sha":"33931d815a05d7b67352e70f9e28fa59d0f29dd9","user":{"login":"kslimani","id":1758996,"avatar_url":"https://avatars0.githubusercontent.com/u/1758996?v=3","gravatar_id":"","url":"https://api.github.com/users/kslimani","html_url":"https://github.com/kslimani","followers_url":"https://api.github.com/users/kslimani/followers","following_url":"https://api.github.com/users/kslimani/following{/other_user}","gists_url":"https://api.github.com/users/kslimani/gists{/gist_id}","starred_url":"https://api.github.com/users/kslimani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kslimani/subscriptions","organizations_url":"https://api.github.com/users/kslimani/orgs","repos_url":"https://api.github.com/users/kslimani/repos","events_url":"https://api.github.com/users/kslimani/events{/privacy}","received_events_url":"https://api.github.com/users/kslimani/received_events","type":"User","site_admin":false},"repo":{"id":69458415,"name":"clappr","full_name":"kslimani/clappr","owner":{"login":"kslimani","id":1758996,"avatar_url":"https://avatars0.githubusercontent.com/u/1758996?v=3","gravatar_id":"","url":"https://api.github.com/users/kslimani","html_url":"https://github.com/kslimani","followers_url":"https://api.github.com/users/kslimani/followers","following_url":"https://api.github.com/users/kslimani/following{/other_user}","gists_url":"https://api.github.com/users/kslimani/gists{/gist_id}","starred_url":"https://api.github.com/users/kslimani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kslimani/subscriptions","organizations_url":"https://api.github.com/users/kslimani/orgs","repos_url":"https://api.github.com/users/kslimani/repos","events_url":"https://api.github.com/users/kslimani/events{/privacy}","received_events_url":"https://api.github.com/users/kslimani/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kslimani/clappr","description":":clapper: An extensible media player for the web.","fork":true,"url":"https://api.github.com/repos/kslimani/clappr","forks_url":"https://api.github.com/repos/kslimani/clappr/forks","keys_url":"https://api.github.com/repos/kslimani/clappr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kslimani/clappr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kslimani/clappr/teams","hooks_url":"https://api.github.com/repos/kslimani/clappr/hooks","issue_events_url":"https://api.github.com/repos/kslimani/clappr/issues/events{/number}","events_url":"https://api.github.com/repos/kslimani/clappr/events","assignees_url":"https://api.github.com/repos/kslimani/clappr/assignees{/user}","branches_url":"https://api.github.com/repos/kslimani/clappr/branches{/branch}","tags_url":"https://api.github.com/repos/kslimani/clappr/tags","blobs_url":"https://api.github.com/repos/kslimani/clappr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kslimani/clappr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kslimani/clappr/git/refs{/sha}","trees_url":"https://api.github.com/repos/kslimani/clappr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kslimani/clappr/statuses/{sha}","languages_url":"https://api.github.com/repos/kslimani/clappr/languages","stargazers_url":"https://api.github.com/repos/kslimani/clappr/stargazers","contributors_url":"https://api.github.com/repos/kslimani/clappr/contributors","subscribers_url":"https://api.github.com/repos/kslimani/clappr/subscribers","subscription_url":"https://api.github.com/repos/kslimani/clappr/subscription","commits_url":"https://api.github.com/repos/kslimani/clappr/commits{/sha}","git_commits_url":"https://api.github.com/repos/kslimani/clappr/git/commits{/sha}","comments_url":"https://api.github.com/repos/kslimani/clappr/comments{/number}","issue_comment_url":"https://api.github.com/repos/kslimani/clappr/issues/comments{/number}","contents_url":"https://api.github.com/repos/kslimani/clappr/contents/{+path}","compare_url":"https://api.github.com/repos/kslimani/clappr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kslimani/clappr/merges","archive_url":"https://api.github.com/repos/kslimani/clappr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kslimani/clappr/downloads","issues_url":"https://api.github.com/repos/kslimani/clappr/issues{/number}","pulls_url":"https://api.github.com/repos/kslimani/clappr/pulls{/number}","milestones_url":"https://api.github.com/repos/kslimani/clappr/milestones{/number}","notifications_url":"https://api.github.com/repos/kslimani/clappr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kslimani/clappr/labels{/name}","releases_url":"https://api.github.com/repos/kslimani/clappr/releases{/id}","deployments_url":"https://api.github.com/repos/kslimani/clappr/deployments","created_at":"2016-09-28T11:54:29Z","updated_at":"2016-09-28T11:54:30Z","pushed_at":"2017-06-15T17:50:45Z","git_url":"git://github.com/kslimani/clappr.git","ssh_url":"git@github.com:kslimani/clappr.git","clone_url":"https://github.com/kslimani/clappr.git","svn_url":"https://github.com/kslimani/clappr","homepage":"http://clappr.io","size":30761,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"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":"clappr:master","ref":"master","sha":"506c7feb29530fe34be3a9558a223b67fe835e3a","user":{"login":"clappr","id":10685859,"avatar_url":"https://avatars2.githubusercontent.com/u/10685859?v=3","gravatar_id":"","url":"https://api.github.com/users/clappr","html_url":"https://github.com/clappr","followers_url":"https://api.github.com/users/clappr/followers","following_url":"https://api.github.com/users/clappr/following{/other_user}","gists_url":"https://api.github.com/users/clappr/gists{/gist_id}","starred_url":"https://api.github.com/users/clappr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clappr/subscriptions","organizations_url":"https://api.github.com/users/clappr/orgs","repos_url":"https://api.github.com/users/clappr/repos","events_url":"https://api.github.com/users/clappr/events{/privacy}","received_events_url":"https://api.github.com/users/clappr/received_events","type":"Organization","site_admin":false},"repo":{"id":16844474,"name":"clappr","full_name":"clappr/clappr","owner":{"login":"clappr","id":10685859,"avatar_url":"https://avatars2.githubusercontent.com/u/10685859?v=3","gravatar_id":"","url":"https://api.github.com/users/clappr","html_url":"https://github.com/clappr","followers_url":"https://api.github.com/users/clappr/followers","following_url":"https://api.github.com/users/clappr/following{/other_user}","gists_url":"https://api.github.com/users/clappr/gists{/gist_id}","starred_url":"https://api.github.com/users/clappr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clappr/subscriptions","organizations_url":"https://api.github.com/users/clappr/orgs","repos_url":"https://api.github.com/users/clappr/repos","events_url":"https://api.github.com/users/clappr/events{/privacy}","received_events_url":"https://api.github.com/users/clappr/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clappr/clappr","description":":clapper: An extensible media player for the web.","fork":false,"url":"https://api.github.com/repos/clappr/clappr","forks_url":"https://api.github.com/repos/clappr/clappr/forks","keys_url":"https://api.github.com/repos/clappr/clappr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clappr/clappr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clappr/clappr/teams","hooks_url":"https://api.github.com/repos/clappr/clappr/hooks","issue_events_url":"https://api.github.com/repos/clappr/clappr/issues/events{/number}","events_url":"https://api.github.com/repos/clappr/clappr/events","assignees_url":"https://api.github.com/repos/clappr/clappr/assignees{/user}","branches_url":"https://api.github.com/repos/clappr/clappr/branches{/branch}","tags_url":"https://api.github.com/repos/clappr/clappr/tags","blobs_url":"https://api.github.com/repos/clappr/clappr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clappr/clappr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clappr/clappr/git/refs{/sha}","trees_url":"https://api.github.com/repos/clappr/clappr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clappr/clappr/statuses/{sha}","languages_url":"https://api.github.com/repos/clappr/clappr/languages","stargazers_url":"https://api.github.com/repos/clappr/clappr/stargazers","contributors_url":"https://api.github.com/repos/clappr/clappr/contributors","subscribers_url":"https://api.github.com/repos/clappr/clappr/subscribers","subscription_url":"https://api.github.com/repos/clappr/clappr/subscription","commits_url":"https://api.github.com/repos/clappr/clappr/commits{/sha}","git_commits_url":"https://api.github.com/repos/clappr/clappr/git/commits{/sha}","comments_url":"https://api.github.com/repos/clappr/clappr/comments{/number}","issue_comment_url":"https://api.github.com/repos/clappr/clappr/issues/comments{/number}","contents_url":"https://api.github.com/repos/clappr/clappr/contents/{+path}","compare_url":"https://api.github.com/repos/clappr/clappr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clappr/clappr/merges","archive_url":"https://api.github.com/repos/clappr/clappr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clappr/clappr/downloads","issues_url":"https://api.github.com/repos/clappr/clappr/issues{/number}","pulls_url":"https://api.github.com/repos/clappr/clappr/pulls{/number}","milestones_url":"https://api.github.com/repos/clappr/clappr/milestones{/number}","notifications_url":"https://api.github.com/repos/clappr/clappr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clappr/clappr/labels{/name}","releases_url":"https://api.github.com/repos/clappr/clappr/releases{/id}","deployments_url":"https://api.github.com/repos/clappr/clappr/deployments","created_at":"2014-02-14T17:36:40Z","updated_at":"2017-06-15T18:17:46Z","pushed_at":"2017-06-15T17:50:47Z","git_url":"git://github.com/clappr/clappr.git","ssh_url":"git@github.com:clappr/clappr.git","clone_url":"https://github.com/clappr/clappr.git","svn_url":"https://github.com/clappr/clappr","homepage":"http://clappr.io","size":30724,"stargazers_count":3596,"watchers_count":3596,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":458,"mirror_url":null,"open_issues_count":154,"forks":458,"open_issues":154,"watchers":3596,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clappr/clappr/pulls/1440"},"html":{"href":"https://github.com/clappr/clappr/pull/1440"},"issue":{"href":"https://api.github.com/repos/clappr/clappr/issues/1440"},"comments":{"href":"https://api.github.com/repos/clappr/clappr/issues/1440/comments"},"review_comments":{"href":"https://api.github.com/repos/clappr/clappr/pulls/1440/comments"},"review_comment":{"href":"https://api.github.com/repos/clappr/clappr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/clappr/clappr/pulls/1440/commits"},"statuses":{"href":"https://api.github.com/repos/clappr/clappr/statuses/33931d815a05d7b67352e70f9e28fa59d0f29dd9"}}}}
{"actor":{"display_login":"leandromoreira"}}