zoukankan      html  css  js  c++  java
  • 获取Audio音频的总时长

    let musicDom = document.getElementsByTagName('audio')[0];  // 获取AudioDom节点
                musicDom.load();//因为source标签不能直接更改路径,所以整个audio标签必须重新加载一次
                musicDom.oncanplay = function () {  
                    console.log("音乐时长",musicDom.duration);//音乐总时长
                    //处理时长
                    var time = musicDom.duration;
                    //分钟
                    var minute = time / 60;
                    var minutes = parseInt(minute);
                    if (minutes < 10) {
                        minutes = "0" + minutes;
                    }
                    //秒
                    var second = time % 60;
                    var seconds = Math.round(second);
                    if (seconds < 10) {
                        seconds = "0" + seconds;
                    }
                    console.log('处理音乐时长',minutes+":"+seconds)

                        
                }

  • 相关阅读:
    Windows netsh命令的使用
    源码安装 qemu-2.0.0 及其依赖 glib-2.12.12
    .ko文件
    Suse环境下编译linux-2.6.24内核
    cut
    POJ3648 Wedding
    [Hnoi2010]Planar
    [中山市选2011]杀人游戏
    BZOJ3033 太鼓达人
    POJ1041 John's trip
  • 原文地址:https://www.cnblogs.com/0826sw/p/11915291.html
Copyright © 2011-2022 走看看