UNPKG

ngx-plyr

Version:

Angular 6+ bindings for [plyr video and audio player](https://github.com/sampotts/plyr). Supports everything that original library supports.

16 lines (14 loc) 9.64 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("plyr"),require("@angular/core"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("ngx-plyr",["exports","plyr","@angular/core","rxjs","rxjs/operators"],t):t((e=e||self)["ngx-plyr"]={},e.Plyr,e.ng.core,e.rxjs,e.rxjs.operators)}(this,(function(e,t,r,n,p){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function i(e,t,r,n){var p,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var y=e.length-1;y>=0;y--)(p=e[y])&&(o=(i<3?p(o):i>3?p(t,r,o):p(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function o(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var y=function(){function e(){}return e.prototype.create=function(e){return new t(e.videoElement,e.options)},e.prototype.updateSource=function(e){e.plyr.source=e.source},e.prototype.destroy=function(e){e.plyr.destroy()},e}(),s=function(){function e(e,t,r){this.elementRef=e,this.ngZone=t,this.renderer=r,this.playerChange=new n.BehaviorSubject(null),this.events=new Map,this.plyrType="video",this.plyrInit=this.playerChange.pipe(p.filter((function(e){return!!e}))),this.plyrProgress=this.createLazyEvent("progress"),this.plyrPlaying=this.createLazyEvent("playing"),this.plyrPlay=this.createLazyEvent("play"),this.plyrPause=this.createLazyEvent("pause"),this.plyrTimeUpdate=this.createLazyEvent("timeupdate"),this.plyrVolumeChange=this.createLazyEvent("volumechange"),this.plyrSeeking=this.createLazyEvent("seeking"),this.plyrSeeked=this.createLazyEvent("seeked"),this.plyrRateChange=this.createLazyEvent("ratechange"),this.plyrEnded=this.createLazyEvent("ended"),this.plyrEnterFullScreen=this.createLazyEvent("enterfullscreen"),this.plyrExitFullScreen=this.createLazyEvent("exitfullscreen"),this.plyrCaptionsEnabled=this.createLazyEvent("captionsenabled"),this.plyrCaptionsDisabled=this.createLazyEvent("captionsdisabled"),this.plyrLanguageChange=this.createLazyEvent("languagechange"),this.plyrControlsHidden=this.createLazyEvent("controlshidden"),this.plyrControlsShown=this.createLazyEvent("controlsshown"),this.plyrReady=this.createLazyEvent("ready"),this.plyrLoadStart=this.createLazyEvent("loadstart"),this.plyrLoadedData=this.createLazyEvent("loadeddata"),this.plyrLoadedMetadata=this.createLazyEvent("loadedmetadata"),this.plyrQualityChange=this.createLazyEvent("qualitychange"),this.plyrCanPlay=this.createLazyEvent("canplay"),this.plyrCanPlayThrough=this.createLazyEvent("canplaythrough"),this.plyrStalled=this.createLazyEvent("stalled"),this.plyrWaiting=this.createLazyEvent("waiting"),this.plyrEmptied=this.createLazyEvent("emptied"),this.plyrCueChange=this.createLazyEvent("cuechange"),this.plyrError=this.createLazyEvent("error"),this.plyrStateChange=this.createLazyEvent("statechange"),this.subscriptions=[]}return Object.defineProperty(e.prototype,"player",{get:function(){return this.playerChange.getValue()},enumerable:!0,configurable:!0}),e.prototype.ngOnChanges=function(e){var t=this;this.subscriptions.push(this.plyrInit.pipe(p.first()).subscribe((function(r){var n=[e.plyrOptions,e.plyrPlaysInline,e.plyrCrossOrigin].filter((function(e){return!!e}));n.length?n.some((function(e){return!e.firstChange}))&&t.initPlyr(!0):t.updatePlyrSource(r)})))},e.prototype.ngOnDestroy=function(){this.destroyPlayer(),this.subscriptions.forEach((function(e){return e.unsubscribe()}))},e.prototype.ngAfterViewInit=function(){this.initPlyr()},e.prototype.initPlyr=function(e){var t=this;void 0===e&&(e=!1),!e&&this.player||this.ngZone.runOutsideAngular((function(){t.destroyPlayer(),t.driver=t.plyrDriver||new y,t.ensureVideoElement();var e=t.driver.create({videoElement:t.videoElement,options:t.plyrOptions});t.updatePlyrSource(e),t.playerChange.next(e)}))},e.prototype.updatePlyrSource=function(e){this.driver.updateSource({videoElement:this.videoElement,plyr:e,source:{type:this.plyrType,title:this.plyrTitle,sources:this.plyrSources,poster:this.plyrPoster,tracks:this.plyrTracks}})},e.prototype.createLazyEvent=function(e){var t=this;return this.plyrInit.pipe(p.switchMap((function(){return new n.Observable((function(r){return t.on(e,(function(e){return t.ngZone.run((function(){return r.next(e)}))}))}))})))},e.prototype.destroyPlayer=function(){var e=this;this.player&&(Array.from(this.events.keys()).forEach((function(t){return e.off(t)})),this.driver.destroy({plyr:this.player}),this.videoElement=null)},Object.defineProperty(e.prototype,"hostElement",{get:function(){return this.elementRef.nativeElement},enumerable:!0,configurable:!0}),e.prototype.ensureVideoElement=function(){var e=this.hostElement.querySelector("video");e?this.videoElement=e:(this.videoElement=this.renderer.createElement("video"),this.videoElement.controls=!0,this.plyrCrossOrigin&&this.videoElement.setAttribute("crossorigin",""),this.plyrPlaysInline&&this.videoElement.setAttribute("playsinline",""),this.renderer.appendChild(this.hostElement,this.videoElement))},e.prototype.on=function(e,t){this.events.set(e,t),this.player.on(e,t)},e.prototype.off=function(e){this.player.off(e,this.events.get(e)),this.events.delete(e)},e.ctorParameters=function(){return[{type:r.ElementRef},{type:r.NgZone},{type:r.Renderer2}]},i([r.Input(),o("design:type",Object)],e.prototype,"plyrDriver",void 0),i([r.Input(),o("design:type",String)],e.prototype,"plyrType",void 0),i([r.Input(),o("design:type",String)],e.prototype,"plyrTitle",void 0),i([r.Input(),o("design:type",String)],e.prototype,"plyrPoster",void 0),i([r.Input(),o("design:type",Array)],e.prototype,"plyrSources",void 0),i([r.Input(),o("design:type",Array)],e.prototype,"plyrTracks",void 0),i([r.Input(),o("design:type",Object)],e.prototype,"plyrOptions",void 0),i([r.Input(),o("design:type",Boolean)],e.prototype,"plyrCrossOrigin",void 0),i([r.Input(),o("design:type",Boolean)],e.prototype,"plyrPlaysInline",void 0),i([r.ViewChild("v"),o("design:type",r.ElementRef)],e.prototype,"vr",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrInit",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrProgress",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrPlaying",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrPlay",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrPause",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrTimeUpdate",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrVolumeChange",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrSeeking",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrSeeked",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrRateChange",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrEnded",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrEnterFullScreen",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrExitFullScreen",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrCaptionsEnabled",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrCaptionsDisabled",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrLanguageChange",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrControlsHidden",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrControlsShown",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrReady",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrLoadStart",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrLoadedData",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrLoadedMetadata",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrQualityChange",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrCanPlay",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrCanPlayThrough",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrStalled",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrWaiting",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrEmptied",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrCueChange",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrError",void 0),i([r.Output(),o("design:type",Object)],e.prototype,"plyrStateChange",void 0),e=i([r.Component({selector:"plyr, [plyr]",template:"",exportAs:"plyr",styles:[""]}),o("design:paramtypes",[r.ElementRef,r.NgZone,r.Renderer2])],e)}(),a=function(){function e(){}return e=i([r.NgModule({declarations:[s],exports:[s]})],e)}();e.DefaultPlyrDriver=y,e.PlyrComponent=s,e.PlyrModule=a,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ngx-plyr.umd.min.js.map