From 3395e8df903cdd63e227a377b4b3be77da682aa8 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Mon, 2 Apr 2018 22:40:03 +1000 Subject: HTML5 quality selection --- src/js/utils.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/js/utils.js') diff --git a/src/js/utils.js b/src/js/utils.js index e9687a14..dd1466df 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -586,15 +586,15 @@ const utils = { }, // Trigger event - dispatchEvent(element, type, bubbles, detail) { + dispatchEvent(element, type = '', bubbles = false, detail = {}) { // Bail if no element - if (!utils.is.element(element) || !utils.is.string(type)) { + if (!utils.is.element(element) || utils.is.empty(type)) { return; } // Create and dispatch the event const event = new CustomEvent(type, { - bubbles: utils.is.boolean(bubbles) ? bubbles : false, + bubbles, detail: Object.assign({}, detail, { plyr: utils.is.plyr(this) ? this : null, }), @@ -737,6 +737,15 @@ const utils = { return utils.extend(target, ...sources); }, + // Remove duplicates in an array + dedupe(array) { + if (!utils.is.array(array)) { + return array; + } + + return array.filter((item, index) => array.indexOf(item) === index); + }, + // Get the provider for a given URL getProviderByUrl(url) { // YouTube -- cgit v1.2.3