dobromir-hristov / vue-vimeo-player

Vue.js wrapper for Vimeo player
MIT License
111 stars 56 forks source link

.getDuration() "message": "player.getDuration is not a function", "statusCode": 500 #73

Closed Joaojack closed 3 years ago

Joaojack commented 3 years ago

Hi, I can't manage to trigger the getDuration() or any getter functions. "message": "player.getDuration is not a function", "statusCode": 500 I'm on Nuxt. Am I doing something wrong ? Could you help me out ? Controls, video, options loading and events are working.

<template>
    <div>
        <client-only>
            {{domDuration}}
            <vimeo-player ref="player" :video-id="id" :options="options" @loaded="onReady"  />
        </client-only>  
    </div>

</template>

<script> 
import { mapGetters } from 'vuex'
export default {
    data() {
        return {
            domDuration:'',
            id:"387248846",
            options: {
                quality:'1080p',
                playsinline:false,
                responsive:true,
                muted: false,
                autoplay: true,
                  allowfullscreen:true,
            },
            playerReady: false
        }
    },

    methods: {
        onReady() {
            let player = this.$refs.player;
                player.getDuration().then(function(duration) {
                let minutes = Math.floor(duration / 60);
                let seconds = duration-(minutes*60)
                this.domDuration=`${minutes} minutes ${seconds}`
                })
        },
    },
}
</script>
dobromir-hristov commented 3 years ago

Use player.player, because you need the player object inside the player ref. A bit confusing i know.

Joaojack commented 3 years ago

Thank you very much ! works fine now :)