Skip to content

feat(youtube-player): Add documentation to the README #16925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/youtube-player/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package(default_visibility = ["//visibility:public"])
load("//:packages.bzl", "ROLLUP_GLOBALS")
load(
"//tools:defaults.bzl",
"markdown_to_html",
"ng_module",
"ng_package",
"ng_test_library",
Expand Down Expand Up @@ -54,11 +53,6 @@ ng_web_test_suite(
deps = [":unit_test_sources"],
)

markdown_to_html(
name = "overview",
srcs = [":youtube-player.md"],
)

filegroup(
name = "source-files",
srcs = glob(["**/*.ts"]),
Expand Down
60 changes: 60 additions & 0 deletions src/youtube-player/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Angular YouTube Player component

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).

## Installation

To install, run `npm install @angular/youtube-player`.

## Usage

Follow the following instructions for setting up the YouTube player component:

- First, follow the [instructions for installing the API script](https://developers.google.com/youtube/iframe_api_reference#Getting_Started).
- Then make sure the API is available before bootstraping the YouTube Player component.
- Provide find the video id by extracting it from the video URL.

## Example

If your video is found at https://www.youtube.com/watch?v=PRQCAL_RMVo, then your video id is `PRQCAL_RMVo`.

```typescript
// example-module.ts
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {YouTubePlayerModule} from '@angular/youtube-player';
import {YoutubePlayerExample} from './example-component';

@NgModule({
imports: [
// Needed for ngIf directive.
CommonModule,
YouTubePlayerModule,
],
declarations: [YoutubePlayerExample],
})
export class YoutubePlayerExampleModule {
}

// example-component.ts
@Component({
moduleId: module.id,
template: '<youtube-player videoId="PRQCAL_RMVo" />',
selector: 'youtube-player-example',
})
class YoutubePlayerExample implements OnInit {
onInit() {
// This code loads the IFrame Player API code asynchronously, according to the instructions at
// https://developers.google.com/youtube/iframe_api_reference#Getting_Started
const tag = document.createElement('script');

tag.src = "https://www.youtube.com/iframe_api";
document.body.appendChild(tag);
}
}

```

## API

Check out the [source](./youtube-player.ts) to read the API.
Empty file.