@bradmax/player-ng
Version:
Bradmax Player Angular module.
13 lines • 7.9 kB
JavaScript
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("@bradmax/player/version"),require("tslib"),require("@bradmax/player/zebra"),require("@angular/common")):"function"==typeof define&&define.amd?define("bradmax-player-ng-zebra",["exports","@angular/core","@bradmax/player/version","tslib","@bradmax/player/zebra","@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.zebra={}),global.ng.core,global.bradmax.player.version,global.tslib,global.bradmax,global.ng.common)}(this,function(exports,core,version,tslib,zebra,common){"use strict";
/**
* @license
* _ _
* | | | |
* | |__ _ __ __ _ __| |_ __ ___ __ ___ __
* | '_ \| '__/ _` |/ _` | '_ ` _ \ / _` \ \/ /
* | |_) | | | (_| | (_| | | | | | | (_| |> <
* |_.__/|_| \__,_|\__,_|_| |_| |_|\__,_/_/\_\
*
* Bradmax Player
* bradmax.com
*/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,this.debug&&console.debug(AbstractBradmaxPlayerComponent.name+".new()");try{this.service.setup(this.elementRef.nativeElement)}catch(e){throw e}}return AbstractBradmaxPlayerComponent.prototype.ngOnInit=function(){var _this=this;if(this.debug&&console.debug(AbstractBradmaxPlayerComponent.name+".ngOnInit(",this.config,")"),null==this.config||void 0===typeof this.config)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(){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}]},AbstractBradmaxPlayerComponent}(),EmbederServiceCounter=-1,EmbederService=function(){function EmbederService(){var _this=this;this.debug=!1,this.isInitialized=!1,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){_this.debug&&console.log(EmbederService.name+".handleCurrentTimeChange(",e,")"),_this.onCurrentTimeChange.emit(e.data)},this.handlePlaying=function(e){_this.debug&&console.log(EmbederService.name+".handlePlaying(",e,")"),_this.onPlaying.emit(e.data)},this.handleComplete=function(e){_this.debug&&console.log(EmbederService.name+".handleComplete(",e,")"),_this.onComplete.emit(e.data)},EmbederServiceCounter++,this.debug&&console.debug(EmbederService.name+".new(counter:"+EmbederServiceCounter+")"),this.isInitialized=!1}return EmbederService.prototype.setup=function(element){this.nativeElement=element,this.debug&&console.log(EmbederService.name+".setup(",this.nativeElement,")")},EmbederService.prototype.create=function(config){this.clean(),this.debug&&console.log(EmbederService.name+".create()"),this.build(config),this.isInitialized=!0},EmbederService.prototype.clean=function(){if(this.debug&&console.log(EmbederService.name+".clean()"),this.isInitialized=!1,this.deattachApiListeners(),null!=this.player&&bradmax.player.destroy(this.player),null!=this.nativeElement)for(;null!=this.nativeElement.firstChild;)this.nativeElement.removeChild(this.nativeElement.firstChild);this.api=null,this.player=null},EmbederService.prototype.destroy=function(){this.debug&&console.log(EmbederService.name+".destroy()"),this.clean(),this.nativeElement=null},Object.defineProperty(EmbederService.prototype,"playerId",{get:function(){if(null!=this.name&&null!=this.version)return this.name+"_"+this.version},enumerable:!0,configurable:!0}),EmbederService.prototype.build=function(config){if(this.debug&&console.log(EmbederService.name+".build()"),null==config&&null==this.globalConfig)throw new Error(EmbederService.name+".build() -> player has no configuration !");if(null==this.nativeElement)throw new Error(EmbederService.name+".build() -> player nativeElement == null !");try{this.player=bradmax.player.create(this.nativeElement,null==config?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(){null!=this.api&&(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(){null!=this.api&&(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[]},EmbederService}(),BRADMAX_PLAYER_CONFIGURATION=new core.InjectionToken("BRADMAX_PLAYER_CONFIGURATION"),BRADMAX_PLAYER_DEBUG=new core.InjectionToken("BRADMAX_PLAYER_DEBUG"),BradmaxPlayerZebraComponent=(new core.InjectionToken("BRADMAX_PLAYER_SOURCE_PATH"),function(_super){function BradmaxPlayerZebraComponent(service,elementRef,debug){var _this=_super.call(this,service,elementRef,debug)||this;return _this.service=service,_this.elementRef=elementRef,_this.debug=debug,service.debug=debug,service.name="zebra",_this}return tslib.__extends(BradmaxPlayerZebraComponent,_super),BradmaxPlayerZebraComponent.decorators=[{type:core.Component,args:[{selector:"bradmax-player-zebra",template:"<i>bradmax player loading...</i>",styles:[":host {display: block;}"],providers:[EmbederService]}]}],BradmaxPlayerZebraComponent.ctorParameters=function(){return[{type:EmbederService},{type:core.ElementRef},{type:Boolean,decorators:[{type:core.Inject,args:[BRADMAX_PLAYER_DEBUG]}]}]},BradmaxPlayerZebraComponent}(AbstractBradmaxPlayerComponent)),BradmaxPlayerZebraModule=function(){function BradmaxPlayerZebraModule(){}return BradmaxPlayerZebraModule.forRoot=function(options){return{ngModule:BradmaxPlayerZebraModule,providers:[{provide:BRADMAX_PLAYER_DEBUG,useValue:!!options&&options.debug},{provide:BRADMAX_PLAYER_CONFIGURATION,useValue:options?options.playerConfig:null}]}},BradmaxPlayerZebraModule.forChild=function(options){return{ngModule:BradmaxPlayerZebraModule,providers:[{provide:BRADMAX_PLAYER_DEBUG,useValue:!!options&&options.debug},{provide:BRADMAX_PLAYER_CONFIGURATION,useValue:options?options.playerConfig:null}]}},BradmaxPlayerZebraModule.decorators=[{type:core.NgModule,args:[{imports:[common.CommonModule],declarations:[BradmaxPlayerZebraComponent],entryComponents:[BradmaxPlayerZebraComponent],exports:[BradmaxPlayerZebraComponent]}]}],BradmaxPlayerZebraModule}();exports.BradmaxPlayerZebraModule=BradmaxPlayerZebraModule,exports.ɵb=AbstractBradmaxPlayerComponent,exports.ɵd=BRADMAX_PLAYER_CONFIGURATION,exports.ɵe=BRADMAX_PLAYER_DEBUG,exports.ɵc=EmbederService,exports.ɵa=BradmaxPlayerZebraComponent,Object.defineProperty(exports,"__esModule",{value:!0})});