Comments (8)
I can probably watch the instance for events and them emit those.
Would that work?
from vue-plyr.
That would probably work, and would be the more "vue" way of doing it. I'm not sure how much extra overhead that extra layer adds on...I'm monitoring the time change, so there is going to be a whole lot of emitting going on.
from vue-plyr.
How about something like this, where you can pass in the events that you want emitted back...
<plyr :emit="['timeupdate','exitfullscreen']" @timeupdate="videoTimeUpdated" @exitfullscreen="exitedFullScreen">
and then the plyr component will just emit what has been requested...
<script>
import plyr from 'plyr'
import 'plyr/dist/plyr.css'
export default {
name: 'plyr',
props: {
/** Options object for plyr config. */
options: {
type: Object,
required: false,
default () { return {} }
},
/**new prop to accept what to emit back**/
emit: {
type: Array,
required: false,
default () { return [] }
},
},
data () {
return {
player: {}
}
},
mounted () {
this.player = plyr.setup(document.getElementById(`plyr-container-${this.idNumber}`),
this.options)[0]
/**after player object is setup, loop through the emit array to set the on() API method for each**/
this.emit.forEach(element => {
this.player.on(element,this.emitPlayerEvent)
});
},
methods: {
/**method to handle emitting any of the player events**/
emitPlayerEvent() {
this.$emit(event.type,event)
},
},
beforeDestroy () {
this.player.destroy()
},
computed: {
idNumber () {
return Math.floor(Math.random() * (100000 - 1)) + 1
}
}
}
</script>
If you like this method, I can set it up in each of the plyr-* components and create a PR.
from vue-plyr.
That looks great!
I wouldn't be able to get to this for a bit, so if you're willing to send a PR that would be amazing !
from vue-plyr.
Will do.
from vue-plyr.
from vue-plyr.
Accepted PR, should be good.
from vue-plyr.
@redxtech @jwjcmw Heads up!
The line:
this.player.on(element,this.emitPlayerEvent)
off is never called
this.player.off(...)
.
This causes memory leaks.
I'm just not sure if it it necessary this part of the code only, or some bug with plyr also.
On my SPA I cannot use any event with :emit
because of the code I highlighted.
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.