:: JavaScript的是audio.pause重置audio.currentTime值设置为0? [英] Javascript:: Is audio.pause reset audio.currentTime value to 0?

查看:1744
本文介绍了:: JavaScript的是audio.pause重置audio.currentTime值设置为0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code是可以正常使用的除了的事实,而不是那个暂停它会回到赛道开始的轨道。

My code is working perfectly except the fact that instead of pause the track it's going back to the beginning of the track.

下面是我的code:

var audio=new Audio();

var hezi=document.querySelector('#player>.button.hand');
var gangina=("textContent" in document)?"textContent":"innerText";

hezi.addEventListener
(
    'click',
    function()
    {

        if(audio.paused)
        {
            audio.src="Nadav Guedj - Golden Boy (Eurovision 2015 - Israel - Karaoke).mp3";
            hezi.innerHTML="►";
            audio.play();
        }
        else
        {
            hezi.innerHTML="||";
            audio.pause();
        }

    }
);

我要承担,要解决这个问题,我需要在轨道的 audio.currentTime 值存储与 window.setInterval ,并使用最后一个 audio.currentTime 值从最后一点停止的地方,但我纳闷播放的曲目,如果有大陆的方法,使暂停/播放按键功能正常(不提的是,如果我将存储通过 window.setInterval ,去年价值它不会是100%准确的,因为我靠在区间值,而不是精确的特定点,用户暂停的曲目)。

I'm going to assume that to solve this issue I need to store the audio.currentTime value of that track with window.setInterval and use the last audio.currentTime value to play the track from the last point where it stopped but I was wonder if there is continent way to make the pause/play button function properly (not to mention the fact that if I would store that last value via window.setInterval it wouldn't be 100% accurate since I'm relying on the interval value and not the exact specific point where the user paused the track).

推荐答案

它会回到起点,因为这条线的,

it is going back to the beginning because of this line,

        audio.src="Nadav Guedj - Golden Boy (Eurovision 2015 - Israel - Karaoke).mp3";

删除,然后audio.play将继续从您暂停的地方。 小提琴演示

这篇关于:: JavaScript的是audio.pause重置audio.currentTime值设置为0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆