-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(youtube-player) Add a demo to the dev-app (#16858)
- Loading branch information
Showing
11 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary") | ||
load("//tools:defaults.bzl", "ng_module") | ||
|
||
ng_module( | ||
name = "youtube-player", | ||
srcs = glob(["**/*.ts"]), | ||
assets = [ | ||
"youtube-player-demo.html", | ||
":youtube_player_demo_scss", | ||
], | ||
deps = [ | ||
"//src/material/radio", | ||
"//src/youtube-player", | ||
"@npm//@angular/forms", | ||
"@npm//@angular/router", | ||
], | ||
) | ||
|
||
sass_binary( | ||
name = "youtube_player_demo_scss", | ||
src = "youtube-player-demo.scss", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {CommonModule} from '@angular/common'; | ||
import {FormsModule} from '@angular/forms'; | ||
import {MatRadioModule} from '@angular/material/radio'; | ||
import {NgModule} from '@angular/core'; | ||
import {RouterModule} from '@angular/router'; | ||
import {YouTubePlayerModule} from '@angular/youtube-player'; | ||
import {YouTubePlayerDemo} from './youtube-player-demo'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
MatRadioModule, | ||
YouTubePlayerModule, | ||
RouterModule.forChild([{path: '', component: YouTubePlayerDemo}]), | ||
], | ||
declarations: [YouTubePlayerDemo], | ||
}) | ||
export class YouTubePlayerDemoModule { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div> | ||
<h1>Basic Example</h1> | ||
<section> | ||
<div class="demo-video-selection"> | ||
<label>Pick the video:</label> | ||
<mat-radio-group aria-label="Select a video" [(ngModel)]="video"> | ||
<mat-radio-button *ngFor="let video of videos" [value]="video"> | ||
{{video.name}} | ||
</mat-radio-button> | ||
<mat-radio-button [value]="undefined">Unset</mat-radio-button> | ||
</mat-radio-group> | ||
</div> | ||
<p *ngIf="!apiLoaded">Loading youtube api...</p> | ||
<youtube-player *ngIf="apiLoaded" [videoId]="video && video.id"></youtube-player> | ||
</section> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.demo-video-selection { | ||
margin-bottom: 20px; | ||
|
||
mat-radio-button { | ||
margin: 8px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {ChangeDetectorRef, Component} from '@angular/core'; | ||
|
||
declare global { | ||
interface Window { | ||
YT: typeof YT | undefined; | ||
onYouTubeIframeAPIReady: () => void; | ||
} | ||
} | ||
|
||
interface Video { | ||
id: string; | ||
name: string; | ||
} | ||
|
||
const VIDEOS: Video[] = [ | ||
{ | ||
id: 'PRQCAL_RMVo', | ||
name: 'Instructional', | ||
}, | ||
{ | ||
id: 'O0xx5SvjmnU', | ||
name: 'Angular Conf', | ||
}, | ||
{ | ||
id: 'invalidname', | ||
name: 'Invalid', | ||
}, | ||
]; | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'youtube-player-demo', | ||
templateUrl: 'youtube-player-demo.html', | ||
styleUrls: ['youtube-player-demo.css'], | ||
}) | ||
export class YouTubePlayerDemo { | ||
video: Video | undefined = VIDEOS[0]; | ||
videos = VIDEOS; | ||
apiLoaded = false; | ||
|
||
constructor(private _ref: ChangeDetectorRef) { | ||
if (window.YT) { | ||
this.apiLoaded = true; | ||
return; | ||
} | ||
|
||
window.onYouTubeIframeAPIReady = () => { | ||
this.apiLoaded = true; | ||
this._ref.detectChanges(); | ||
}; | ||
} | ||
} |