Skip to content

Commit

Permalink
docs: add an example Vue integration.md (#5899)
Browse files Browse the repository at this point in the history
* Create vue.md

Instructions for Vue integration (based on React example).

* Add link to Vue guide
  • Loading branch information
chopfitzroy authored and gkatsev committed Mar 28, 2019
1 parent 511f729 commit 4c277fd
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/guides/player-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This document outlines many considerations for using Video.js for advanced playe
* [React](#react)
* [Ember](#ember)
* [Angular](#angular)
* [Vue](#vue)

## Accessing a player that has already been created on a page

Expand Down Expand Up @@ -371,3 +372,7 @@ See [ReactJS integration example](/docs/guides/react.md)
### Ember

### Angular

### Vue

See [Vue integration example](/docs/guides/vue.md)
83 changes: 83 additions & 0 deletions docs/guides/vue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Video.js and Vue integration

Here's a basic Vue player implementation.

It just instantiates the Video.js player on `mounted` and destroys it on `beforeDestroy`.

```vue
<template>
<div>
<video ref="videoPlayer" class="video-js"></video>
</div>
</template>
<script>
import videojs from 'video.js';
export default {
name: "VideoPlayer",
props: {
options: {
type: Object,
default() {
return {};
}
}
},
data() {
return {
player: null
}
},
mounted() {
this.player = videojs(this.$refs.videoPlayer, this.options, function onPlayerReady() {
console.log('onPlayerReady', this);
})
},
beforeDestroy() {
if (this.player) {
this.player.dispose()
}
}
}
</script>
```

You can then use it like this: (see [options guide][options] for option information)

```vue
<template>
<div>
<video-player :options="videoOptions"/>
</div>
</template>
<script>
import VideoPlayer from "@/components/VideoPlayer.vue";
export default {
name: "VideoExample",
components: {
VideoPlayer
},
data() {
return {
videoOptions: {
autoplay: true,
controls: true,
sources: [
{
src:
"/path/to/video.mp4",
type: "video/mp4"
}
]
}
};
}
};
```

Don't forget to include the Video.js CSS, located at `video.js/dist/video-js.css`.

[options]: /docs/guides/options.md

0 comments on commit 4c277fd

Please sign in to comment.