From 0c390b3f2e5b99285a4fa859204e6f555046e0bf Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sat, 19 Dec 2015 23:43:59 +0100 Subject: [PATCH 01/56] groupedSrc method, Readme --- README.md | 47 +++++++++++++++++++++++++++++- lib/videojs-resolution-switcher.js | 4 +++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e3d6bac..eb3e70e 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ player.updateSrc([ |:----:|:----:|:--------:|:-----------:| | source| array| no | array of sources | -### currentResolution([label]) +### currentResolution([label], [customSourcePicker]) If used as getter returns current resolution object: ```javascript { @@ -154,6 +154,51 @@ player.currentResolution('SD'); // returns videojs player object | name | type | required | description | |:----:|:----:|:--------:|:-----------:| | label| string| no | label name | +| customSourcePicker | function | no | cutom function to choose source | + +#### customSourcePicker +If there is more than one source with the same label, player will choose source automatically. This behavior can be changed if `customSourcePicker` is passed. + +`customSourcePicker` must return `player` object. +```javascript +player.currentResolution('SD', function(_player, _sources, _label){ + return _player.src(_sources[0]); \\ Always select first source in array +}); +``` +`customSourcePicker` accepst 3 arguments. + +| name | type | required | description | +|:----:|:----:|:--------:|:-----------:| +| palyer| Object | yes | videojs player object | +| sources | Array | no | array of sources | +| label | String | no | name of label | + +`customSourcePicker` may be passed in options when player is initialized: +```javascript + +var myCustomSrcPicker = function(_p, _s, _l){ + // select any source you want + return _p.src(selectedSource); +} + +videojs('video', { + controls: true, + muted: true, + width: 1000, + plugins: { + videoJsResolutionSwitcher: { + default: 'low', + customSourcePicker: myCustomSrcPicker + } + } + }, function(){ + // this is player + }) +``` + + +### getGroupedSrc() +Returns sources grouped by label, resolution and type. ## Events diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index 20f5621..e2f356e 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -195,6 +195,10 @@ return player; }; + /** + * Returns grouped sources by label, resolution and type + * @returns {Object} grouped sources: { label: { key: [] }, res: { key: [] }, type: { key: [] } } + */ player.getGroupedSrc = function(){ return groupedSrc; } From a9178dc4aaaea77216636d81be59e3f1b32690aa Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sat, 19 Dec 2015 23:45:43 +0100 Subject: [PATCH 02/56] readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index eb3e70e..7050e43 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ videojs('video', { ### Avalible options: * default - `{Number}|'low'|'high'` - default resolution. If any `Number` is passed plugin will try to choose source based on `res` parameter. If `low` or `high` is passed, plugin will choose respectively worse or best resolution (if `res` parameter is specified). If `res` parameter is not specified plugin assumes that sources array is sorted from best to worse. * dynamicLabel - `{Boolean}` - if `true` current label will be displayed in control bar. By default gear icon is displayed. +* customSourcePicker - `{Function}` - custom function for selecting source. ## Example From b6d6c348eceaa77fe1fb0c1920ad563a10af258c Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sat, 19 Dec 2015 23:46:45 +0100 Subject: [PATCH 03/56] RM fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7050e43..d5f0d30 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ player.currentResolution('SD', function(_player, _sources, _label){ | name | type | required | description | |:----:|:----:|:--------:|:-----------:| -| palyer| Object | yes | videojs player object | +| player| Object | yes | videojs player object | | sources | Array | no | array of sources | | label | String | no | name of label | From 9960add1390ffc81edf02a416c91347d3f79528b Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sat, 19 Dec 2015 23:47:18 +0100 Subject: [PATCH 04/56] 3.0 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 6f0c2a7..ba974b6 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "vjs-resolution-switcher", - "version": "0.2.3", + "version": "0.3.0", "authors": [ "Kasper Moskwiak " ], From cd88cf2a90ed54d9cc48ba81820db697c4e75fe3 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sat, 19 Dec 2015 23:47:55 +0100 Subject: [PATCH 05/56] 0.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fd8fe0..61d3c92 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "videojs-resolution-switcher", - "version": "0.2.3", + "version": "0.3.0", "main": "./lib/videojs-resolution-switcher.js", "author": { "name": "Kasper Moskwiak", From 1121c822d92ed25db60b770dc6578a7651fe7a98 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sun, 20 Dec 2015 11:20:57 +0100 Subject: [PATCH 06/56] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d5f0d30..23cbcda 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ -# Video.js Resolution Switcher +# Video.js Resolution Switcher [![Build Status](https://travis-ci.org/kmoskwiak/videojs-resolution-switcher.svg?branch=master)](https://travis-ci.org/kmoskwiak/videojs-resolution-switcher) Resolution switcher for [video.js v5](https://github.com/videojs/video.js) + + ## Getting Started Install plugin with @@ -208,4 +210,5 @@ Returns sources grouped by label, resolution and type. > Fired when resolution is changed +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/kmoskwiak/videojs-resolution-switcher/trend.png)](https://bitdeli.com/free "Bitdeli Badge") From 437ecd076c66a1a48f2ac23e181a49a42d52248c Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sun, 20 Dec 2015 12:01:23 +0100 Subject: [PATCH 07/56] jshint tests --- Gruntfile.js | 4 ++++ lib/videojs-resolution-switcher.js | 4 ++-- package.json | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 89a9142..a0435f8 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -81,4 +81,8 @@ module.exports = function(grunt) { 'qunit', 'concat', 'uglify']); + + grunt.registerTask('test', [ + 'jshint' + ]); }; diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index e2f356e..cb4f767 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -80,7 +80,7 @@ // Probably because of https://github.com/videojs/video-js-swf/issues/124 // If player preload is 'none' and then loadeddata not fired. So, we need timeupdate event for seek handle (timeupdate doesn't work properly with flash) var handleSeekEvent = 'loadeddata'; - if(this.player_.preload() == 'none' && this.player_.techName_ != 'Flash') { + if(this.player_.preload() === 'none' && this.player_.techName_ !== 'Flash') { handleSeekEvent = 'timeupdate'; } setSourcesSanitized(this.player_, this.src, this.options_.label, customSourcePicker).one(handleSeekEvent, function() { @@ -201,7 +201,7 @@ */ player.getGroupedSrc = function(){ return groupedSrc; - } + }; /** * Method used for sorting list of sources diff --git a/package.json b/package.json index 61d3c92..ffb197a 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,12 @@ "source", "videojs-plugin" ], - "dependencies": {}, + "scripts": { + "test": "grunt test" + }, + "dependencies": { + "grunt": "^0.4.5" + }, "devDependencies": { "grunt-contrib-clean": "^0.7", "grunt-contrib-concat": "^0.5", From 91da2a04ffe1fa531d5e37c27dfd0ed364381730 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sun, 20 Dec 2015 12:05:55 +0100 Subject: [PATCH 08/56] travis conf update --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4f23153..41d37ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,4 +3,6 @@ node_js: - 4 - 0.12 - 0.10 +before_install: npm install -g grunt-cli +install: npm install sudo: false From b3b047253b855bd63503902bf8ae11c259d814d2 Mon Sep 17 00:00:00 2001 From: Mohammad Samimi Date: Sun, 27 Dec 2015 14:27:24 +0330 Subject: [PATCH 09/56] add menu button before full screen button --- lib/videojs-resolution-switcher.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index cb4f767..785e47a 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -125,7 +125,7 @@ item.selected(item === clickedItem); }); }; - + for (var key in labels) { if (labels.hasOwnProperty(key)) { menuItems.push(new ResolutionMenuItem( @@ -177,7 +177,7 @@ var choosen = chooseSrc(groupedSrc, src); var menuButton = new ResolutionMenuButton(player, { sources: groupedSrc, initialySelectedLabel: choosen.label , initialySelectedRes: choosen.res , customSourcePicker: settings.customSourcePicker}, settings, label); menuButton.el().classList.add('vjs-resolution-button'); - player.controlBar.resolutionSwitcher = player.controlBar.addChild(menuButton); + player.controlBar.resolutionSwitcher = player.controlBar.el_.insertBefore(menuButton.el_, player.controlBar.getChild('fullscreenToggle').el_); return setSourcesSanitized(player, choosen.sources, choosen.label); }; @@ -194,7 +194,7 @@ } return player; }; - + /** * Returns grouped sources by label, resolution and type * @returns {Object} grouped sources: { label: { key: [] }, res: { key: [] }, type: { key: [] } } From 661e52197214fe6cc4204243dea729f5f04abe27 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Mon, 28 Dec 2015 20:51:40 +0100 Subject: [PATCH 10/56] readme - moved example --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 23cbcda..f0c4c96 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ Resolution switcher for [video.js v5](https://github.com/videojs/video.js) +## Example +[Working example](example.html) of the plugin you can check out if you're having trouble. Or check out this [demo](https://kmoskwiak.github.io/videojs-resolution-switcher/). ## Getting Started @@ -106,9 +108,6 @@ videojs('video', { * dynamicLabel - `{Boolean}` - if `true` current label will be displayed in control bar. By default gear icon is displayed. * customSourcePicker - `{Function}` - custom function for selecting source. -## Example - -[Working example](example.html) of the plugin you can check out if you're having trouble. Or check out this [demo](https://kmoskwiak.github.io/videojs-resolution-switcher/). ## Methods From 5bb133609d2d8e50121d79045b1ba53769a3d4e5 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Mon, 28 Dec 2015 20:52:59 +0100 Subject: [PATCH 11/56] version update --- bower.json | 2 +- lib/videojs-resolution-switcher.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index ba974b6..2c3f155 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "vjs-resolution-switcher", - "version": "0.3.0", + "version": "0.3.1", "authors": [ "Kasper Moskwiak " ], diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index 785e47a..8b3bd52 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -1,4 +1,4 @@ -/*! videojs-resolution-switcher - v0.0.0 - 2015-7-26 +/*! videojs-resolution-switcher - 2015-7-26 * Copyright (c) 2015 Kasper Moskwiak * Modified by Pierre Kraft * Licensed under the Apache-2.0 license. */ From 2219110b837bc7481b489414fab1517eacabc26a Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Mon, 28 Dec 2015 20:53:16 +0100 Subject: [PATCH 12/56] 0.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ffb197a..b99f30b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "videojs-resolution-switcher", - "version": "0.3.0", + "version": "0.3.1", "main": "./lib/videojs-resolution-switcher.js", "author": { "name": "Kasper Moskwiak", From 70d994853bd099557495618389b00ee00fde1411 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Thu, 31 Dec 2015 14:49:27 +0100 Subject: [PATCH 13/56] Update README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index f0c4c96..b672b3e 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,3 @@ Returns sources grouped by label, resolution and type. ### resolutionchange `EVENT` > Fired when resolution is changed - -[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/kmoskwiak/videojs-resolution-switcher/trend.png)](https://bitdeli.com/free "Bitdeli Badge") - From e539a816b0582b1b880a4e0f6f3bff50c55c3cd1 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Thu, 31 Dec 2015 21:30:45 +0100 Subject: [PATCH 14/56] happy new year! --- lib/videojs-resolution-switcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index 8b3bd52..187c654 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -1,5 +1,5 @@ /*! videojs-resolution-switcher - 2015-7-26 - * Copyright (c) 2015 Kasper Moskwiak + * Copyright (c) 2016 Kasper Moskwiak * Modified by Pierre Kraft * Licensed under the Apache-2.0 license. */ From cdda41a7034f52beac369471236c877994892d8c Mon Sep 17 00:00:00 2001 From: Gregor Kralik Date: Wed, 27 Jan 2016 13:41:26 +0100 Subject: [PATCH 15/56] add class .vjs-selected to the selected version's menu item --- lib/videojs-resolution-switcher.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index 187c654..4e54581 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -53,6 +53,8 @@ if (options.initialySelected) { this.showAsLabel(); this.selected(true); + + this.addClass('vjs-selected'); } }, showAsLabel: function() { @@ -67,6 +69,10 @@ var currentTime = this.player_.currentTime(); var isPaused = this.player_.paused(); this.showAsLabel(); + + // add .current class + this.addClass('vjs-selected'); + // Hide bigPlayButton if(!isPaused){ this.player_.bigPlayButton.hide(); @@ -123,6 +129,7 @@ var onClickUnselectOthers = function(clickedItem) { menuItems.map(function(item) { item.selected(item === clickedItem); + item.removeClass('vjs-selected'); }); }; From 365238ba456bbc1444918f80ed522b044fa95ea3 Mon Sep 17 00:00:00 2001 From: Gregor Kralik Date: Wed, 27 Jan 2016 13:42:55 +0100 Subject: [PATCH 16/56] disable the text-transform CSS property for the resolution menu the default skin has text-transform: lowercase. so if one uses "HD" and "SD" as resolution labels, it will render as "hd" and "sd" by default. override the property so no transformation occurs and the labels show as the user wants them to show. --- lib/videojs-resolution-switcher.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/videojs-resolution-switcher.css b/lib/videojs-resolution-switcher.css index a2224ce..d1a4232 100644 --- a/lib/videojs-resolution-switcher.css +++ b/lib/videojs-resolution-switcher.css @@ -28,3 +28,7 @@ .vjs-resolution-button .vjs-menu { left: 0; } + +.vjs-resolution-button .vjs-menu li { + text-transform: none; +} From 8f6511f1e491526fcb2018ff248eb1baec16cf04 Mon Sep 17 00:00:00 2001 From: Gregor Kralik Date: Wed, 27 Jan 2016 14:45:14 +0100 Subject: [PATCH 17/56] make sure the resolution select button's text is vertically centered decrease the line-height from 2.5em to 2.3em --- lib/videojs-resolution-switcher.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/videojs-resolution-switcher.css b/lib/videojs-resolution-switcher.css index a2224ce..9eb726e 100644 --- a/lib/videojs-resolution-switcher.css +++ b/lib/videojs-resolution-switcher.css @@ -11,7 +11,7 @@ .vjs-resolution-button .vjs-resolution-button-label { font-size: 1.2em; - line-height: 2.50em; + line-height: 2.30em; position: absolute; top: 0; left: 0; From a42dc8694c2d174684a34a0aabec5e24ee5af4a9 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sat, 6 Feb 2016 11:21:53 +0100 Subject: [PATCH 18/56] update packages --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b99f30b..e56bba8 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ "devDependencies": { "grunt-contrib-clean": "^0.7", "grunt-contrib-concat": "^0.5", - "grunt-contrib-jshint": "^0.11", - "grunt-contrib-qunit": "^0.7", + "grunt-contrib-jshint": "^0.12", + "grunt-contrib-qunit": "^1.0", "grunt-contrib-uglify": "^0.11", "grunt-contrib-watch": "^0.6", "video.js": "^5.4", From dd389e900c77186a0328c39ea160eb710fc5a62c Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Mon, 8 Feb 2016 11:42:15 +0100 Subject: [PATCH 19/56] bower version --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 2c3f155..a20b9af 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "vjs-resolution-switcher", - "version": "0.3.1", + "version": "0.3.2", "authors": [ "Kasper Moskwiak " ], From 9b231adcf8d9618f04fa026bc101c055683f92b3 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Mon, 8 Feb 2016 11:42:50 +0100 Subject: [PATCH 20/56] 0.3.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e56bba8..d57b945 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "videojs-resolution-switcher", - "version": "0.3.1", + "version": "0.3.2", "main": "./lib/videojs-resolution-switcher.js", "author": { "name": "Kasper Moskwiak", From 694392ab05c794536f2fff805ae2db7eb8476c18 Mon Sep 17 00:00:00 2001 From: Yurifag Date: Wed, 2 Mar 2016 17:25:43 +0100 Subject: [PATCH 21/56] implement dispose method --- lib/videojs-resolution-switcher.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index 4e54581..e57346f 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -185,6 +185,9 @@ var menuButton = new ResolutionMenuButton(player, { sources: groupedSrc, initialySelectedLabel: choosen.label , initialySelectedRes: choosen.res , customSourcePicker: settings.customSourcePicker}, settings, label); menuButton.el().classList.add('vjs-resolution-button'); player.controlBar.resolutionSwitcher = player.controlBar.el_.insertBefore(menuButton.el_, player.controlBar.getChild('fullscreenToggle').el_); + player.controlBar.resolutionSwitcher.dispose = function(){ + this.parentNode.removeChild(this); + }; return setSourcesSanitized(player, choosen.sources, choosen.label); }; From 7a5fe76ba8b94fc3b5d84ec45ba3185d34e051db Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sun, 13 Mar 2016 19:07:25 +0100 Subject: [PATCH 22/56] videojs upgrade --- package.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index d57b945..55792c5 100644 --- a/package.json +++ b/package.json @@ -38,16 +38,16 @@ "grunt": "^0.4.5" }, "devDependencies": { - "grunt-contrib-clean": "^0.7", - "grunt-contrib-concat": "^0.5", - "grunt-contrib-jshint": "^0.12", - "grunt-contrib-qunit": "^1.0", - "grunt-contrib-uglify": "^0.11", - "grunt-contrib-watch": "^0.6", - "video.js": "^5.4", - "qunitjs": "^1.20" + "grunt-contrib-clean": "^1.0", + "grunt-contrib-concat": "^1.0", + "grunt-contrib-jshint": "^1.0", + "grunt-contrib-qunit": "^1.1", + "grunt-contrib-uglify": "^1.0", + "grunt-contrib-watch": "^1.0", + "video.js": "^5.8", + "qunitjs": "^1.22" }, "peerDependencies": { - "video.js": "^5.4" + "video.js": "^5.8" } } From bcff5176f1c78811e75daf69e076635bd6a689f3 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sun, 13 Mar 2016 19:18:18 +0100 Subject: [PATCH 23/56] grunt in dev --- package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index 55792c5..49b706a 100644 --- a/package.json +++ b/package.json @@ -34,10 +34,8 @@ "scripts": { "test": "grunt test" }, - "dependencies": { - "grunt": "^0.4.5" - }, "devDependencies": { + "grunt": "^0.4.5", "grunt-contrib-clean": "^1.0", "grunt-contrib-concat": "^1.0", "grunt-contrib-jshint": "^1.0", From eb189a02a917b01125686cde3c3d04a63e7193ef Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sun, 13 Mar 2016 19:19:14 +0100 Subject: [PATCH 24/56] bower version 0.3.3 --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index a20b9af..8c8c766 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "vjs-resolution-switcher", - "version": "0.3.2", + "version": "0.3.3", "authors": [ "Kasper Moskwiak " ], From f19f33caf934fbdd80f9da9871133c7af3f87fb9 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sun, 13 Mar 2016 19:19:57 +0100 Subject: [PATCH 25/56] 0.3.3 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 49b706a..1416436 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "videojs-resolution-switcher", - "version": "0.3.2", + "version": "0.3.3", "main": "./lib/videojs-resolution-switcher.js", "author": { "name": "Kasper Moskwiak", @@ -35,7 +35,7 @@ "test": "grunt test" }, "devDependencies": { - "grunt": "^0.4.5", + "grunt": "^0.4.5", "grunt-contrib-clean": "^1.0", "grunt-contrib-concat": "^1.0", "grunt-contrib-jshint": "^1.0", From 42c6498597bd35705cb3614cf3e78588405c2ba6 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sun, 13 Mar 2016 20:05:31 +0100 Subject: [PATCH 26/56] fix #24 --- lib/videojs-resolution-switcher.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index e57346f..7c04c4b 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -119,7 +119,7 @@ this.el().appendChild(label); }else{ var staticLabel = document.createElement('span'); - staticLabel.classList.add('vjs-resolution-button-staticlabel'); + videojs.addClass(staticLabel, 'vjs-resolution-button-staticlabel'); this.el().appendChild(staticLabel); } }, @@ -163,8 +163,8 @@ label = document.createElement('span'), groupedSrc = {}; - label.classList.add('vjs-resolution-button-label'); - + videojs.addClass(label, 'vjs-resolution-button-label'); + /** * Updates player sources or returns current source URL * @param {Array} [src] array of sources [{src: '', type: '', label: '', res: ''}] @@ -183,7 +183,7 @@ groupedSrc = bucketSources(src); var choosen = chooseSrc(groupedSrc, src); var menuButton = new ResolutionMenuButton(player, { sources: groupedSrc, initialySelectedLabel: choosen.label , initialySelectedRes: choosen.res , customSourcePicker: settings.customSourcePicker}, settings, label); - menuButton.el().classList.add('vjs-resolution-button'); + videojs.addClass(menuButton.el(), 'vjs-resolution-button'); player.controlBar.resolutionSwitcher = player.controlBar.el_.insertBefore(menuButton.el_, player.controlBar.getChild('fullscreenToggle').el_); player.controlBar.resolutionSwitcher.dispose = function(){ this.parentNode.removeChild(this); From e1cf38e16c68e7127d79744bf4925ceaf5fe7f96 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sun, 13 Mar 2016 20:06:20 +0100 Subject: [PATCH 27/56] bower version --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 8c8c766..bf63197 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "vjs-resolution-switcher", - "version": "0.3.3", + "version": "0.3.4", "authors": [ "Kasper Moskwiak " ], From 46c88bcc4123fb0a351fe451f7dca09e6b67379e Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sun, 13 Mar 2016 20:06:23 +0100 Subject: [PATCH 28/56] 0.3.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1416436..72ecbcd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "videojs-resolution-switcher", - "version": "0.3.3", + "version": "0.3.4", "main": "./lib/videojs-resolution-switcher.js", "author": { "name": "Kasper Moskwiak", From 92477a26db40a1d51b7f2343f95c97a92f282823 Mon Sep 17 00:00:00 2001 From: Kasper Moskwiak Date: Sun, 13 Mar 2016 20:57:55 +0100 Subject: [PATCH 29/56] youtube tech --- examples/flash.html | 81 +++++++++++++++++++++++++++++ example.html => examples/html5.html | 56 ++------------------ examples/youtube.html | 71 +++++++++++++++++++++++++ lib/videojs-resolution-switcher.js | 78 ++++++++++++++++++++++++--- package.json | 3 +- 5 files changed, 229 insertions(+), 60 deletions(-) create mode 100644 examples/flash.html rename example.html => examples/html5.html (62%) create mode 100644 examples/youtube.html diff --git a/examples/flash.html b/examples/flash.html new file mode 100644 index 0000000..60dfb11 --- /dev/null +++ b/examples/flash.html @@ -0,0 +1,81 @@ + + + + + Video.js Resolution Switcher + + + + + + +
+

+ Use flash +

+
+ + + + + + + + + diff --git a/example.html b/examples/html5.html similarity index 62% rename from example.html rename to examples/html5.html index cdf913e..a987cc4 100644 --- a/example.html +++ b/examples/html5.html @@ -4,8 +4,8 @@ Video.js Resolution Switcher - - + + + + +
+

+ Youtube tech +

+
+ + + + + + + + + + + + \ No newline at end of file diff --git a/lib/videojs-resolution-switcher.js b/lib/videojs-resolution-switcher.js index 7c04c4b..5c678a6 100644 --- a/lib/videojs-resolution-switcher.js +++ b/lib/videojs-resolution-switcher.js @@ -86,7 +86,7 @@ // Probably because of https://github.com/videojs/video-js-swf/issues/124 // If player preload is 'none' and then loadeddata not fired. So, we need timeupdate event for seek handle (timeupdate doesn't work properly with flash) var handleSeekEvent = 'loadeddata'; - if(this.player_.preload() === 'none' && this.player_.techName_ !== 'Flash') { + if(this.player_.techName_ != 'Youtube' && this.player_.preload() === 'none' && this.player_.techName_ !== 'Flash') { handleSeekEvent = 'timeupdate'; } setSourcesSanitized(this.player_, this.src, this.options_.label, customSourcePicker).one(handleSeekEvent, function() { @@ -282,14 +282,76 @@ } return {res: selectedRes, label: selectedLabel, sources: groupedSrc.res[selectedRes]}; } + + function initResolutionForYt(player){ + // Init resolution + player.tech_.ytPlayer.setPlaybackQuality('default'); + + // Capture events + player.tech_.ytPlayer.addEventListener('onPlaybackQualityChange', function(){ + player.trigger('resolutionchange'); + }); + + // We must wait for play event + player.one('play', function(){ + var qualities = player.tech_.ytPlayer.getAvailableQualityLevels(); + // Map youtube qualities names + var _yts = { + "highres": {res: 1080, label: '1080', yt: 'highres'}, + "hd1080": {res: 1080, label: '1080', yt: 'hd1080'}, + "hd720": {res: 720, label: '720', yt: 'hd720'}, + "large": {res: 480, label: '480', yt: 'large'}, + "medium": {res: 360, label: '360', yt: 'medium'}, + "small": {res: 240, label: '240', yt: 'small'}, + "tiny": {res: 144, label: '144', yt: 'tiny'}, + "auto": {res: 0, label: 'auto', yt: 'default'} + } - // Create resolution switcher for videos form tag inside