我正在使用这个库https://github.com/dobromir-hristov/vue-vimeo-player/tree/master在Vue+Nuxt应用程序中嵌入vimeo播放器,但是有了我自己的自定义控件,一切都运行得很好,除了我找不到一种方法来改变播放器的当前时间。我已经有时间切换到想要切换的位置,但我找不到方法来实现这一点。对于Youtube IFrame API中的示例,有一个名为player.seekTo(nextTime)的方法。此外,我现在从这里https://developer.vimeo.com/player/sdk/reference Vimeo SDK提供了一个方法setCurrentTime(seconds),但我不知道如何使用它与vue-vimeo-player库。
这是我的播放器组件代码:
<vimeo-player
ref="player"
:video-id="videoId"
:controls="false"
:autoplay="true"
:options="{ responsive: true }"
@playing="isPlaying = true"
@pause="isPlaying = false"
@ended="closeFullWindow"
@timeupdate="onProgress"
/>以及当用户点击我的自定义时间控件时的方法:
lineClicked ({ clientX }) {
//...calculations to get nextTime...
// Here i have my time where user clicked:
console.log('nextTime', nextTime)
// Here is method from Vimeo SDK but how use it with vue-vimeo-player?
// this.player.setCurrentTime(30.456).then(function (seconds) {
// // `seconds` indicates the actual time that the player seeks to
// }).catch(function (error) {
// switch (error.name) {
// case 'RangeError':
// // The time is less than 0 or greater than the video's duration
// break
// default:
// // Some other error occurred
// break
// }
// })
// With Youtube IFrame API all i had to do is:
// this.player.seekTo(nextTime)
},发布于 2021-03-16 19:03:33
好的,我发现vue-vimeo-player是基于这个https://github.com/vimeo/player.js的,所以基本上我要做的是:this.$refs.player.player.setCurrentTime(nextTime)
https://stackoverflow.com/questions/66651011
复制相似问题