{"action":"created","comment":{"url":"https://api.github.com/repos/videojs/video.js/pulls/comments/91801178","pull_request_review_id":12283365,"id":91801178,"diff_hunk":"@@ -9,6 +9,9 @@\n <body>\n   <div id=\"qunit\"></div>\n   <script src=\"../node_modules/qunitjs/qunit/qunit.js\"></script>\n+  <script>\n+    QUnit.config.reorder = false;","path":"test/index.html","position":5,"original_position":5,"commit_id":"2d74db3fff9064f653baa58d6eae1d1e4f6b8dfe","original_commit_id":"2d74db3fff9064f653baa58d6eae1d1e4f6b8dfe","user":{"login":"BrandonOCasey","id":2381475,"avatar_url":"https://avatars.githubusercontent.com/u/2381475?v=3","gravatar_id":"","url":"https://api.github.com/users/BrandonOCasey","html_url":"https://github.com/BrandonOCasey","followers_url":"https://api.github.com/users/BrandonOCasey/followers","following_url":"https://api.github.com/users/BrandonOCasey/following{/other_user}","gists_url":"https://api.github.com/users/BrandonOCasey/gists{/gist_id}","starred_url":"https://api.github.com/users/BrandonOCasey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrandonOCasey/subscriptions","organizations_url":"https://api.github.com/users/BrandonOCasey/orgs","repos_url":"https://api.github.com/users/BrandonOCasey/repos","events_url":"https://api.github.com/users/BrandonOCasey/events{/privacy}","received_events_url":"https://api.github.com/users/BrandonOCasey/received_events","type":"User","site_admin":false},"body":"Should this be in the generator/spellbook?","created_at":"2016-12-09T21:42:16Z","updated_at":"2016-12-09T21:42:56Z","html_url":"https://github.com/videojs/video.js/pull/3788#discussion_r91801178","pull_request_url":"https://api.github.com/repos/videojs/video.js/pulls/3788","_links":{"self":{"href":"https://api.github.com/repos/videojs/video.js/pulls/comments/91801178"},"html":{"href":"https://github.com/videojs/video.js/pull/3788#discussion_r91801178"},"pull_request":{"href":"https://api.github.com/repos/videojs/video.js/pulls/3788"}}},"pull_request":{"url":"https://api.github.com/repos/videojs/video.js/pulls/3788","id":94036308,"html_url":"https://github.com/videojs/video.js/pull/3788","diff_url":"https://github.com/videojs/video.js/pull/3788.diff","patch_url":"https://github.com/videojs/video.js/pull/3788.patch","issue_url":"https://api.github.com/repos/videojs/video.js/issues/3788","number":3788,"state":"open","locked":false,"title":"[WIP] Middleware","user":{"login":"gkatsev","id":535884,"avatar_url":"https://avatars.githubusercontent.com/u/535884?v=3","gravatar_id":"","url":"https://api.github.com/users/gkatsev","html_url":"https://github.com/gkatsev","followers_url":"https://api.github.com/users/gkatsev/followers","following_url":"https://api.github.com/users/gkatsev/following{/other_user}","gists_url":"https://api.github.com/users/gkatsev/gists{/gist_id}","starred_url":"https://api.github.com/users/gkatsev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gkatsev/subscriptions","organizations_url":"https://api.github.com/users/gkatsev/orgs","repos_url":"https://api.github.com/users/gkatsev/repos","events_url":"https://api.github.com/users/gkatsev/events{/privacy}","received_events_url":"https://api.github.com/users/gkatsev/received_events","type":"User","site_admin":false},"body":"## Description\r\nThis is the initial PR for middleware which hopes to solve the problems from https://github.com/videojs/video.js/issues/3734.\r\nMiddleware are objects with two special functions `setSource` and `setTech`. On top of these special methods, it can have getters and setters. Currently, the only allowed ones are `currentTime`, `duration`, and `setCurrentTime`. In the future it can be extended to allow more. Also, methods like `play` could probably be treated as setters and events originating from the video element can be treated as getters and events triggered on the player could be treated as setters. But that's more in the future.\r\n\r\nThe core of middleware is that video types are basically a routing tree. So, you can \"use\" a middleware on a particular type but you can also \"use\" a tech on a particular type using special syntax since techs need a bit extra handling.\r\n```js\r\n// example HLS usage\r\nvideojs.use('application/x-mpegurl', require('contrib-hls'));\r\nvideojs.use('application/vnd.apple.mpegurl', require('contrib-hls'));\r\n\r\n// example tech usage\r\nvideojs.use('video/mp4', 'videojs/html5');\r\nvideojs.use('application/x-mpegurl', 'videojs/html5');\r\n```\r\n\r\nThe contrib-hls object could look something like this:\r\n```js\r\nmodule.exports = {\r\n  setSource(srcObj, next) {\r\n    // next expects an error as a first argument to let the middleware know whether you can handle the current srcObj\r\n    // you can also modify this srcObj and return something else instead which will continue down the middleware tree\r\n    next(false, srcObj);\r\n  },\r\n\r\n  setTech(tech) {\r\n    // this gets the tech that ends up getting chosen to back everything. Store it if you need it.\r\n    // the tech still acts as the final source of truth for everything\r\n  },\r\n\r\n  currentTime(previousCt) {\r\n    // getters get the value from further up the chain and should return a transformed value, if necessary.\r\n    // In a simple case, the middleware would get the value from the tech and would expect to return a value for the player to use\r\n    return previousCt / 2;\r\n  },\r\n\r\n  setCurrentTime(newCt) {\r\n    // setters get the value from further up the chain and should return a transformed value, if necessary.\r\n   // In a simple case, the middleware would get the value from the player and would expect to return a value for the tech to use\r\n  return newCt;\r\n  }\r\n};\r\n```\r\n\r\nI have a simple live example here: http://plnkr.co/edit/Ap9Fvg21lpYW3Rnlk9ty?p=preview","created_at":"2016-11-16T19:46:26Z","updated_at":"2016-12-09T21:42:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1855eb3b738bd195233658f1ecaa78c26da557e5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/videojs/video.js/pulls/3788/commits","review_comments_url":"https://api.github.com/repos/videojs/video.js/pulls/3788/comments","review_comment_url":"https://api.github.com/repos/videojs/video.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/videojs/video.js/issues/3788/comments","statuses_url":"https://api.github.com/repos/videojs/video.js/statuses/2d74db3fff9064f653baa58d6eae1d1e4f6b8dfe","head":{"label":"videojs:middleware","ref":"middleware","sha":"2d74db3fff9064f653baa58d6eae1d1e4f6b8dfe","user":{"login":"videojs","id":3287189,"avatar_url":"https://avatars.githubusercontent.com/u/3287189?v=3","gravatar_id":"","url":"https://api.github.com/users/videojs","html_url":"https://github.com/videojs","followers_url":"https://api.github.com/users/videojs/followers","following_url":"https://api.github.com/users/videojs/following{/other_user}","gists_url":"https://api.github.com/users/videojs/gists{/gist_id}","starred_url":"https://api.github.com/users/videojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/videojs/subscriptions","organizations_url":"https://api.github.com/users/videojs/orgs","repos_url":"https://api.github.com/users/videojs/repos","events_url":"https://api.github.com/users/videojs/events{/privacy}","received_events_url":"https://api.github.com/users/videojs/received_events","type":"Organization","site_admin":false},"repo":{"id":667006,"name":"video.js","full_name":"videojs/video.js","owner":{"login":"videojs","id":3287189,"avatar_url":"https://avatars.githubusercontent.com/u/3287189?v=3","gravatar_id":"","url":"https://api.github.com/users/videojs","html_url":"https://github.com/videojs","followers_url":"https://api.github.com/users/videojs/followers","following_url":"https://api.github.com/users/videojs/following{/other_user}","gists_url":"https://api.github.com/users/videojs/gists{/gist_id}","starred_url":"https://api.github.com/users/videojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/videojs/subscriptions","organizations_url":"https://api.github.com/users/videojs/orgs","repos_url":"https://api.github.com/users/videojs/repos","events_url":"https://api.github.com/users/videojs/events{/privacy}","received_events_url":"https://api.github.com/users/videojs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/videojs/video.js","description":"Video.js - open source HTML5 & Flash video player","fork":false,"url":"https://api.github.com/repos/videojs/video.js","forks_url":"https://api.github.com/repos/videojs/video.js/forks","keys_url":"https://api.github.com/repos/videojs/video.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/videojs/video.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/videojs/video.js/teams","hooks_url":"https://api.github.com/repos/videojs/video.js/hooks","issue_events_url":"https://api.github.com/repos/videojs/video.js/issues/events{/number}","events_url":"https://api.github.com/repos/videojs/video.js/events","assignees_url":"https://api.github.com/repos/videojs/video.js/assignees{/user}","branches_url":"https://api.github.com/repos/videojs/video.js/branches{/branch}","tags_url":"https://api.github.com/repos/videojs/video.js/tags","blobs_url":"https://api.github.com/repos/videojs/video.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/videojs/video.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/videojs/video.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/videojs/video.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/videojs/video.js/statuses/{sha}","languages_url":"https://api.github.com/repos/videojs/video.js/languages","stargazers_url":"https://api.github.com/repos/videojs/video.js/stargazers","contributors_url":"https://api.github.com/repos/videojs/video.js/contributors","subscribers_url":"https://api.github.com/repos/videojs/video.js/subscribers","subscription_url":"https://api.github.com/repos/videojs/video.js/subscription","commits_url":"https://api.github.com/repos/videojs/video.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/videojs/video.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/videojs/video.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/videojs/video.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/videojs/video.js/contents/{+path}","compare_url":"https://api.github.com/repos/videojs/video.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/videojs/video.js/merges","archive_url":"https://api.github.com/repos/videojs/video.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/videojs/video.js/downloads","issues_url":"https://api.github.com/repos/videojs/video.js/issues{/number}","pulls_url":"https://api.github.com/repos/videojs/video.js/pulls{/number}","milestones_url":"https://api.github.com/repos/videojs/video.js/milestones{/number}","notifications_url":"https://api.github.com/repos/videojs/video.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/videojs/video.js/labels{/name}","releases_url":"https://api.github.com/repos/videojs/video.js/releases{/id}","deployments_url":"https://api.github.com/repos/videojs/video.js/deployments","created_at":"2010-05-14T18:45:10Z","updated_at":"2016-12-09T21:37:14Z","pushed_at":"2016-12-09T21:20:14Z","git_url":"git://github.com/videojs/video.js.git","ssh_url":"git@github.com:videojs/video.js.git","clone_url":"https://github.com/videojs/video.js.git","svn_url":"https://github.com/videojs/video.js","homepage":"www.videojs.com","size":118739,"stargazers_count":14454,"watchers_count":14454,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":4184,"mirror_url":null,"open_issues_count":227,"forks":4184,"open_issues":227,"watchers":14454,"default_branch":"master"}},"base":{"label":"videojs:master","ref":"master","sha":"766580af2b7b8fd4c29b007ccdab1b85c4f14f8e","user":{"login":"videojs","id":3287189,"avatar_url":"https://avatars.githubusercontent.com/u/3287189?v=3","gravatar_id":"","url":"https://api.github.com/users/videojs","html_url":"https://github.com/videojs","followers_url":"https://api.github.com/users/videojs/followers","following_url":"https://api.github.com/users/videojs/following{/other_user}","gists_url":"https://api.github.com/users/videojs/gists{/gist_id}","starred_url":"https://api.github.com/users/videojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/videojs/subscriptions","organizations_url":"https://api.github.com/users/videojs/orgs","repos_url":"https://api.github.com/users/videojs/repos","events_url":"https://api.github.com/users/videojs/events{/privacy}","received_events_url":"https://api.github.com/users/videojs/received_events","type":"Organization","site_admin":false},"repo":{"id":667006,"name":"video.js","full_name":"videojs/video.js","owner":{"login":"videojs","id":3287189,"avatar_url":"https://avatars.githubusercontent.com/u/3287189?v=3","gravatar_id":"","url":"https://api.github.com/users/videojs","html_url":"https://github.com/videojs","followers_url":"https://api.github.com/users/videojs/followers","following_url":"https://api.github.com/users/videojs/following{/other_user}","gists_url":"https://api.github.com/users/videojs/gists{/gist_id}","starred_url":"https://api.github.com/users/videojs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/videojs/subscriptions","organizations_url":"https://api.github.com/users/videojs/orgs","repos_url":"https://api.github.com/users/videojs/repos","events_url":"https://api.github.com/users/videojs/events{/privacy}","received_events_url":"https://api.github.com/users/videojs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/videojs/video.js","description":"Video.js - open source HTML5 & Flash video player","fork":false,"url":"https://api.github.com/repos/videojs/video.js","forks_url":"https://api.github.com/repos/videojs/video.js/forks","keys_url":"https://api.github.com/repos/videojs/video.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/videojs/video.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/videojs/video.js/teams","hooks_url":"https://api.github.com/repos/videojs/video.js/hooks","issue_events_url":"https://api.github.com/repos/videojs/video.js/issues/events{/number}","events_url":"https://api.github.com/repos/videojs/video.js/events","assignees_url":"https://api.github.com/repos/videojs/video.js/assignees{/user}","branches_url":"https://api.github.com/repos/videojs/video.js/branches{/branch}","tags_url":"https://api.github.com/repos/videojs/video.js/tags","blobs_url":"https://api.github.com/repos/videojs/video.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/videojs/video.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/videojs/video.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/videojs/video.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/videojs/video.js/statuses/{sha}","languages_url":"https://api.github.com/repos/videojs/video.js/languages","stargazers_url":"https://api.github.com/repos/videojs/video.js/stargazers","contributors_url":"https://api.github.com/repos/videojs/video.js/contributors","subscribers_url":"https://api.github.com/repos/videojs/video.js/subscribers","subscription_url":"https://api.github.com/repos/videojs/video.js/subscription","commits_url":"https://api.github.com/repos/videojs/video.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/videojs/video.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/videojs/video.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/videojs/video.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/videojs/video.js/contents/{+path}","compare_url":"https://api.github.com/repos/videojs/video.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/videojs/video.js/merges","archive_url":"https://api.github.com/repos/videojs/video.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/videojs/video.js/downloads","issues_url":"https://api.github.com/repos/videojs/video.js/issues{/number}","pulls_url":"https://api.github.com/repos/videojs/video.js/pulls{/number}","milestones_url":"https://api.github.com/repos/videojs/video.js/milestones{/number}","notifications_url":"https://api.github.com/repos/videojs/video.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/videojs/video.js/labels{/name}","releases_url":"https://api.github.com/repos/videojs/video.js/releases{/id}","deployments_url":"https://api.github.com/repos/videojs/video.js/deployments","created_at":"2010-05-14T18:45:10Z","updated_at":"2016-12-09T21:37:14Z","pushed_at":"2016-12-09T21:20:14Z","git_url":"git://github.com/videojs/video.js.git","ssh_url":"git@github.com:videojs/video.js.git","clone_url":"https://github.com/videojs/video.js.git","svn_url":"https://github.com/videojs/video.js","homepage":"www.videojs.com","size":118739,"stargazers_count":14454,"watchers_count":14454,"language":"JavaScript","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":4184,"mirror_url":null,"open_issues_count":227,"forks":4184,"open_issues":227,"watchers":14454,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/videojs/video.js/pulls/3788"},"html":{"href":"https://github.com/videojs/video.js/pull/3788"},"issue":{"href":"https://api.github.com/repos/videojs/video.js/issues/3788"},"comments":{"href":"https://api.github.com/repos/videojs/video.js/issues/3788/comments"},"review_comments":{"href":"https://api.github.com/repos/videojs/video.js/pulls/3788/comments"},"review_comment":{"href":"https://api.github.com/repos/videojs/video.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/videojs/video.js/pulls/3788/commits"},"statuses":{"href":"https://api.github.com/repos/videojs/video.js/statuses/2d74db3fff9064f653baa58d6eae1d1e4f6b8dfe"}}}}
{"actor":{"display_login":"BrandonOCasey"}}