From aad9f723dce54b4667864626d2efcac7e5f7bfcb Mon Sep 17 00:00:00 2001 From: Jonathan Bokobza Date: Mon, 30 May 2016 15:42:29 +0200 Subject: [PATCH 1/4] fix poster for Dailymotion --- es5/videojs-dailymotion.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/es5/videojs-dailymotion.js b/es5/videojs-dailymotion.js index 9f895f6..4767342 100644 --- a/es5/videojs-dailymotion.js +++ b/es5/videojs-dailymotion.js @@ -66,7 +66,7 @@ var Dailymotion = (function (_Tech) { if (typeof this.videoId !== 'undefined') { this.setTimeout(function () { - _this.setPoster('//api.dailymotion.com/video/' + _this.videoId + '?fields=poster_url&ads=false'); + _this.setPoster('https://api.dailymotion.com/video/' + _this.videoId + '?fields=thumbnail_large_url'); }, 100); } @@ -213,8 +213,15 @@ var Dailymotion = (function (_Tech) { }, { key: 'setPoster', value: function setPoster(poster) { - this.poster_ = poster; - this.trigger('posterchange'); + + var baseClass = this; + $.getJSON(poster, function(data) { + // Set the low resolution first + baseClass.poster_ = data.thumbnail_large_url; + console.log(baseClass.poster_); + baseClass.trigger('posterchange'); + }); + } /** From a4755735351ceb6ee2dbbb56884ef89b1e5cb5a4 Mon Sep 17 00:00:00 2001 From: Jonathan Bokobza Date: Mon, 30 May 2016 16:01:26 +0200 Subject: [PATCH 2/4] avoid fatal js error if player is not ready --- es5/videojs-dailymotion.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/es5/videojs-dailymotion.js b/es5/videojs-dailymotion.js index 4767342..cd36c58 100644 --- a/es5/videojs-dailymotion.js +++ b/es5/videojs-dailymotion.js @@ -118,6 +118,16 @@ var Dailymotion = (function (_Tech) { }, { key: 'loadApi', value: function loadApi() { + + var baseObjectLoader = this; + + if (document.getElementById(this.options_.techId) == null) { + setTimeout(function() { + baseObjectLoader.loadApi(); + }, 50); + return null; + } + this.dmPlayer = new DM.player(this.options_.techId, { video: this.videoId, width: this.options_.width, @@ -218,7 +228,6 @@ var Dailymotion = (function (_Tech) { $.getJSON(poster, function(data) { // Set the low resolution first baseClass.poster_ = data.thumbnail_large_url; - console.log(baseClass.poster_); baseClass.trigger('posterchange'); }); From 07784544715364d6646f5110a90bc7b66fca28e3 Mon Sep 17 00:00:00 2001 From: Jonathan Bokobza Date: Mon, 30 May 2016 16:04:16 +0200 Subject: [PATCH 3/4] sync with es5 --- src/videojs-dailymotion.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/videojs-dailymotion.js b/src/videojs-dailymotion.js index 3d46a56..4f76130 100644 --- a/src/videojs-dailymotion.js +++ b/src/videojs-dailymotion.js @@ -41,8 +41,8 @@ class Dailymotion extends Tech { this.videoId = this.parseSrc(options.source.src); if (typeof this.videoId !== 'undefined') { - this.setTimeout(() => { - this.setPoster('//api.dailymotion.com/video/' + this.videoId + '?fields=poster_url&ads=false'); + this.setTimeout(function () { + _this.setPoster('https://api.dailymotion.com/video/' + _this.videoId + '?fields=thumbnail_large_url'); }, 100); } @@ -93,6 +93,16 @@ class Dailymotion extends Tech { } loadApi() { + + var baseObjectLoader = this; + + if (document.getElementById(this.options_.techId) == null) { + setTimeout(function() { + baseObjectLoader.loadApi(); + }, 50); + return null; + } + this.dmPlayer = new DM.player(this.options_.techId, { video: this.videoId, width: this.options_.width, @@ -182,8 +192,12 @@ class Dailymotion extends Tech { } setPoster(poster) { - this.poster_ = poster; - this.trigger('posterchange'); + var baseClass = this; + $.getJSON(poster, function(data) { + // Set the low resolution first + baseClass.poster_ = data.thumbnail_large_url; + baseClass.trigger('posterchange'); + }); } /** From e0f3e416e46e97655dea8be2736952fd9d6982f1 Mon Sep 17 00:00:00 2001 From: Jonathan Bokobza Date: Mon, 30 May 2016 16:35:25 +0200 Subject: [PATCH 4/4] added class vjs-dailymotion to the video container --- es5/videojs-dailymotion.js | 4 ++++ src/videojs-dailymotion.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/es5/videojs-dailymotion.js b/es5/videojs-dailymotion.js index cd36c58..615d1c9 100644 --- a/es5/videojs-dailymotion.js +++ b/es5/videojs-dailymotion.js @@ -57,6 +57,10 @@ var Dailymotion = (function (_Tech) { url: options.source.src }; + setTimeout(function() { + this.el_.parentNode.className += ' vjs-dailymotion'; + }.bind(this)); + // If we are not on a server, don't specify the origin (it will crash) if (window.location.protocol !== 'file:') { this.params.origin = window.location.protocol + '//' + window.location.hostname; diff --git a/src/videojs-dailymotion.js b/src/videojs-dailymotion.js index 4f76130..baa4c53 100644 --- a/src/videojs-dailymotion.js +++ b/src/videojs-dailymotion.js @@ -33,6 +33,10 @@ class Dailymotion extends Tech { url: options.source.src }; + setTimeout(function() { + this.el_.parentNode.className += ' vjs-dailymotion'; + }.bind(this)); + // If we are not on a server, don't specify the origin (it will crash) if (window.location.protocol !== 'file:') { this.params.origin = window.location.protocol + '//' + window.location.hostname;