@bradmax/player-ng
Version:
Bradmax Player Angular module.
273 lines (263 loc) • 11.9 kB
JavaScript
/* @bradmax/player-ng v0.1.2 */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@bradmax/player/version'), require('tslib'), require('@bradmax/player/mole'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('bradmax-player-ng-mole', ['exports', '@angular/core', '@bradmax/player/version', 'tslib', '@bradmax/player/mole', '@angular/common'], factory) :
(factory((global.bradmax = global.bradmax || {}, global.bradmax.player = global.bradmax.player || {}, global.bradmax.player.ng = global.bradmax.player.ng || {}, global.bradmax.player.ng.mole = {}),global.ng.core,global.bradmax.player.version,global.tslib,global.bradmax,global.ng.common));
}(this, (function (exports,core,version,tslib,mole,common) { 'use strict';
/**
* @license
* _ _
* | | | |
* | |__ _ __ __ _ __| |_ __ ___ __ ___ __
* | '_ \| '__/ _` |/ _` | '_ ` _ \ / _` \ \/ /
* | |_) | | | (_| | (_| | | | | | | (_| |> <
* |_.__/|_| \__,_|\__,_|_| |_| |_|\__,_/_/\_\
*
* Bradmax Player
* bradmax.com
*/
var EmbederServiceCounter = -1;
var EmbederService = (function () {
function EmbederService() {
var _this = this;
this.debug = false;
this.isInitialized = false;
this.name = null;
this.version = version.BRADMAX_PLAYER_VERSION;
this.nativeElement = null;
this.player = null;
this.api = null;
this.onPlaying = new core.EventEmitter();
this.onCurrentTimeChange = new core.EventEmitter();
this.onComplete = new core.EventEmitter();
this.globalConfig = null;
this.handleCurrentTimeChange = function (e) {
if (_this.debug)
console.log(EmbederService.name + '.handleCurrentTimeChange(', e, ')');
_this.onCurrentTimeChange.emit(e.data);
};
this.handlePlaying = function (e) {
if (_this.debug)
console.log(EmbederService.name + '.handlePlaying(', e, ')');
_this.onPlaying.emit(e.data);
};
this.handleComplete = function (e) {
if (_this.debug)
console.log(EmbederService.name + '.handleComplete(', e, ')');
_this.onComplete.emit(e.data);
};
EmbederServiceCounter++;
if (this.debug)
console.debug(EmbederService.name + '.new(counter:' + EmbederServiceCounter + ')');
this.isInitialized = false;
}
EmbederService.prototype.setup = function (element) {
this.nativeElement = element;
if (this.debug)
console.log(EmbederService.name + '.setup(', this.nativeElement, ')');
};
EmbederService.prototype.create = function (config) {
this.clean();
if (this.debug)
console.log(EmbederService.name + '.create()');
this.build(config);
this.isInitialized = true;
};
EmbederService.prototype.clean = function () {
if (this.debug)
console.log(EmbederService.name + '.clean()');
this.isInitialized = false;
this.deattachApiListeners();
if (this.player != null)
bradmax.player.destroy(this.player);
if (this.nativeElement != null)
while (this.nativeElement.firstChild != null)
this.nativeElement.removeChild(this.nativeElement.firstChild);
this.api = null;
this.player = null;
};
EmbederService.prototype.destroy = function () {
if (this.debug)
console.log(EmbederService.name + '.destroy()');
this.clean();
this.nativeElement = null;
};
Object.defineProperty(EmbederService.prototype, "playerId", {
get: function () {
if (this.name == null || this.version == null)
return undefined;
return this.name + '_' + this.version;
},
enumerable: true,
configurable: true
});
EmbederService.prototype.build = function (config) {
if (this.debug)
console.log(EmbederService.name + '.build()');
if (config == null && this.globalConfig == null)
throw new Error(EmbederService.name + '.build() -> player has no configuration !');
if (this.nativeElement == null)
throw new Error(EmbederService.name + '.build() -> player nativeElement == null !');
try {
this.player = bradmax.player.create(this.nativeElement, config == null ? this.globalConfig : config, this.playerId);
}
catch (e) {
throw e;
}
try {
this.api = this.player.modules.JavascriptApi;
}
catch (e) {
throw e;
}
this.attachApiListeners();
};
EmbederService.prototype.attachApiListeners = function () {
if (this.api != null) {
this.api.add('VideoEvent.currentTimeChange', this.handleCurrentTimeChange);
this.api.add('VideoEvent.playing', this.handlePlaying);
this.api.add('VideoEvent.complete', this.handleComplete);
}
};
EmbederService.prototype.deattachApiListeners = function () {
if (this.api != null) {
this.api.remove('VideoEvent.currentTimeChange', this.handleCurrentTimeChange);
this.api.remove('VideoEvent.playing', this.handlePlaying);
this.api.remove('VideoEvent.complete', this.handleComplete);
}
};
EmbederService.decorators = [
{ type: core.Injectable },
];
EmbederService.ctorParameters = function () { return []; };
return EmbederService;
}());
var AbstractBradmaxPlayerComponent = (function () {
function AbstractBradmaxPlayerComponent(service, elementRef, debug) {
this.service = service;
this.elementRef = elementRef;
this.debug = debug;
this.config = null;
this.playing = new core.EventEmitter();
this.currentTimeChange = new core.EventEmitter();
this.complete = new core.EventEmitter();
if (this.debug)
console.debug(AbstractBradmaxPlayerComponent.name + '.new()');
try {
this.service.setup(this.elementRef.nativeElement);
}
catch (e) {
throw e;
}
}
AbstractBradmaxPlayerComponent.prototype.ngOnInit = function () {
var _this = this;
if (this.debug)
console.debug(AbstractBradmaxPlayerComponent.name + '.ngOnInit(', this.config, ')');
if (this.config == null || typeof this.config === undefined)
throw new Error(AbstractBradmaxPlayerComponent.name + '.ngOnInit.config == ' + this.config);
this.service.onPlaying.subscribe(function (e) { return _this.playing.emit(e); });
this.service.onCurrentTimeChange.subscribe(function (e) { return _this.currentTimeChange.emit(e); });
this.service.onComplete.subscribe(function (e) { return _this.complete.emit(e); });
try {
this.service.create(this.config);
}
catch (e) {
throw e;
}
};
AbstractBradmaxPlayerComponent.prototype.ngOnDestroy = function () {
if (this.debug)
console.debug(AbstractBradmaxPlayerComponent.name + '.ngOnDestroy()');
try {
this.service.destroy();
}
catch (e) {
throw e;
}
};
AbstractBradmaxPlayerComponent.propDecorators = {
config: [{ type: core.Input }],
playing: [{ type: core.Output }],
currentTimeChange: [{ type: core.Output }],
complete: [{ type: core.Output }]
};
return AbstractBradmaxPlayerComponent;
}());
var BRADMAX_PLAYER_CONFIGURATION = new core.InjectionToken('BRADMAX_PLAYER_CONFIGURATION');
var BRADMAX_PLAYER_DEBUG = new core.InjectionToken('BRADMAX_PLAYER_DEBUG');
var BRADMAX_PLAYER_SOURCE_PATH = new core.InjectionToken('BRADMAX_PLAYER_SOURCE_PATH');
var BradmaxPlayerMoleComponent = (function (_super) {
tslib.__extends(BradmaxPlayerMoleComponent, _super);
function BradmaxPlayerMoleComponent(service, elementRef, debug) {
var _this = _super.call(this, service, elementRef, debug) || this;
_this.service = service;
_this.elementRef = elementRef;
_this.debug = debug;
service.debug = debug;
service.name = 'mole';
return _this;
}
BradmaxPlayerMoleComponent.decorators = [
{ type: core.Component, args: [{
selector: 'bradmax-player-mole',
template: "<i>bradmax player loading...</i>",
styles: [":host {display: block;}"],
providers: [EmbederService]
},] },
];
BradmaxPlayerMoleComponent.ctorParameters = function () { return [
{ type: EmbederService },
{ type: core.ElementRef },
{ type: Boolean, decorators: [{ type: core.Inject, args: [BRADMAX_PLAYER_DEBUG,] }] }
]; };
return BradmaxPlayerMoleComponent;
}(AbstractBradmaxPlayerComponent));
var BradmaxPlayerMoleModule = (function () {
function BradmaxPlayerMoleModule() {
}
BradmaxPlayerMoleModule.forRoot = function (options) {
return {
ngModule: BradmaxPlayerMoleModule,
providers: [
{ provide: BRADMAX_PLAYER_DEBUG, useValue: options ? options.debug : false },
{ provide: BRADMAX_PLAYER_CONFIGURATION, useValue: options ? options.playerConfig : null }
]
};
};
BradmaxPlayerMoleModule.forChild = function (options) {
return {
ngModule: BradmaxPlayerMoleModule,
providers: [
{ provide: BRADMAX_PLAYER_DEBUG, useValue: options ? options.debug : false },
{ provide: BRADMAX_PLAYER_CONFIGURATION, useValue: options ? options.playerConfig : null }
]
};
};
BradmaxPlayerMoleModule.decorators = [
{ type: core.NgModule, args: [{
imports: [
common.CommonModule
],
declarations: [
BradmaxPlayerMoleComponent
],
entryComponents: [BradmaxPlayerMoleComponent],
exports: [
BradmaxPlayerMoleComponent
]
},] },
];
return BradmaxPlayerMoleModule;
}());
/* bradmax.com */
exports.BradmaxPlayerMoleModule = BradmaxPlayerMoleModule;
exports.ɵb = AbstractBradmaxPlayerComponent;
exports.ɵd = BRADMAX_PLAYER_CONFIGURATION;
exports.ɵe = BRADMAX_PLAYER_DEBUG;
exports.ɵc = EmbederService;
exports.ɵa = BradmaxPlayerMoleComponent;
Object.defineProperty(exports, '__esModule', { value: true });
})));
/* bradmax.com */
//# sourceMappingURL=index.umd.js.map