-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
How to use on Vue #4167
Comments
Working fine for me? |
@Adynnor can you paste some snippet to show how you did it? Do you know how to change video dynamically? |
@edouard-lopez <template>
<video playsinline id="myPlayer" class="video-js vjs-default-skin" width="100%" controls preload="auto" data-setup='{ "aspectRatio":"16:9" }'></video>
</template>
<script>
window.videojs = require('video.js');
export default {
data(){
return{
player: '',
url: 'https://someurl.com',
volume: 1
};
},
methods: {
playerInitialize(){
this.player = videojs('myPlayer');
},
playerDispose(){
this.player.dispose();
},
playerPlay(){
this.player.play();
},
playerPause(){
this.player.pause();
},
playerSetSrc(url){
this.player.src(url);
},
playerSetVolume(float){
this.player.volume(float);
},
playerSetPoster(url){
this.player.poster(url);
},
playerSetTime(time){
this.player.currentTime(time);
},
playerEventEnded(){
console.log('ended');
},
playerEventVolume(){
this.volume = this.player.volume();
},
playerEventError(){
console.log( this.playerGetError() )
},
playerGetPaused(){
return this.player.paused();
},
playerGetTime(){
return this.player.currentTime();
},
playerGetError(){
return this.player.error().message;
},
playerSetupEvents(){
this.player.on('ended', function(){ var a = window.playerEvents.playerEventEnded(); });
this.player.on('volumechange', function(){ window.playerEvents.playerEventVolume(); });
this.player.on('error', function(){ window.playerEvents.playerEventError(); });
},
},
mounted(){
window.playerEvents = this;
this.playerInitialize();
this.playerSetSrc(this.url);
this.playerSetupEvents();
},
beforeDestroy() {
this.playerDispose();
}
}
</script> |
@Adynnor gee, I was missing the |
@edouard-lopez NP, glad you worked it out! :) |
@Adynnor would you be able to write a quick doc about using video.js with vue similar to our react doc? |
Closing this as it's been answered. If anyone wants to submit a PR to make a doc like the react doc, that would be awesome! |
PR submitted #5899. |
Thanks @CrashyBang! |
I have been unable to use vue, I hope to be a document
The text was updated successfully, but these errors were encountered: