ng5-yt-player
Version:
* [Description](#Description) * [Usage](#usage) * [Events](#Events) * [Download](#download)
2 lines (1 loc) • 10.2 kB
Source Map (JSON)
{"version":3,"file":"ng5-yt-player.es5.js","sources":["ts/ng5-yt-player.ts","ts/src/app/youtube-player/youtube-player.module.ts","ts/src/app/youtube-player/youtube-player.component.ts","ts/src/app/youtube-player/services/youtube-player.service.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport {YouTubePlayerModule} from './public_api';\n\nexport {YoutubePlayerService as ɵb} from './src/app/youtube-player/services/youtube-player.service';\nexport {YoutubePlayerComponent as ɵa} from './src/app/youtube-player/youtube-player.component';","import { NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';\nimport { YoutubePlayerComponent } from './youtube-player.component';\nimport { YoutubePlayerService } from './services/youtube-player.service';\nimport { ModuleWithProviders } from '@angular/compiler/src/core';\nexport class YouTubePlayerModule {\nstatic decorators: DecoratorInvocation[] = [\n{ type: NgModule, args: [{\n declarations: [\n YoutubePlayerComponent\n ],\n schemas: [NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA],\n providers: [YoutubePlayerService],\n exports: [\n YoutubePlayerComponent\n ]\n}, ] },\n];\n/**\n * @nocollapse\n */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n];\n}\n\nfunction YouTubePlayerModule_tsickle_Closure_declarations() {\n/** @type {?} */\nYouTubePlayerModule.decorators;\n/**\n * @nocollapse\n * @type {?}\n */\nYouTubePlayerModule.ctorParameters;\n}\n\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n","import { Component, OnInit, EventEmitter, AfterContentInit, Output, Input, OnChanges, SimpleChanges } from '@angular/core';\nimport { YoutubePlayerService } from './services/youtube-player.service';\nimport { YT } from './models/youtube';\nconst /** @type {?} */ domEleId = 'player';\nexport class YoutubePlayerComponent implements AfterContentInit {\n videoId: string;\n height: number;\n width: number;\n playerParams: YT.PlayerVars;\n\n playerReadyEvent = new EventEmitter<YT.Player>();\n playerStateChangeEvent = new EventEmitter<YT.PlayerState>();\n\n domId;\n/**\n * @param {?} playerService\n */\nconstructor(private playerService: YoutubePlayerService) {\n this.domId = 'player-' + this.guid();\n }\n/**\n * @return {?}\n */\nngAfterContentInit() {\n const /** @type {?} */ playerOptions: YT.PlayerOptions = {\n videoId: this.videoId || '',\n height: this.height || 300,\n width: this.width || 300,\n playerVars: {\n ...this.playerParams,\n enablejsapi: 1\n }\n };\n\n this.playerService.loadPlayerApi();\n this.playerService.createPlayer(this.domId, playerOptions, this.playerReadyEvent, this.playerStateChangeEvent);\n }\n/**\n * @return {?}\n */\nguid() {\n/**\n * @return {?}\n */\nfunction s4() {\n return Math.floor((1 + Math.random()) * 0x10000)\n .toString(16)\n .substring(1);\n }\n return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();\n }\nstatic decorators: DecoratorInvocation[] = [\n{ type: Component, args: [{\n selector: 'ng5-youtube-player',\n template: `\n <div [id]=\"domId\"></div>\n `,\n styles: [`\n\n `]\n}, ] },\n];\n/**\n * @nocollapse\n */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n{type: YoutubePlayerService, },\n];\nstatic propDecorators: {[key: string]: DecoratorInvocation[]} = {\n'videoId': [{ type: Input },],\n'height': [{ type: Input },],\n'width': [{ type: Input },],\n'playerParams': [{ type: Input },],\n'playerReadyEvent': [{ type: Output },],\n'playerStateChangeEvent': [{ type: Output },],\n};\n}\n\nfunction YoutubePlayerComponent_tsickle_Closure_declarations() {\n/** @type {?} */\nYoutubePlayerComponent.decorators;\n/**\n * @nocollapse\n * @type {?}\n */\nYoutubePlayerComponent.ctorParameters;\n/** @type {?} */\nYoutubePlayerComponent.propDecorators;\n/** @type {?} */\nYoutubePlayerComponent.prototype.videoId;\n/** @type {?} */\nYoutubePlayerComponent.prototype.height;\n/** @type {?} */\nYoutubePlayerComponent.prototype.width;\n/** @type {?} */\nYoutubePlayerComponent.prototype.playerParams;\n/** @type {?} */\nYoutubePlayerComponent.prototype.playerReadyEvent;\n/** @type {?} */\nYoutubePlayerComponent.prototype.playerStateChangeEvent;\n/** @type {?} */\nYoutubePlayerComponent.prototype.domId;\n/** @type {?} */\nYoutubePlayerComponent.prototype.playerService;\n}\n\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n","import { Injectable, NgZone, EventEmitter } from '@angular/core';\nimport { YT } from '../../youtube-player/models/youtube';\n\nconst /** @type {?} */ $window: any = window;\nconst /** @type {?} */ iFrameSrc = 'http://www.youtube.com/iframe_api';\nexport class YoutubePlayerService {\n/**\n * @param {?} zone\n */\nconstructor(private zone: NgZone) { }\n/**\n * @param {?} domElementId\n * @param {?} playerOptions\n * @param {?} readyEvent\n * @param {?} stateChangeEvent\n * @return {?}\n */\ncreatePlayer(domElementId: string, playerOptions: YT.PlayerOptions,\n readyEvent: EventEmitter<YT.Player>, stateChangeEvent: EventEmitter<YT.PlayerState>) {\n return setInterval(() => {\n if ((typeof $window.YT !== 'undefined') && $window.YT && $window.YT.Player) {\n const /** @type {?} */ player = new $window.YT.Player(domElementId, {\n ...playerOptions,\n events: {\n onReady: (ev: YT.PlayerEvent) => {\n this.zone.run(() =>\n readyEvent.emit(ev.target));\n },\n onStateChange: (ev: YT.OnStateChangeEvent) => {\n /**\n * player state is 1 (playing), 2 for Pause. Reference https://developers.google.com/youtube/iframe_api_reference\n */\n this.zone.run(() => stateChangeEvent.emit(ev.data));\n }\n }\n });\n }\n }, 100);\n }\n/**\n * @return {?}\n */\nloadPlayerApi(): void {\n const /** @type {?} */ doc = $window.document;\n const /** @type {?} */ playerApi = doc.createElement('script');\n playerApi.type = 'text/javascript';\n playerApi.src = iFrameSrc;\n doc.body.appendChild(playerApi);\n }\nstatic decorators: DecoratorInvocation[] = [\n{ type: Injectable },\n];\n/**\n * @nocollapse\n */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n{type: NgZone, },\n];\n}\n\nfunction YoutubePlayerService_tsickle_Closure_declarations() {\n/** @type {?} */\nYoutubePlayerService.decorators;\n/**\n * @nocollapse\n * @type {?}\n */\nYoutubePlayerService.ctorParameters;\n/** @type {?} */\nYoutubePlayerService.prototype.zone;\n}\n\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"],"names":[],"mappings":";AGGA,IAAM,OAAA,GAAe,MAAA,CAAO;AAC5B,IAAM,SAAA,GAAY,mCAAA,CAAoC;AACtD;;;;IAIA,8BADsB,IAAM;QAAN,IAAtB,CAAA,IAAsB,GAAA,IAAA,CAAM;IAA5B,CAAmC;;;;;;;;IASnC,2CAPG,GAOH,UAPG,YAAA,EAAA,aAAA,EAQC,UAAmC,EAAE,gBAA8C;QADvF,iBAqBG;QAnBC,MAAJ,CAPW,WAAA,CAAY;YAQjB,EAAN,CAAA,CAAU,CAPC,OAAO,OAAA,CAAQ,EAAC,KAAM,WAAA,CAOjC,IAPiD,OAAA,CAAQ,EAAC,IAAK,OAAA,CAAQ,EAAC,CAAE,MAAC,CAO3E,CAPkF,CAOlF;gBACQ,IAAR,gBAAA,CAPc,MAAA,GAAS,IAAI,OAAA,CAAQ,EAAC,CAAE,MAAC,CAAM,YAAC,EAO9C,MAAA,CAAA,MAAA,CAAA,EAAA,EACa,aAPC,EAMd,EAEU,MAAM,EAPE;wBAQN,OAAO,EAPE,UAAA,EAAS;4BAQhB,KAAI,CAPC,IAAC,CAAI,GAAC,CAAG,cAQZ,OAAA,UAAU,CAPC,IAAC,CAAI,EAAC,CAAE,MAAC,CAAM,EAO1B,CAP0B,CAAC,CAAC;wBAQ5C,CAAa;wBACD,aAAa,EAPE,UAAA,EAAS;;;;4BAWtB,KAAI,CAPC,IAAC,CAAI,GAAC,CAAG,cAAM,OAAA,gBAAA,CAAiB,IAAC,CAAI,EAAC,CAAE,IAAC,CAAI,EAA9B,CAA8B,CAAC,CAAC;w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