<player-component id="tvp-id" playerid="tvp" vid="{{nowvid}}" style="width:100%;">
<view slot="bottom-left-ctrl-btn" style="display: flex;">
<button class="yhx_but_bottom" bind:tap="backwardFiveSeconds">-5s</button>
<button class="yhx_but_bottom" bind:tap="forwardFiveSeconds">+5s</button>
</view>
</player-component>
js:
forwardFiveSeconds(){
const player = this.selectComponent('#tvp-id')
if (player && typeof player.getCurrentTime === 'function' && typeof player.seek === 'function') {
const currentTime = player.getCurrentTime();
player.seek(currentTime + 5);
} else {
console.error('Player methods not available!');
}
},
你这样写没报错么?我这样写是能直接当前+5s的
forwardFiveSeconds() { const player = this.selectComponent('#tvp-id') const currentTime = player.playtime; player.seek(currentTime + 5); }
const player = this.selectComponent('#tvp-id')
改为
const store = requirePlugin('player') const player = store.get('tvp');
也不行