音乐app各部分笔记

7-11 播放器播放时间获取和更新

1.audio 有一个 ontimeupdate事件 播放过程中 随时触发 

  vue里面就是  @timeupdate   事件中有默认参数 e  通过e.target 能获得当前dom

2. audio 有个属性  currentTime 表示当前播放时间

3. 或零 =  Math.floor    都是向下取整

  计算时间搓为几分几秒

  

  format(interval){
        interval = interval | 0 //或0 相当于向下取整 Math.floor
        const minute = interval / 60 |0
        const second = (interval % 60) < 10? '0'+ interval : interval; // 当<10 需要补零
        return `${minute}:${second}`
     }

猜你喜欢

转载自www.cnblogs.com/tansitong/p/9059983.html