Skip to content

Commit 83545cf

Browse files
Nathan Tatejelbourn
authored andcommitted
feat(youtube-player): add feature for waiting until the API has finished loading (#16998)
1 parent f02fb47 commit 83545cf

File tree

4 files changed

+270
-209
lines changed

4 files changed

+270
-209
lines changed

src/dev-app/youtube-player/youtube-player-demo.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ <h1>Basic Example</h1>
1010
<mat-radio-button [value]="undefined">Unset</mat-radio-button>
1111
</mat-radio-group>
1212
</div>
13-
<p *ngIf="!apiLoaded">Loading youtube api...</p>
14-
<youtube-player *ngIf="apiLoaded" [videoId]="video && video.id"></youtube-player>
13+
<youtube-player [videoId]="video && video.id"></youtube-player>
1514
</section>
1615
</div>

src/dev-app/youtube-player/youtube-player-demo.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {ChangeDetectorRef, Component} from '@angular/core';
10-
11-
declare global {
12-
interface Window {
13-
YT: typeof YT | undefined;
14-
onYouTubeIframeAPIReady: () => void;
15-
}
16-
}
9+
import {Component} from '@angular/core';
1710

1811
interface Video {
1912
id: string;
@@ -45,16 +38,4 @@ export class YouTubePlayerDemo {
4538
video: Video | undefined = VIDEOS[0];
4639
videos = VIDEOS;
4740
apiLoaded = false;
48-
49-
constructor(private _ref: ChangeDetectorRef) {
50-
if (window.YT) {
51-
this.apiLoaded = true;
52-
return;
53-
}
54-
55-
window.onYouTubeIframeAPIReady = () => {
56-
this.apiLoaded = true;
57-
this._ref.detectChanges();
58-
};
59-
}
6041
}

0 commit comments

Comments
 (0)