Changeset 3103168
- Timestamp:
- 06/15/2024 11:52:35 PM (22 months ago)
- Location:
- hls-player
- Files:
-
- 8 edited
- 1 copied
-
tags/1.0.6 (copied) (copied from hls-player/trunk)
-
tags/1.0.6/Readme.txt (modified) (2 diffs)
-
tags/1.0.6/hls-player.php (modified) (6 diffs)
-
tags/1.0.6/public/js/hls-player.js (modified) (1 diff)
-
tags/1.0.6/public/js/hls-player.min.js (modified) (1 diff)
-
trunk/Readme.txt (modified) (2 diffs)
-
trunk/hls-player.php (modified) (6 diffs)
-
trunk/public/js/hls-player.js (modified) (1 diff)
-
trunk/public/js/hls-player.min.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
hls-player/tags/1.0.6/Readme.txt
r3103164 r3103168 6 6 Tested up to: 6.5.4 7 7 Requires PHP: 8.1 8 Stable tag: 1.0. 58 Stable tag: 1.0.6 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0 … … 109 109 110 110 == Changelog == 111 = 1.0.5= 111 = 1.0.6 = 112 * Improved: Compatibility for multiple themes and plugins. 113 114 = 1.0.5 = 112 115 * Added: Support for multiple video players on one post/page. 113 116 114 = 1.0.4 =117 = 1.0.4 = 115 118 * Added: Wordpress v6.5.4 compatibility. 116 119 -
hls-player/tags/1.0.6/hls-player.php
r3103164 r3103168 4 4 * Plugin URI: https://github.com/root-sector/wordpress-plugin-hls-player-free 5 5 * Description: HLS Player is a simple, lightweight HTTP Live Streaming player for WordPress. Leveraging video.js, the leading open-source HTML5 player, it enables effortless embedding of both responsive and fixed-width .m3u8 or .mpd HLS videos into posts and pages. 6 * Version: 1.0. 56 * Version: 1.0.6 7 7 * Requires at least: 6.4 8 8 * Requires PHP: 8.1 … … 17 17 } 18 18 19 define('HLS_PLAYER_VERSION', '1.0. 5');19 define('HLS_PLAYER_VERSION', '1.0.6'); 20 20 21 21 class HLSPlayer … … 39 39 add_filter('the_excerpt', 'do_shortcode', 11); 40 40 add_filter('the_content', 'do_shortcode', 11); 41 42 // Add script localization for video instances43 add_action('wp_enqueue_scripts', array($this, 'enqueue_hls_player_script'));44 41 } 45 42 … … 50 47 wp_enqueue_script('videojs', plugins_url('public/js/video.min.js', __FILE__), array(), $this->plugin_version, false); 51 48 wp_enqueue_style('videojs', plugins_url('public/css/video-js.min.css', __FILE__), array(), $this->plugin_version); 52 }53 }54 55 public function enqueue_hls_player_script()56 {57 if (!is_admin() && isset($GLOBALS['hlsPlayerData']) && !empty($GLOBALS['hlsPlayerData'])) {58 wp_enqueue_script('hls-player-script', plugins_url('public/js/hls-player.min.js', __FILE__), array('videojs'), $this->plugin_version, true);59 wp_localize_script('hls-player-script', 'hlsPlayerData', $GLOBALS['hlsPlayerData']);60 49 } 61 50 } … … 83 72 84 73 // Generate a unique id for the video element 85 $video_id = uniqid('video -');74 $video_id = uniqid('video_'); 86 75 87 76 // Define custom css classes for videojs player … … 156 145 $script_data = array( 157 146 'video_id' => $video_id, 158 'src' => $url,147 'src' => esc_url_raw($url), 159 148 'type' => $type, 160 149 'captions_data' => $captions_data, 161 150 ); 162 151 163 if (!isset($GLOBALS['hlsPlayerData'])) { 164 $GLOBALS['hlsPlayerData'] = array(); 165 } 166 $GLOBALS['hlsPlayerData'][] = $script_data; 152 $encoded_data = base64_encode(json_encode($script_data)); 153 $inline_script = "var hlsPlayerData_{$video_id} = '{$encoded_data}';"; 167 154 168 wp_enqueue_script('hls-player-script', plugins_url('public/js/hls-player.js', __FILE__), array('videojs'), $this->plugin_version, true); 155 // Enqueue the main script and add the inline script 156 wp_enqueue_script('hls-player-script', plugins_url('public/js/hls-player.min.js', __FILE__), array('videojs'), $this->plugin_version, true); 157 wp_add_inline_script('hls-player-script', $inline_script); 169 158 170 159 return $video_html; -
hls-player/tags/1.0.6/public/js/hls-player.js
r3103164 r3103168 8 8 9 9 onReady(() => { 10 hlsPlayerData.forEach((playerData) => { 11 let player = videojs(playerData.video_id); 12 player.src({ 13 src: playerData.src, 14 type: playerData.type, 15 }); 10 $("video.video-js").each(function () { 11 var videoId = $(this).attr("id"); 12 var localizedName = "hlsPlayerData_" + videoId; 16 13 17 playerData.captions_data.forEach((caption) => { 18 player.addRemoteTextTrack( 19 { 20 kind: "subtitles", 21 src: caption.src, 22 srclang: caption.srclang, 23 label: caption.label, 24 default: caption.default, 25 }, 26 false 27 ); 28 }); 14 if (typeof window[localizedName] !== "undefined") { 15 // Decode base64-encoded data 16 let playerData = JSON.parse(atob(window[localizedName])); 29 17 30 player.load(); 18 let player = videojs(playerData.video_id); 19 player.src({ 20 src: playerData.src, 21 type: playerData.type, 22 }); 23 24 playerData.captions_data.forEach((caption) => { 25 player.addRemoteTextTrack( 26 { 27 kind: "subtitles", 28 src: caption.src, 29 srclang: caption.srclang, 30 label: caption.label, 31 default: caption.default, 32 }, 33 false 34 ); 35 }); 36 37 player.load(); 38 } else { 39 console.log("No localized data found for " + localizedName); 40 } 31 41 }); 32 42 }); -
hls-player/tags/1.0.6/public/js/hls-player.min.js
r3103164 r3103168 1 !function($){"use strict";var callback;callback=()=>{ hlsPlayerData.forEach((playerData=>{let player=videojs(playerData.video_id);player.src({src:playerData.src,type:playerData.type}),playerData.captions_data.forEach((caption=>{player.addRemoteTextTrack({kind:"subtitles",src:caption.src,srclang:caption.srclang,label:caption.label,default:caption.default},!1)})),player.load()}))},"loading"!=document.readyState?callback():document.addEventListener("DOMContentLoaded",callback)}(jQuery);1 !function($){"use strict";var callback;callback=()=>{$("video.video-js").each((function(){var localizedName="hlsPlayerData_"+$(this).attr("id");if(void 0!==window[localizedName]){let playerData=JSON.parse(atob(window[localizedName])),player=videojs(playerData.video_id);player.src({src:playerData.src,type:playerData.type}),playerData.captions_data.forEach((caption=>{player.addRemoteTextTrack({kind:"subtitles",src:caption.src,srclang:caption.srclang,label:caption.label,default:caption.default},!1)})),player.load()}else console.log("No localized data found for "+localizedName)}))},"loading"!=document.readyState?callback():document.addEventListener("DOMContentLoaded",callback)}(jQuery); -
hls-player/trunk/Readme.txt
r3103164 r3103168 6 6 Tested up to: 6.5.4 7 7 Requires PHP: 8.1 8 Stable tag: 1.0. 58 Stable tag: 1.0.6 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0 … … 109 109 110 110 == Changelog == 111 = 1.0.5= 111 = 1.0.6 = 112 * Improved: Compatibility for multiple themes and plugins. 113 114 = 1.0.5 = 112 115 * Added: Support for multiple video players on one post/page. 113 116 114 = 1.0.4 =117 = 1.0.4 = 115 118 * Added: Wordpress v6.5.4 compatibility. 116 119 -
hls-player/trunk/hls-player.php
r3103164 r3103168 4 4 * Plugin URI: https://github.com/root-sector/wordpress-plugin-hls-player-free 5 5 * Description: HLS Player is a simple, lightweight HTTP Live Streaming player for WordPress. Leveraging video.js, the leading open-source HTML5 player, it enables effortless embedding of both responsive and fixed-width .m3u8 or .mpd HLS videos into posts and pages. 6 * Version: 1.0. 56 * Version: 1.0.6 7 7 * Requires at least: 6.4 8 8 * Requires PHP: 8.1 … … 17 17 } 18 18 19 define('HLS_PLAYER_VERSION', '1.0. 5');19 define('HLS_PLAYER_VERSION', '1.0.6'); 20 20 21 21 class HLSPlayer … … 39 39 add_filter('the_excerpt', 'do_shortcode', 11); 40 40 add_filter('the_content', 'do_shortcode', 11); 41 42 // Add script localization for video instances43 add_action('wp_enqueue_scripts', array($this, 'enqueue_hls_player_script'));44 41 } 45 42 … … 50 47 wp_enqueue_script('videojs', plugins_url('public/js/video.min.js', __FILE__), array(), $this->plugin_version, false); 51 48 wp_enqueue_style('videojs', plugins_url('public/css/video-js.min.css', __FILE__), array(), $this->plugin_version); 52 }53 }54 55 public function enqueue_hls_player_script()56 {57 if (!is_admin() && isset($GLOBALS['hlsPlayerData']) && !empty($GLOBALS['hlsPlayerData'])) {58 wp_enqueue_script('hls-player-script', plugins_url('public/js/hls-player.min.js', __FILE__), array('videojs'), $this->plugin_version, true);59 wp_localize_script('hls-player-script', 'hlsPlayerData', $GLOBALS['hlsPlayerData']);60 49 } 61 50 } … … 83 72 84 73 // Generate a unique id for the video element 85 $video_id = uniqid('video -');74 $video_id = uniqid('video_'); 86 75 87 76 // Define custom css classes for videojs player … … 156 145 $script_data = array( 157 146 'video_id' => $video_id, 158 'src' => $url,147 'src' => esc_url_raw($url), 159 148 'type' => $type, 160 149 'captions_data' => $captions_data, 161 150 ); 162 151 163 if (!isset($GLOBALS['hlsPlayerData'])) { 164 $GLOBALS['hlsPlayerData'] = array(); 165 } 166 $GLOBALS['hlsPlayerData'][] = $script_data; 152 $encoded_data = base64_encode(json_encode($script_data)); 153 $inline_script = "var hlsPlayerData_{$video_id} = '{$encoded_data}';"; 167 154 168 wp_enqueue_script('hls-player-script', plugins_url('public/js/hls-player.js', __FILE__), array('videojs'), $this->plugin_version, true); 155 // Enqueue the main script and add the inline script 156 wp_enqueue_script('hls-player-script', plugins_url('public/js/hls-player.min.js', __FILE__), array('videojs'), $this->plugin_version, true); 157 wp_add_inline_script('hls-player-script', $inline_script); 169 158 170 159 return $video_html; -
hls-player/trunk/public/js/hls-player.js
r3103164 r3103168 8 8 9 9 onReady(() => { 10 hlsPlayerData.forEach((playerData) => { 11 let player = videojs(playerData.video_id); 12 player.src({ 13 src: playerData.src, 14 type: playerData.type, 15 }); 10 $("video.video-js").each(function () { 11 var videoId = $(this).attr("id"); 12 var localizedName = "hlsPlayerData_" + videoId; 16 13 17 playerData.captions_data.forEach((caption) => { 18 player.addRemoteTextTrack( 19 { 20 kind: "subtitles", 21 src: caption.src, 22 srclang: caption.srclang, 23 label: caption.label, 24 default: caption.default, 25 }, 26 false 27 ); 28 }); 14 if (typeof window[localizedName] !== "undefined") { 15 // Decode base64-encoded data 16 let playerData = JSON.parse(atob(window[localizedName])); 29 17 30 player.load(); 18 let player = videojs(playerData.video_id); 19 player.src({ 20 src: playerData.src, 21 type: playerData.type, 22 }); 23 24 playerData.captions_data.forEach((caption) => { 25 player.addRemoteTextTrack( 26 { 27 kind: "subtitles", 28 src: caption.src, 29 srclang: caption.srclang, 30 label: caption.label, 31 default: caption.default, 32 }, 33 false 34 ); 35 }); 36 37 player.load(); 38 } else { 39 console.log("No localized data found for " + localizedName); 40 } 31 41 }); 32 42 }); -
hls-player/trunk/public/js/hls-player.min.js
r3103164 r3103168 1 !function($){"use strict";var callback;callback=()=>{ hlsPlayerData.forEach((playerData=>{let player=videojs(playerData.video_id);player.src({src:playerData.src,type:playerData.type}),playerData.captions_data.forEach((caption=>{player.addRemoteTextTrack({kind:"subtitles",src:caption.src,srclang:caption.srclang,label:caption.label,default:caption.default},!1)})),player.load()}))},"loading"!=document.readyState?callback():document.addEventListener("DOMContentLoaded",callback)}(jQuery);1 !function($){"use strict";var callback;callback=()=>{$("video.video-js").each((function(){var localizedName="hlsPlayerData_"+$(this).attr("id");if(void 0!==window[localizedName]){let playerData=JSON.parse(atob(window[localizedName])),player=videojs(playerData.video_id);player.src({src:playerData.src,type:playerData.type}),playerData.captions_data.forEach((caption=>{player.addRemoteTextTrack({kind:"subtitles",src:caption.src,srclang:caption.srclang,label:caption.label,default:caption.default},!1)})),player.load()}else console.log("No localized data found for "+localizedName)}))},"loading"!=document.readyState?callback():document.addEventListener("DOMContentLoaded",callback)}(jQuery);
Note: See TracChangeset
for help on using the changeset viewer.