【发布时间】:2021-03-16 07:54:33
【问题描述】:
我正在使用这个库https://github.com/dobromir-hristov/vue-vimeo-player/tree/master 将 vimeo 播放器嵌入到 Vue+Nuxt 应用程序中,但使用我自己的自定义控件,一切正常,但我无法找到如何更改播放器当前时间的方法。我已经有时间想切换,但我找不到实现这一目标的方法。例如,在 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)
},
【问题讨论】: