Setup multiple players
This commit is contained in:
		| @ -1244,6 +1244,29 @@ class Plyr { | ||||
|     static loadSprite(url, id) { | ||||
|         return utils.loadSprite(url, id); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Setup multiple instances | ||||
|      * @param {*} selector | ||||
|      * @param {object} options | ||||
|      */ | ||||
|     static setup(selector, options = {}) { | ||||
|         let targets = null; | ||||
|  | ||||
|         if (utils.is.string(selector)) { | ||||
|             targets = Array.from(document.querySelectorAll(selector)); | ||||
|         } else if (utils.is.nodeList(selector)) { | ||||
|             targets = Array.from(selector); | ||||
|         } else if (utils.is.array(selector)) { | ||||
|             targets = selector.filter(i => utils.is.element(i)); | ||||
|         } | ||||
|  | ||||
|         if (utils.is.empty(targets)) { | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|         return targets.map(t => new Plyr(t, options)); | ||||
|     } | ||||
| } | ||||
|  | ||||
| export default Plyr; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user