Skip to content

Commit f02fb47

Browse files
Nathan Tatejelbourn
authored andcommitted
feat(youtube-player): Add documentation README (#16925)
1 parent aad7ff7 commit f02fb47

File tree

3 files changed

+60
-6
lines changed

3 files changed

+60
-6
lines changed

src/youtube-player/BUILD.bazel

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package(default_visibility = ["//visibility:public"])
33
load("//:packages.bzl", "ROLLUP_GLOBALS")
44
load(
55
"//tools:defaults.bzl",
6-
"markdown_to_html",
76
"ng_module",
87
"ng_package",
98
"ng_test_library",
@@ -54,11 +53,6 @@ ng_web_test_suite(
5453
deps = [":unit_test_sources"],
5554
)
5655

57-
markdown_to_html(
58-
name = "overview",
59-
srcs = [":youtube-player.md"],
60-
)
61-
6256
filegroup(
6357
name = "source-files",
6458
srcs = glob(["**/*.ts"]),

src/youtube-player/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Angular YouTube Player component
2+
3+
This component provides a simple angular wrapper around the embed [YouTube player API](https://developers.google.com/youtube/iframe_api_reference). File any bugs against the [angular/components repo](https://github.com/angular/components/issues).
4+
5+
## Installation
6+
7+
To install, run `npm install @angular/youtube-player`.
8+
9+
## Usage
10+
11+
Follow the following instructions for setting up the YouTube player component:
12+
13+
- First, follow the [instructions for installing the API script](https://developers.google.com/youtube/iframe_api_reference#Getting_Started).
14+
- Then make sure the API is available before bootstraping the YouTube Player component.
15+
- Provide find the video id by extracting it from the video URL.
16+
17+
## Example
18+
19+
If your video is found at https://www.youtube.com/watch?v=PRQCAL_RMVo, then your video id is `PRQCAL_RMVo`.
20+
21+
```typescript
22+
// example-module.ts
23+
import {CommonModule} from '@angular/common';
24+
import {NgModule} from '@angular/core';
25+
import {YouTubePlayerModule} from '@angular/youtube-player';
26+
import {YoutubePlayerExample} from './example-component';
27+
28+
@NgModule({
29+
imports: [
30+
// Needed for ngIf directive.
31+
CommonModule,
32+
YouTubePlayerModule,
33+
],
34+
declarations: [YoutubePlayerExample],
35+
})
36+
export class YoutubePlayerExampleModule {
37+
}
38+
39+
// example-component.ts
40+
@Component({
41+
moduleId: module.id,
42+
template: '<youtube-player videoId="PRQCAL_RMVo" />',
43+
selector: 'youtube-player-example',
44+
})
45+
class YoutubePlayerExample implements OnInit {
46+
onInit() {
47+
// This code loads the IFrame Player API code asynchronously, according to the instructions at
48+
// https://developers.google.com/youtube/iframe_api_reference#Getting_Started
49+
const tag = document.createElement('script');
50+
51+
tag.src = "https://www.youtube.com/iframe_api";
52+
document.body.appendChild(tag);
53+
}
54+
}
55+
56+
```
57+
58+
## API
59+
60+
Check out the [source](./youtube-player.ts) to read the API.

src/youtube-player/youtube-player.md

Whitespace-only changes.

0 commit comments

Comments
 (0)