Giter Site home page Giter Site logo

Accessing player object about vue-plyr HOT 12 CLOSED

redxtech avatar redxtech commented on July 19, 2024
Accessing player object

from vue-plyr.

Comments (12)

thegeminisociety avatar thegeminisociety commented on July 19, 2024 7

Found a solution to access the player object that works for now...

<plyr ref="player">

then

mounted() { this.player = this.$refs.player.player; this.player.play(); // works this.player.forward(20); // works }

from vue-plyr.

vana-dev avatar vana-dev commented on July 19, 2024 5

not working for me :/ this.$refs.player.player returns undefined

from vue-plyr.

Galvesmash avatar Galvesmash commented on July 19, 2024 3

Found a solution to access the player object that works for now...

<plyr ref="player">

then

mounted() { this.player = this.$refs.player.player; this.player.play(); // works this.player.forward(20); // works }

I LOVE YOU

from vue-plyr.

redxtech avatar redxtech commented on July 19, 2024 1

I might be able to emit the plyr object on initialization, and you can set the state based on that. I'll also look into exposing the component's state so that you can access the plyr state element from outside the component.

from vue-plyr.

jwjcmw avatar jwjcmw commented on July 19, 2024

Just a note that this was working prior to the update to plyr v3 (I was accessing event.detail.plyr.getCurrentTime() to keep track of progress through a video using the timeupdate event). I just tried updating to the 3.0.0 version, and it returns null.

from vue-plyr.

thegeminisociety avatar thegeminisociety commented on July 19, 2024

Any update on this? Running into a scenario where I have multiple players on the page and want to pause the active player if a user plays a different player. Thanks!

from vue-plyr.

redxtech avatar redxtech commented on July 19, 2024

@thegeminisociety @jwjcmw I unfortunately will not be able to do this for a while, as I am quite backed up with school. If either of you want to make a PR that for each of the components emits the object under emitObject or something like that in the mounted hook I would happily merge the PR

from vue-plyr.

jwjcmw avatar jwjcmw commented on July 19, 2024

I was looking into this a bit further to see why the old behavior broke...here are a couple of examples (I stripped these down to bare js...I wanted to make sure vue wasn't the issue). In the first example, plyr is pulled in through the cdn, and the event.detail.object exists:
https://codesandbox.io/s/l7z67y53zz

In the next example, the only difference is that plyr is required as a node module (like in vue-plyr), and the event.detail.plyr object does NOT exist:
https://codesandbox.io/s/1yn2mkx3vq

Do either of you have an idea what might be happening here? I also tried specifically requiring the plyr.min.js file in dist, which should be the same one that is pulled from the cdn (and a compare shows them to be, except for the source map reference at the end). No difference.

from vue-plyr.

jwjcmw avatar jwjcmw commented on July 19, 2024

And, weirdly, this does work:
https://codesandbox.io/s/887zvvpxl8
where I'm using an ES6 import instead of require. See any issues with changing vue-plyr to use that syntax instead? I can gen up a PR for it.

from vue-plyr.

jwjcmw avatar jwjcmw commented on July 19, 2024

Also, just noticed the examples only work in chrome...not sure if that is my code or codesandbox, which I just started using.

from vue-plyr.

jwjcmw avatar jwjcmw commented on July 19, 2024

I figured out the issue with the plyr object not being available on the events. If you use this:
const Plyr = require('plyr')
then a type check fails in the plyr code that outputs the plyr object along with the event. If you use:
const plyr = require('plyr') or just require('plyr')
all is good.

from vue-plyr.

redxtech avatar redxtech commented on July 19, 2024

This should be fixed in the new version coming out soon. Additionally, the player is going to be emitted by the player event when the component is mounted, so you can access it directly from that.

from vue-plyr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.