Skip to content

Commit

Permalink
Guard playlist code
Browse files Browse the repository at this point in the history
Right now the playlist code is very raw.
It tries to do things, trusting JavaScript to fail in the right place.

:shrug:
  • Loading branch information
Lewiscowles1986 committed Nov 9, 2019
1 parent 9c2b67c commit 9657e39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 7 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down Expand Up @@ -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);
}
});
}
});
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 9657e39

Please sign in to comment.