From 87721585c1b81836d720aea2530124f8ac63a3b8 Mon Sep 17 00:00:00 2001 From: Daniel Neto Date: Fri, 30 Jun 2023 11:41:25 -0300 Subject: [PATCH] videojs update --- plugin/NextButton/script.js | 42 ++++++++++--------- plugin/PlayLists/player.php | 25 ++++++----- plugin/PlayLists/playerButton.js | 18 ++++---- plugin/PlayerSkins/autoplayButton.js | 19 ++++----- plugin/PlayerSkins/epgButton.js | 16 +++---- plugin/PlayerSkins/logo.js | 16 +++---- plugin/PlayerSkins/loopbutton.js | 15 ++++--- plugin/PlayerSkins/shareButton.js | 18 ++++---- plugin/TheaterButton/addButton.js | 17 ++++---- .../videojs.persistvolume.js | 2 +- 10 files changed, 95 insertions(+), 93 deletions(-) diff --git a/plugin/NextButton/script.js b/plugin/NextButton/script.js index 8463337ea5..efbf2e640a 100644 --- a/plugin/NextButton/script.js +++ b/plugin/NextButton/script.js @@ -1,24 +1,26 @@ // Extend default $(document).ready(function () { - setTimeout(function(){ if(typeof player == 'undefined'){player = videojs(videoJsId);} + setTimeout(function() { + if(typeof player == 'undefined') { + player = videojs(videoJsId); + } -var Button = videojs.getComponent('Button'); -var nextButton = videojs.extend(Button, { - //constructor: function(player, options) { - constructor: function () { - Button.apply(this, arguments); - //this.addClass('vjs-chapters-button'); - this.addClass('next-button'); - this.addClass('vjs-button-fa-size'); - this.controlText("Next"); - }, - handleClick: function () { - document.location = autoPlayVideoURL; - } + var Button = videojs.getComponent('Button'); + + class NextButton extends Button { + constructor() { + super(...arguments); + this.addClass('next-button'); + this.addClass('vjs-button-fa-size'); + this.controlText("Next"); + } + handleClick() { + document.location = autoPlayVideoURL; + } + } + + // Register the new component + videojs.registerComponent('NextButton', NextButton); + player.getChild('controlBar').addChild('NextButton', {}, getPlayerButtonIndex('PlayToggle')+1); + }, 30); }); - -// Register the new component -videojs.registerComponent('nextButton', nextButton); -player.getChild('controlBar').addChild('nextButton', {}, getPlayerButtonIndex('PlayToggle')+1); - - }, 30); }); \ No newline at end of file diff --git a/plugin/PlayLists/player.php b/plugin/PlayLists/player.php index 01f3f64439..5e7b8f7585 100644 --- a/plugin/PlayLists/player.php +++ b/plugin/PlayLists/player.php @@ -233,24 +233,27 @@ $name = $plp->getName(); } }); setTimeout(function () { + if (typeof player == 'undefined') { + player = videojs(videoJsId); + } + var Button = videojs.getComponent('Button'); - var nextButton = videojs.extend(Button, { - //constructor: function(player, options) { - constructor: function () { - Button.apply(this, arguments); - //this.addClass('vjs-chapters-button'); + + class NextButton extends Button { + constructor() { + super(...arguments); this.addClass('next-button'); this.addClass('vjs-button-fa-size'); this.controlText("Next"); - }, - handleClick: function () { - player.playlist.next(); } - }); + handleClick() { + document.location = autoPlayVideoURL; + } + } // Register the new component - videojs.registerComponent('nextButton', nextButton); - player.getChild('controlBar').addChild('nextButton', {}, getPlayerButtonIndex('PlayToggle') + 1); + videojs.registerComponent('NextButton', NextButton); + player.getChild('controlBar').addChild('NextButton', {}, getPlayerButtonIndex('PlayToggle') + 1); }, 30); }); diff --git a/plugin/PlayLists/playerButton.js b/plugin/PlayLists/playerButton.js index 3121a64150..079002300c 100644 --- a/plugin/PlayLists/playerButton.js +++ b/plugin/PlayLists/playerButton.js @@ -1,20 +1,20 @@ var Button = videojs.getComponent('Button'); -var playListProgramButton = videojs.extend(Button, { - //constructor: function(player, options) { - constructor: function () { - Button.apply(this, arguments); +class PlayListProgramButton extends Button { + constructor() { + super(...arguments); this.addClass('playListProgram-button'); this.controlText("playListProgram"); - }, - handleClick: function () { + } + + handleClick() { console.log('playListProgramButton clicked'); $('#playListHolder').fadeToggle(); } -}); +} -videojs.registerComponent('playListProgramButton', playListProgramButton); -player.getChild('controlBar').addChild('playListProgramButton', {}, getPlayerButtonIndex('fullscreenToggle') - 1); +videojs.registerComponent('PlayListProgramButton', PlayListProgramButton); +player.getChild('controlBar').addChild('PlayListProgramButton', {}, getPlayerButtonIndex('fullscreenToggle') - 1); function playListFadeIn() { $('#playListHolder').fadeIn(); diff --git a/plugin/PlayerSkins/autoplayButton.js b/plugin/PlayerSkins/autoplayButton.js index 950494f49b..b5d5aaab9a 100644 --- a/plugin/PlayerSkins/autoplayButton.js +++ b/plugin/PlayerSkins/autoplayButton.js @@ -1,14 +1,13 @@ var Button = videojs.getComponent('Button'); -var autoplayButton = videojs.extend(Button, { - //constructor: function(player, options) { - constructor: function () { - Button.apply(this, arguments); +class AutoplayButton extends Button { + constructor() { + super(...arguments); this.addClass('autoplay-button'); this.controlText("autoplay"); setTimeout(function(){avideoTooltip(".autoplay-button","Autoplay");},1000); - }, - handleClick: function () { + } + handleClick() { console.log('autoplayButton clicked'); if($('.autoplay-button').hasClass('checked')){ disableAutoPlay(); @@ -16,8 +15,8 @@ var autoplayButton = videojs.extend(Button, { enableAutoPlay(); } } -}); +} -videojs.registerComponent('autoplayButton', autoplayButton); -player.getChild('controlBar').addChild('autoplayButton', {}, getPlayerButtonIndex('fullscreenToggle') - 1); -checkAutoPlay(); \ No newline at end of file +videojs.registerComponent('AutoplayButton', AutoplayButton); +player.getChild('controlBar').addChild('AutoplayButton', {}, getPlayerButtonIndex('fullscreenToggle') - 1); +checkAutoPlay(); diff --git a/plugin/PlayerSkins/epgButton.js b/plugin/PlayerSkins/epgButton.js index 217ac0a321..1eb10325ba 100644 --- a/plugin/PlayerSkins/epgButton.js +++ b/plugin/PlayerSkins/epgButton.js @@ -1,20 +1,20 @@ var Button = videojs.getComponent('Button'); -var EPGButton = videojs.extend(Button, { - //constructor: function(player, options) { - constructor: function () { - Button.apply(this, arguments); +class EPGButton extends Button { + constructor() { + super(...arguments); this.addClass('EPG-button'); this.controlText("TV Guide"); setTimeout(function(){avideoTooltip(".EPG-button","TV Guide");},1000); - }, - handleClick: function () { + } + + handleClick() { var url = webSiteRootURL+'plugin/PlayerSkins/epg.php'; url = addQueryStringParameter(url, 'videos_id', mediaId); console.log('epg clicked'); avideoModalIframeFullTransparent(url); } -}); +} videojs.registerComponent('EPGButton', EPGButton); -player.getChild('controlBar').addChild('EPGButton', {}, getPlayerButtonIndex('fullscreenToggle') - 1); \ No newline at end of file +player.getChild('controlBar').addChild('EPGButton', {}, getPlayerButtonIndex('fullscreenToggle') - 1); diff --git a/plugin/PlayerSkins/logo.js b/plugin/PlayerSkins/logo.js index 0894867c18..81300dbfaa 100644 --- a/plugin/PlayerSkins/logo.js +++ b/plugin/PlayerSkins/logo.js @@ -2,17 +2,17 @@ $(document).ready(function () { var Button = videojs.getComponent('Button'); - var Logo = videojs.extend(Button, { - //constructor: function(player, options) { - constructor: function () { - Button.apply(this, arguments); + class Logo extends Button { + constructor() { + super(...arguments); this.addClass('player-logo'); this.controlText(PlayerSkinLogoTitle); - }, - handleClick: function () { + } + + handleClick() { window.open(webSiteRootURL, '_blank'); } - }); + } videojs.registerComponent('Logo', Logo); if (player.getChild('controlBar').getChild('PictureInPictureToggle')) { @@ -20,4 +20,4 @@ $(document).ready(function () { } else { player.getChild('controlBar').addChild('Logo', {}, getPlayerButtonIndex('fullscreenToggle') - 1); } -}); \ No newline at end of file +}); diff --git a/plugin/PlayerSkins/loopbutton.js b/plugin/PlayerSkins/loopbutton.js index 010a2fec75..2b18dc3634 100644 --- a/plugin/PlayerSkins/loopbutton.js +++ b/plugin/PlayerSkins/loopbutton.js @@ -1,9 +1,8 @@ var Button = videojs.getComponent('Button'); -var LoopButton = videojs.extend(Button, { - //constructor: function(player, options) { - constructor: function () { - Button.apply(this, arguments); +class LoopButton extends Button { + constructor() { + super(...arguments); this.addClass('loop-button'); if (!isPlayerLoop()) { this.addClass('loop-disabled-button'); @@ -11,11 +10,11 @@ var LoopButton = videojs.extend(Button, { this.addClass('fa-spin'); } this.controlText("Loop"); - }, - handleClick: function () { + } + handleClick() { tooglePlayerLoop(); } -}); +} videojs.registerComponent('LoopButton', LoopButton); -player.getChild('controlBar').addChild('LoopButton', {}, 0); \ No newline at end of file +player.getChild('controlBar').addChild('LoopButton', {}, 0); diff --git a/plugin/PlayerSkins/shareButton.js b/plugin/PlayerSkins/shareButton.js index 43eb354b49..e4db9ed3dc 100644 --- a/plugin/PlayerSkins/shareButton.js +++ b/plugin/PlayerSkins/shareButton.js @@ -1,18 +1,18 @@ var Button = videojs.getComponent('Button'); -var socialButton = videojs.extend(Button, { - //constructor: function(player, options) { - constructor: function () { - Button.apply(this, arguments); +class SocialButton extends Button { + constructor() { + super(...arguments); this.addClass('social-button'); this.controlText("social"); setTimeout(function(){avideoTooltip(".social-button","Share");},1000); - }, - handleClick: function () { + } + + handleClick() { console.log('socialButton clicked'); tooglePlayersocial(); } -}); +} -videojs.registerComponent('socialButton', socialButton); -player.getChild('controlBar').addChild('socialButton', {}, getPlayerButtonIndex('fullscreenToggle') - 1); \ No newline at end of file +videojs.registerComponent('SocialButton', SocialButton); +player.getChild('controlBar').addChild('SocialButton', {}, getPlayerButtonIndex('fullscreenToggle') - 1); diff --git a/plugin/TheaterButton/addButton.js b/plugin/TheaterButton/addButton.js index eed5cc2c97..108b447e5d 100644 --- a/plugin/TheaterButton/addButton.js +++ b/plugin/TheaterButton/addButton.js @@ -1,10 +1,10 @@ $(document).ready(function () { var Button = videojs.getComponent('Button'); -var Theater = videojs.extend(Button, { - //constructor: function(player, options) { - constructor: function () { - Button.apply(this, arguments); + +class Theater extends Button { + constructor() { + super(...arguments); if(isCompressed){ this.addClass('ypt-expand'); this.controlText("Switch to Compressed Mode"); @@ -16,14 +16,13 @@ var Theater = videojs.extend(Button, { this.addClass('hidden-sm'); this.addClass('hidden-xs'); $(this).attr('id', 'avideoTheaterButton'); - }, - handleClick: function () { + } + + handleClick() { toogleEC(); } -}); +} // Register the new component and set the right location as FF is not having a PIP button. videojs.registerComponent('Theater', Theater); }); - - diff --git a/view/js/videojs-persistvolume/videojs.persistvolume.js b/view/js/videojs-persistvolume/videojs.persistvolume.js index 017faeeca8..610b348f7a 100644 --- a/view/js/videojs-persistvolume/videojs.persistvolume.js +++ b/view/js/videojs-persistvolume/videojs.persistvolume.js @@ -118,6 +118,6 @@ } }; - vjs.plugin("persistvolume", volumePersister); + vjs.registerPlugin("persistvolume", volumePersister); }); \ No newline at end of file