Plugin Directory

Changeset 3103164


Ignore:
Timestamp:
06/15/2024 10:14:37 PM (22 months ago)
Author:
r00tsector
Message:

Update to version 1.0.5 from GitHub

Location:
hls-player
Files:
2 added
6 edited
1 copied

Legend:

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

    r3098170 r3103164  
    66Tested up to: 6.5.4
    77Requires PHP: 8.1
    8 Stable tag: 1.0.4
     8Stable tag: 1.0.5
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0
     
    7575`[hls_player url="https://example.com/external/xxxxxxxxx.m3u8" muted="true"]`
    7676
    77 * **withcredentials**: Disable withCredentials for a single video. The value for this parameter is true by default.
    78 `[hls_player url="https://example.com/external/xxxxxxxxx.m3u8" withcredentials="false"]`
    79 
    80 * **protected**: Disable check active subscription protection for this single video. The value for this parameter is true by default.
    81 `[hls_player url="https://example.com/external/xxxxxxxxx.m3u8" protected="false"]`
    82 
    8377* **captions**: Add captions or subtitles to the video in multiple languages. Provide the captions in the format: `"path/to/captions1.vtt|lang1|label1|default,path/to/captions2.vtt|lang2|label2"`.
    8478provide the lang in two character language code format. For example de-de, en-us
     
    115109
    116110== Changelog ==
     111= 1.0.5=
     112* Added: Support for multiple video players on one post/page.
     113
    117114= 1.0.4=
    118115* Added: Wordpress v6.5.4 compatibility.
  • hls-player/tags/1.0.5/hls-player.php

    r3098170 r3103164  
    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.4
     6 * Version: 1.0.5
    77 * Requires at least: 6.4
    88 * Requires PHP: 8.1
     
    1717}
    1818
    19 define('HLS_PLAYER_VERSION', '1.0.4');
     19define('HLS_PLAYER_VERSION', '1.0.5');
    2020
    2121class HLSPlayer
     
    4040        add_filter('the_content', 'do_shortcode', 11);
    4141
     42        // Add script localization for video instances
     43        add_action('wp_enqueue_scripts', array($this, 'enqueue_hls_player_script'));
    4244    }
    4345
     
    4547    public function enqueue_scripts_and_styles()
    4648    {
    47         wp_enqueue_script('videojs', plugins_url('public/js/video.min.js', __FILE__), array(), $this->plugin_version, false);
    48         wp_enqueue_style('videojs', plugins_url('public/css/video-js.min.css', __FILE__), array(), $this->plugin_version);
     49        if (!is_admin()) {
     50            wp_enqueue_script('videojs', plugins_url('public/js/video.min.js', __FILE__), array(), $this->plugin_version, false);
     51            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        }
    4961    }
    5062
     
    7486
    7587        // Define custom css classes for videojs player
    76         if (!empty($atts['class']))
    77             $class = $atts['class'];
    78         else
    79             $class = 'video-js vjs-fluid';
     88        $class = !empty($atts['class']) ? $atts['class'] : 'video-js vjs-fluid';
    8089
    8190        // Controls
    82         if ($atts['controls'] == 'false')
    83             $controls = '';
    84         else
    85             $controls = ' controls';
     91        $controls = $atts['controls'] == 'false' ? '' : ' controls';
    8692
    8793        // Preload
    88         if ($atts['preload'] == 'metadata')
    89             $preload = ' preload="metadata"';
    90         else if ($atts['preload'] == 'none')
    91             $preload = ' preload="none"';
    92         else
    93             $preload = ' preload="auto"';
     94        $preload = $atts['preload'] == 'metadata' ? ' preload="metadata"' : ($atts['preload'] == 'none' ? ' preload="none"' : ' preload="auto"');
    9495
    9596        // Autoplay
    96         if ($atts['autoplay'] == 'true')
    97             $autoplay = ' autoplay';
    98         else
    99             $autoplay = '';
     97        $autoplay = $atts['autoplay'] == 'true' ? ' autoplay' : '';
    10098
    10199        // Loop
    102         if ($atts['loop'] == 'true')
    103             $loop = ' loop';
    104         else
    105             $loop = '';
     100        $loop = $atts['loop'] == 'true' ? ' loop' : '';
    106101
    107102        // Muted
    108         if ($atts['muted'] == 'true')
    109             $muted = ' muted';
    110         else
    111             $muted = '';
     103        $muted = $atts['muted'] == 'true' ? ' muted' : '';
    112104
    113105        // Poster
    114         if (!empty($atts['poster']))
    115             $poster = ' poster="' . $atts['poster'] . '"';
    116         else
    117             $poster = '';
     106        $poster = !empty($atts['poster']) ? ' poster="' . $atts['poster'] . '"' : '';
    118107
    119108        // Extract the url attribute
     
    172161        );
    173162
     163        if (!isset($GLOBALS['hlsPlayerData'])) {
     164            $GLOBALS['hlsPlayerData'] = array();
     165        }
     166        $GLOBALS['hlsPlayerData'][] = $script_data;
     167
    174168        wp_enqueue_script('hls-player-script', plugins_url('public/js/hls-player.js', __FILE__), array('videojs'), $this->plugin_version, true);
    175         wp_localize_script('hls-player-script', 'hlsPlayerData', $script_data);
    176169
    177170        return $video_html;
  • hls-player/tags/1.0.5/public/js/hls-player.js

    r3095505 r3103164  
    88
    99  onReady(() => {
    10     let player = videojs(hlsPlayerData.video_id);
    11     player.src({
    12       src: hlsPlayerData.src,
    13       type: hlsPlayerData.type,
     10    hlsPlayerData.forEach((playerData) => {
     11      let player = videojs(playerData.video_id);
     12      player.src({
     13        src: playerData.src,
     14        type: playerData.type,
     15      });
     16
     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      });
     29
     30      player.load();
    1431    });
    15 
    16     hlsPlayerData.captions_data.forEach((caption) => {
    17       player.addRemoteTextTrack(
    18         {
    19           kind: "subtitles",
    20           src: caption.src,
    21           srclang: caption.srclang,
    22           label: caption.label,
    23           default: caption.default,
    24         },
    25         false
    26       );
    27     });
    28 
    29     player.load();
    3032  });
    3133})(jQuery);
  • hls-player/trunk/Readme.txt

    r3098170 r3103164  
    66Tested up to: 6.5.4
    77Requires PHP: 8.1
    8 Stable tag: 1.0.4
     8Stable tag: 1.0.5
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0
     
    7575`[hls_player url="https://example.com/external/xxxxxxxxx.m3u8" muted="true"]`
    7676
    77 * **withcredentials**: Disable withCredentials for a single video. The value for this parameter is true by default.
    78 `[hls_player url="https://example.com/external/xxxxxxxxx.m3u8" withcredentials="false"]`
    79 
    80 * **protected**: Disable check active subscription protection for this single video. The value for this parameter is true by default.
    81 `[hls_player url="https://example.com/external/xxxxxxxxx.m3u8" protected="false"]`
    82 
    8377* **captions**: Add captions or subtitles to the video in multiple languages. Provide the captions in the format: `"path/to/captions1.vtt|lang1|label1|default,path/to/captions2.vtt|lang2|label2"`.
    8478provide the lang in two character language code format. For example de-de, en-us
     
    115109
    116110== Changelog ==
     111= 1.0.5=
     112* Added: Support for multiple video players on one post/page.
     113
    117114= 1.0.4=
    118115* Added: Wordpress v6.5.4 compatibility.
  • hls-player/trunk/hls-player.php

    r3098170 r3103164  
    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.4
     6 * Version: 1.0.5
    77 * Requires at least: 6.4
    88 * Requires PHP: 8.1
     
    1717}
    1818
    19 define('HLS_PLAYER_VERSION', '1.0.4');
     19define('HLS_PLAYER_VERSION', '1.0.5');
    2020
    2121class HLSPlayer
     
    4040        add_filter('the_content', 'do_shortcode', 11);
    4141
     42        // Add script localization for video instances
     43        add_action('wp_enqueue_scripts', array($this, 'enqueue_hls_player_script'));
    4244    }
    4345
     
    4547    public function enqueue_scripts_and_styles()
    4648    {
    47         wp_enqueue_script('videojs', plugins_url('public/js/video.min.js', __FILE__), array(), $this->plugin_version, false);
    48         wp_enqueue_style('videojs', plugins_url('public/css/video-js.min.css', __FILE__), array(), $this->plugin_version);
     49        if (!is_admin()) {
     50            wp_enqueue_script('videojs', plugins_url('public/js/video.min.js', __FILE__), array(), $this->plugin_version, false);
     51            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        }
    4961    }
    5062
     
    7486
    7587        // Define custom css classes for videojs player
    76         if (!empty($atts['class']))
    77             $class = $atts['class'];
    78         else
    79             $class = 'video-js vjs-fluid';
     88        $class = !empty($atts['class']) ? $atts['class'] : 'video-js vjs-fluid';
    8089
    8190        // Controls
    82         if ($atts['controls'] == 'false')
    83             $controls = '';
    84         else
    85             $controls = ' controls';
     91        $controls = $atts['controls'] == 'false' ? '' : ' controls';
    8692
    8793        // Preload
    88         if ($atts['preload'] == 'metadata')
    89             $preload = ' preload="metadata"';
    90         else if ($atts['preload'] == 'none')
    91             $preload = ' preload="none"';
    92         else
    93             $preload = ' preload="auto"';
     94        $preload = $atts['preload'] == 'metadata' ? ' preload="metadata"' : ($atts['preload'] == 'none' ? ' preload="none"' : ' preload="auto"');
    9495
    9596        // Autoplay
    96         if ($atts['autoplay'] == 'true')
    97             $autoplay = ' autoplay';
    98         else
    99             $autoplay = '';
     97        $autoplay = $atts['autoplay'] == 'true' ? ' autoplay' : '';
    10098
    10199        // Loop
    102         if ($atts['loop'] == 'true')
    103             $loop = ' loop';
    104         else
    105             $loop = '';
     100        $loop = $atts['loop'] == 'true' ? ' loop' : '';
    106101
    107102        // Muted
    108         if ($atts['muted'] == 'true')
    109             $muted = ' muted';
    110         else
    111             $muted = '';
     103        $muted = $atts['muted'] == 'true' ? ' muted' : '';
    112104
    113105        // Poster
    114         if (!empty($atts['poster']))
    115             $poster = ' poster="' . $atts['poster'] . '"';
    116         else
    117             $poster = '';
     106        $poster = !empty($atts['poster']) ? ' poster="' . $atts['poster'] . '"' : '';
    118107
    119108        // Extract the url attribute
     
    172161        );
    173162
     163        if (!isset($GLOBALS['hlsPlayerData'])) {
     164            $GLOBALS['hlsPlayerData'] = array();
     165        }
     166        $GLOBALS['hlsPlayerData'][] = $script_data;
     167
    174168        wp_enqueue_script('hls-player-script', plugins_url('public/js/hls-player.js', __FILE__), array('videojs'), $this->plugin_version, true);
    175         wp_localize_script('hls-player-script', 'hlsPlayerData', $script_data);
    176169
    177170        return $video_html;
  • hls-player/trunk/public/js/hls-player.js

    r3095505 r3103164  
    88
    99  onReady(() => {
    10     let player = videojs(hlsPlayerData.video_id);
    11     player.src({
    12       src: hlsPlayerData.src,
    13       type: hlsPlayerData.type,
     10    hlsPlayerData.forEach((playerData) => {
     11      let player = videojs(playerData.video_id);
     12      player.src({
     13        src: playerData.src,
     14        type: playerData.type,
     15      });
     16
     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      });
     29
     30      player.load();
    1431    });
    15 
    16     hlsPlayerData.captions_data.forEach((caption) => {
    17       player.addRemoteTextTrack(
    18         {
    19           kind: "subtitles",
    20           src: caption.src,
    21           srclang: caption.srclang,
    22           label: caption.label,
    23           default: caption.default,
    24         },
    25         false
    26       );
    27     });
    28 
    29     player.load();
    3032  });
    3133})(jQuery);
Note: See TracChangeset for help on using the changeset viewer.