From 9657e3988fd4ed59a61882081dcaa74def70c264 Mon Sep 17 00:00:00 2001 From: Lewis Cowles Date: Sat, 9 Nov 2019 16:01:44 +0000 Subject: [PATCH] Guard playlist code Right now the playlist code is very raw. It tries to do things, trusting JavaScript to fail in the right place. :shrug: --- index.php | 11 +++++++---- readme.txt | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/index.php b/index.php index 13eef64..632bf2c 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: Media Playback Speed * Description: Appends playback buttons to the Media Player. Updated original by Daron Spence. * Author: LewisCowles - * Version: 1.0.6 + * Version: 1.0.7 */ add_action( 'wp_footer', function(){ @@ -52,9 +52,12 @@ container.parentNode.insertBefore(buttons.cloneNode(true), container.nextSibling); mediaTag.addEventListener('loadedmetadata', function(e) { - var activeSpeed = e.target.closest('.wp-playlist').querySelector('.mejs-container .playback-rate-button.mejs-active'); - rate = activeSpeed.dataset.value; - e.target.setPlaybackRate(rate); + var playlist = e.target.closest('.wp-playlist'); + if(playlist) { + var activeSpeed = playlist.querySelector('.mejs-container .playback-rate-button.mejs-active'), + rate = activeSpeed.dataset.value; + e.target.setPlaybackRate(rate); + } }); } }); diff --git a/readme.txt b/readme.txt index c46a710..b8c2a0c 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: frontend,media,streaming,aria,mediaelementjs,html5,video,audio,playback,sp Requires at least: 4.0 Tested up to: 5.2.2 Requires PHP: 5.6 -Stable tag: 1.0.6 +Stable tag: 1.0.7 License: GPL-3.0 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -37,6 +37,9 @@ Please feel free to [suggest](https://github.com/CODESIGN2/media-playback-speed/ Download and extract the zip file or clone this repo to your WordPress plugins directory. Alternatively use the plugin directory to find and install this plugin. == Changelog == += 1.0.7 = +* guard to prevent errors + = 1.0.6 = * change of DOM event