Plugin Directory

Changeset 3103168


Ignore:
Timestamp:
06/15/2024 11:52:35 PM (22 months ago)
Author:
r00tsector
Message:

Update to version 1.0.6 from GitHub

Location:
hls-player
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • hls-player/tags/1.0.6/Readme.txt

    r3103164 r3103168  
    66Tested up to: 6.5.4
    77Requires PHP: 8.1
    8 Stable tag: 1.0.5
     8Stable tag: 1.0.6
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0
     
    109109
    110110== Changelog ==
    111 = 1.0.5=
     111= 1.0.6 =
     112* Improved: Compatibility for multiple themes and plugins.
     113
     114= 1.0.5 =
    112115* Added: Support for multiple video players on one post/page.
    113116
    114 = 1.0.4=
     117= 1.0.4 =
    115118* Added: Wordpress v6.5.4 compatibility.
    116119
  • hls-player/tags/1.0.6/hls-player.php

    r3103164 r3103168  
    44 * Plugin URI: https://github.com/root-sector/wordpress-plugin-hls-player-free
    55 * 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.5
     6 * Version: 1.0.6
    77 * Requires at least: 6.4
    88 * Requires PHP: 8.1
     
    1717}
    1818
    19 define('HLS_PLAYER_VERSION', '1.0.5');
     19define('HLS_PLAYER_VERSION', '1.0.6');
    2020
    2121class HLSPlayer
     
    3939        add_filter('the_excerpt', 'do_shortcode', 11);
    4040        add_filter('the_content', 'do_shortcode', 11);
    41 
    42         // Add script localization for video instances
    43         add_action('wp_enqueue_scripts', array($this, 'enqueue_hls_player_script'));
    4441    }
    4542
     
    5047            wp_enqueue_script('videojs', plugins_url('public/js/video.min.js', __FILE__), array(), $this->plugin_version, false);
    5148            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']);
    6049        }
    6150    }
     
    8372
    8473        // Generate a unique id for the video element
    85         $video_id = uniqid('video-');
     74        $video_id = uniqid('video_');
    8675
    8776        // Define custom css classes for videojs player
     
    156145        $script_data = array(
    157146            'video_id' => $video_id,
    158             'src' => $url,
     147            'src' => esc_url_raw($url),
    159148            'type' => $type,
    160149            'captions_data' => $captions_data,
    161150        );
    162151
    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}';";
    167154
    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);
    169158
    170159        return $video_html;
  • hls-player/tags/1.0.6/public/js/hls-player.js

    r3103164 r3103168  
    88
    99  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;
    1613
    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]));
    2917
    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      }
    3141    });
    3242  });
  • 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  
    66Tested up to: 6.5.4
    77Requires PHP: 8.1
    8 Stable tag: 1.0.5
     8Stable tag: 1.0.6
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0
     
    109109
    110110== Changelog ==
    111 = 1.0.5=
     111= 1.0.6 =
     112* Improved: Compatibility for multiple themes and plugins.
     113
     114= 1.0.5 =
    112115* Added: Support for multiple video players on one post/page.
    113116
    114 = 1.0.4=
     117= 1.0.4 =
    115118* Added: Wordpress v6.5.4 compatibility.
    116119
  • hls-player/trunk/hls-player.php

    r3103164 r3103168  
    44 * Plugin URI: https://github.com/root-sector/wordpress-plugin-hls-player-free
    55 * 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.5
     6 * Version: 1.0.6
    77 * Requires at least: 6.4
    88 * Requires PHP: 8.1
     
    1717}
    1818
    19 define('HLS_PLAYER_VERSION', '1.0.5');
     19define('HLS_PLAYER_VERSION', '1.0.6');
    2020
    2121class HLSPlayer
     
    3939        add_filter('the_excerpt', 'do_shortcode', 11);
    4040        add_filter('the_content', 'do_shortcode', 11);
    41 
    42         // Add script localization for video instances
    43         add_action('wp_enqueue_scripts', array($this, 'enqueue_hls_player_script'));
    4441    }
    4542
     
    5047            wp_enqueue_script('videojs', plugins_url('public/js/video.min.js', __FILE__), array(), $this->plugin_version, false);
    5148            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']);
    6049        }
    6150    }
     
    8372
    8473        // Generate a unique id for the video element
    85         $video_id = uniqid('video-');
     74        $video_id = uniqid('video_');
    8675
    8776        // Define custom css classes for videojs player
     
    156145        $script_data = array(
    157146            'video_id' => $video_id,
    158             'src' => $url,
     147            'src' => esc_url_raw($url),
    159148            'type' => $type,
    160149            'captions_data' => $captions_data,
    161150        );
    162151
    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}';";
    167154
    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);
    169158
    170159        return $video_html;
  • hls-player/trunk/public/js/hls-player.js

    r3103164 r3103168  
    88
    99  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;
    1613
    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]));
    2917
    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      }
    3141    });
    3242  });
  • 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.