@@ -93,48 +93,48 @@ export class YouTubePlayer implements AfterViewInit, OnDestroy, OnInit {
93
93
get videoId ( ) : string | undefined { return this . _videoId ; }
94
94
set videoId ( videoId : string | undefined ) {
95
95
this . _videoId = videoId ;
96
- this . _videoIdObs . emit ( videoId ) ;
96
+ this . _videoIdObs . next ( videoId ) ;
97
97
}
98
98
private _videoId : string | undefined ;
99
- private _videoIdObs = new EventEmitter < string | undefined > ( ) ;
99
+ private _videoIdObs = new Subject < string | undefined > ( ) ;
100
100
101
101
/** Height of video player */
102
102
@Input ( )
103
103
get height ( ) : number | undefined { return this . _height ; }
104
104
set height ( height : number | undefined ) {
105
105
this . _height = height || DEFAULT_PLAYER_HEIGHT ;
106
- this . _heightObs . emit ( this . _height ) ;
106
+ this . _heightObs . next ( this . _height ) ;
107
107
}
108
108
private _height = DEFAULT_PLAYER_HEIGHT ;
109
- private _heightObs = new EventEmitter < number > ( ) ;
109
+ private _heightObs = new Subject < number > ( ) ;
110
110
111
111
/** Width of video player */
112
112
@Input ( )
113
113
get width ( ) : number | undefined { return this . _width ; }
114
114
set width ( width : number | undefined ) {
115
115
this . _width = width || DEFAULT_PLAYER_WIDTH ;
116
- this . _widthObs . emit ( this . _width ) ;
116
+ this . _widthObs . next ( this . _width ) ;
117
117
}
118
118
private _width = DEFAULT_PLAYER_WIDTH ;
119
- private _widthObs = new EventEmitter < number > ( ) ;
119
+ private _widthObs = new Subject < number > ( ) ;
120
120
121
121
/** The moment when the player is supposed to start playing */
122
122
@Input ( ) set startSeconds ( startSeconds : number | undefined ) {
123
- this . _startSeconds . emit ( startSeconds ) ;
123
+ this . _startSeconds . next ( startSeconds ) ;
124
124
}
125
- private _startSeconds = new EventEmitter < number | undefined > ( ) ;
125
+ private _startSeconds = new Subject < number | undefined > ( ) ;
126
126
127
127
/** The moment when the player is supposed to stop playing */
128
128
@Input ( ) set endSeconds ( endSeconds : number | undefined ) {
129
- this . _endSeconds . emit ( endSeconds ) ;
129
+ this . _endSeconds . next ( endSeconds ) ;
130
130
}
131
- private _endSeconds = new EventEmitter < number | undefined > ( ) ;
131
+ private _endSeconds = new Subject < number | undefined > ( ) ;
132
132
133
133
/** The suggested quality of the player */
134
134
@Input ( ) set suggestedQuality ( suggestedQuality : YT . SuggestedVideoQuality | undefined ) {
135
- this . _suggestedQuality . emit ( suggestedQuality ) ;
135
+ this . _suggestedQuality . next ( suggestedQuality ) ;
136
136
}
137
- private _suggestedQuality = new EventEmitter < YT . SuggestedVideoQuality | undefined > ( ) ;
137
+ private _suggestedQuality = new Subject < YT . SuggestedVideoQuality | undefined > ( ) ;
138
138
139
139
/**
140
140
* Whether the iframe will attempt to load regardless of the status of the api on the
@@ -157,8 +157,8 @@ export class YouTubePlayer implements AfterViewInit, OnDestroy, OnInit {
157
157
158
158
/** Whether we're currently rendering inside a browser. */
159
159
private _isBrowser : boolean ;
160
- private _youtubeContainer = new EventEmitter < HTMLElement > ( ) ;
161
- private _destroyed = new EventEmitter < undefined > ( ) ;
160
+ private _youtubeContainer = new Subject < HTMLElement > ( ) ;
161
+ private _destroyed = new Subject < void > ( ) ;
162
162
private _player : Player | undefined ;
163
163
164
164
constructor (
@@ -215,7 +215,7 @@ export class YouTubePlayer implements AfterViewInit, OnDestroy, OnInit {
215
215
this . createEventsBoundInZone ( ) ,
216
216
) . pipe ( waitUntilReady ( ) , takeUntil ( this . _destroyed ) , publish ( ) ) ;
217
217
218
- /** Set up side effects to bind inputs to the player. */
218
+ // Set up side effects to bind inputs to the player.
219
219
playerObs . subscribe ( player => this . _player = player ) ;
220
220
221
221
bindSizeToPlayer ( playerObs , widthObs , heightObs ) ;
@@ -256,15 +256,24 @@ export class YouTubePlayer implements AfterViewInit, OnDestroy, OnInit {
256
256
}
257
257
258
258
ngAfterViewInit ( ) {
259
- this . _youtubeContainer . emit ( this . youtubeContainer . nativeElement ) ;
259
+ this . _youtubeContainer . next ( this . youtubeContainer . nativeElement ) ;
260
260
}
261
261
262
262
ngOnDestroy ( ) {
263
263
if ( this . _player ) {
264
264
this . _player . destroy ( ) ;
265
265
window . onYouTubeIframeAPIReady = undefined ;
266
- this . _destroyed . emit ( ) ;
267
266
}
267
+
268
+ this . _videoIdObs . complete ( ) ;
269
+ this . _heightObs . complete ( ) ;
270
+ this . _widthObs . complete ( ) ;
271
+ this . _startSeconds . complete ( ) ;
272
+ this . _endSeconds . complete ( ) ;
273
+ this . _suggestedQuality . complete ( ) ;
274
+ this . _youtubeContainer . complete ( ) ;
275
+ this . _destroyed . next ( ) ;
276
+ this . _destroyed . complete ( ) ;
268
277
}
269
278
270
279
private _runInZone < T extends ( ...args : any [ ] ) => void > ( callback : T ) :
@@ -521,7 +530,7 @@ function bindCueVideoCall(
521
530
startSecondsObs : Observable < number | undefined > ,
522
531
endSecondsObs : Observable < number | undefined > ,
523
532
suggestedQualityObs : Observable < YT . SuggestedVideoQuality | undefined > ,
524
- destroyed : Observable < undefined > ,
533
+ destroyed : Observable < void > ,
525
534
) {
526
535
const cueOptionsObs = combineLatest ( [ startSecondsObs , endSecondsObs ] )
527
536
. pipe ( map ( ( [ startSeconds , endSeconds ] ) => ( { startSeconds, endSeconds} ) ) ) ;
0 commit comments