UNPKG

@abraham_0101/platzimediaplayer

Version:

50 lines (49 loc) 1.43 kB
"use strict"; exports.__esModule = true; var MediaPlayer = /** @class */ (function () { function MediaPlayer(config) { this.media = config.el; this.plugins = config.plugins || []; this.initPlayer(); this.initPlugins(); } MediaPlayer.prototype.initPlayer = function () { this.container = document.createElement('div'); this.container.style.position = 'relative'; this.media.parentNode.insertBefore(this.container, this.media); this.container.appendChild(this.media); }; MediaPlayer.prototype.initPlugins = function () { var _this = this; this.plugins.forEach(function (plugin) { plugin.run(_this); }); }; MediaPlayer.prototype.play = function () { this.media.play(); }; MediaPlayer.prototype.pause = function () { this.media.pause(); }; MediaPlayer.prototype.muted = function () { this.media.muted = true; }; MediaPlayer.prototype.unmuted = function () { if (this.media.muted) { this.media.muted = false; } else { this.media.muted = true; } }; MediaPlayer.prototype.togglePlay = function () { if (this.media.paused) { this.media.play(); } else { this.media.pause(); } }; return MediaPlayer; }()); exports["default"] = MediaPlayer;