Skip to content
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

Cannot change vimeo source dynamically - error: Unknown player. Probably unloaded #502

Open
dataexcess opened this issue Nov 18, 2022 · 0 comments

Comments

@dataexcess
Copy link

dataexcess commented Nov 18, 2022

Hello,

I want to switch the source of my vimeo embedd dynamically. However when I do that I get a continues stream of the following errors, blocking my site and not setting any source:

player.js:2 Uncaught (in promise) Error: Unknown player. Probably unloaded.
    at e (player.js:2:12623)
    at new Promise (<anonymous>)
    at Proxy.value (player.js:2:12601)
    at player.js:2:11775
    at new Promise (<anonymous>)
    at Proxy.value (player.js:2:11669)
    at Proxy.value (player.js:2:15030)
    at Proxy.ready2 (plyr.min.mjs:3:77754)
    at Proxy.setup (plyr.min.mjs:3:74303)
    at Proxy.setup (plyr.min.mjs:3:86581)

I am following the setting source comvention like so ...

<template>
    <ClientOnly>
        <vue-plyr ref="plyr" :options="{ hideControls: true, autoplay: true, muted: true, volume: 0 }">
            <div data-plyr-provider="vimeo" :data-plyr-embed-id="vimeoId"></div>
        </vue-plyr>
    </ClientOnly>
</template>

<script lang="ts" setup>
import { ref, watchEffect } from 'vue'

const props = defineProps<{
    vimeoId: number
}>()

const plyr = ref<null | any>(null)

watchEffect(() => {
    console.log(props.vimeoId)
    if (plyr.value.player !== undefined && plyr.value.player.ready ) {
        plyr.value.player.source = {
            type: 'video',
            sources: [
                {
                    src: props.vimeoId.toString(),
                    provider: 'vimeo',
                },
            ],
        }
    }
})
</script>

I know I can add a :key argument to my vue-plyr component instance, and in doing so I get the stream of errors 6-7 times but eventually they stop and the source changes because the component rerenders all-together, but I would really like to avoid re-rendering this component as it causes other issues for me. Why can I not simply use the API as it is intended to be used?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant