Comments (10)
That seems like a reasonable solution. I can probably build that into the next release to fix this sort of issue.
from vue-plyr.
I think that using nextTick to access the ref is the best solution for now. If anyone has any other questions feel free to open a new issue.
from vue-plyr.
I think that using nextTick to access the ref is the best solution for now. If anyone has any other questions feel free to open a new issue.
This does not work for me. The player is still undefined.
from vue-plyr.
From what I understand, it's not best practice to 1.) use refs to access child components and 2.) depend on refs being available in computed properties: https://vuejs.org/v2/guide/components-edge-cases.html#Accessing-Child-Component-Instances-amp-Child-Elements
That might have something to do with it - I've found that refs is not even available in the mounted hook on the first render, so Nuxt might be having an issue with that. I still haven't worked out the best way to grab a reference to the player instance.
from vue-plyr.
@jacobedawson: Thanks for the answer. It's in the same component and I'm following the doc
The goal is to play the player programmatically
from vue-plyr.
I'm having the same problem in Vue SPA. This is what I had to do to initialize the player with a video:
<template>
<vue-plyr ref="plyr" id="video-player">
<video controls>
<source src type="video/mp4"/>
</video>
</vue-plyr>
</template>
<script>
export default {
data () {
return {
player: {},
playerInitialized: false
}
},
updated: function () {
// INITIALIZE PLYR PLAYER WITH A VIDEO
this.$nextTick(function () {
const videoplayer = document.getElementById("video-player");
if(!this.playerInitialized) { // If player not initialized
videoplayer.addEventListener('ready', event => {
this.playerInitialized = true
this.player = this.$refs.plyr.player
if(!this.player.source) {
this.player.source = {
type: 'video',
title: 'Example title',
sources: [{
src: "example-video-url.mp4",
type: 'video/mp4',
size: 1080,
}]
}
}
})
}
}),
methods: {
// Load videos programatically
loadVideo (videoUrl) {
this.player.source = {
type: 'video',
title: 'Example title',
sources: [{
src: videoUrl,
type: 'video/mp4',
size: 1080,
}]
}
}
}
}
</script>
If any one knows how to do this in a better way, please let me know.
from vue-plyr.
Hi, is there any solution for this??
from vue-plyr.
@rafaelacb (and others):
Sorry for the delays, I've been swamped. I should be completely free to look at this in a few weeks.
I appreciate your understanding.
from vue-plyr.
Hi!, @rafaelacb and everyone.
How did you guys solve this issue?
Thank you in advance :)
from vue-plyr.
This is work for me
await this.$nextTick(() => {
setTimeout(() => {
console.log(this.$refs.plyr.player)
}, 500)
});
from vue-plyr.
Related Issues (20)
- Help me
- 'npm install vue-plyr' error? HOT 3
- sampotts/plyr.git develop Permission denied HOT 3
- Not working with HLS mp4s
- Add subtitles to a Youtube iframe
- default controls shown in the demo page its not coming
- Vue Plyr 7.0.0 causes npm ci in Docker fail with error 401 HOT 3
- Any maintenance status update for this (lovely) package? HOT 3
- Installation of dependency sampotts/plyr extremely slow
- Quality settings closes
- Cannot change vimeo source dynamically - error: Unknown player. Probably unloaded
- reload componentn when language changed
- `v-if` not working with plyr.
- Controls disappears in full screen HOT 1
- Fails to compile if importing css as in the example
- How can I use it Nuxt3 app HOT 3
- Customizing player
- Nuxt 3 SSR HOT 2
- Cannot load videos using Hls.js on Vite
- Vue3 update starting time
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-plyr.