Skip to content

Commit 39bd89c

Browse files
committed
Update README
1 parent 04f81f9 commit 39bd89c

File tree

3 files changed

+45
-14
lines changed

3 files changed

+45
-14
lines changed

README.md

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@ This plugin makes it easy to integrate the YouTube Iframe API into your Vue app.
44

55
## Notice
66

7-
⚠️ Currently rewriting this library in Typescript. This change **should not** introduce breaking changes, but if there
8-
are open a new issue. The `1.0.3` version is still based on the previous JS based source code. The upcoming version
9-
`1.0.4` is based on the Typescript rewrite.
7+
⚠️ The new version `1.0.4` (rewritten in Typescript) introduces the following breaking change:
8+
9+
The events `@ended`, `@playing`, `@paused`, `@buffering` and `@cued` will no longer be emitted. Instead you should now
10+
use `@state-change` to catch the events when the player state changes. This better represents the behaviour of the
11+
YouTube Iframe API described [here](https://developers.google.com/youtube/iframe_api_reference#Events).
12+
13+
### New features
14+
15+
- Support for typings across the board. In detail these are type declarations for the plugin itself as well as YouTube
16+
Iframe specific typings under the namespace `YT`.
17+
- API complete methods for pausing, stoping and queueing videos (See
18+
[here](https://developers.google.com/youtube/iframe_api_reference#Functions))
1019

1120
## Usage
1221

@@ -24,15 +33,15 @@ yarn add @techassi/vue-youtube-iframe
2433

2534
### Basic usage
2635

27-
`main.js`
36+
`main.js` / `main.ts`
2837

2938
```js
3039
import { createApp } from 'vue';
3140
import App from './App.vue';
3241

33-
import VueYouTubeIframe from '@techassi/vue-youtube-iframe';
42+
import YoutubeIframe from '@techassi/vue-youtube-iframe';
3443

35-
createApp(App).use(VueYouTubeIframe).mount('#app');
44+
createApp(App).use(YoutubeIframe).mount('#app');
3645
```
3746

3847
`YourComponent.vue`
@@ -60,22 +69,46 @@ createApp(App).use(VueYouTubeIframe).mount('#app');
6069
</template>
6170
```
6271

63-
#### Available props
72+
### Typings
73+
74+
Vue currently doesn't support typings when using a component in a SFC and accessing it via `ref` / `this.$refs`. There
75+
is a way to bring in typings when using `ref`. Please note: This isn't the most elegant solution.
76+
77+
```vue
78+
<template>
79+
<youtube-iframe :video-id="YT_VIDEO_ID" ref="yt"></youtube-iframe>
80+
</template>
81+
82+
<script lang="ts">
83+
import { defineComponent } from 'vue';
84+
import { Player } from '@techassi/vue-youtube-iframe';
85+
86+
export default defineComponent({
87+
name: 'App',
88+
mounted() {
89+
const player = this.$refs.yt as typeof Player;
90+
// Variable player now has typings
91+
},
92+
});
93+
</script>
94+
```
95+
96+
### Available props
6497

6598
- `:videoId / :video-id`: Specify the YT video id (e.g. `dQw4w9WgXcQ`)
6699
- `:playerWidth / :player-width`: Specify the player's width in pixels
67100
- `:playerHeight / :player-height`: Specify the player's height in pixels
68101
- `:noCookie / :no-cookie`: If set to `true` the host will be set to `https://www.youtube-nocookie.com`
69102
- `:playerParameters / :player-parameters`: Set player parameters, see [here](#available-player-parameters)
70103

71-
#### Available player parameters
104+
### Available player parameters
72105

73106
For the available player parameters see [here](https://developers.google.com/youtube/player_parameters#Parameters)
74107

75-
#### Available Events
108+
### Available Events
76109

77110
```
78-
@ready, @error, @ended, @playing, @paused, @buffering and @cued
111+
@ready, @error, @stateChange
79112
```
80113

81114
For detailed event information check [here](https://developers.google.com/youtube/iframe_api_reference#Events)

src/manager.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,4 @@ export function createManager(): Manager {
5151
}
5252

5353
const manager = createManager();
54-
Object.freeze(manager);
55-
5654
export default manager;

src/player.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const player = defineComponent({
3333
default: false,
3434
},
3535
},
36-
emits: ['ready', 'error', 'stateChange'],
36+
emits: ['ready', 'error', 'state-change'],
3737
data() {
3838
return {
3939
elementId: '',
@@ -64,7 +64,7 @@ const player = defineComponent({
6464
},
6565
onStateChange: (event: YT.OnStateChangeEvent) => {
6666
if (event.data !== -1) {
67-
this.$emit('stateChange', event);
67+
this.$emit('state-change', event);
6868
}
6969
},
7070
onError: (event: YT.OnErrorEvent) => {

0 commit comments

Comments
 (0)