• php 上传音频文件并获取时长


     <input type="file" name="audio" id="voice_file" style="display: inline-block;" accept="audio/mp3">
    <audio id="audio" controls autoplay="" style="display: none; "></audio>

    //上传 $("#voice_file").on("change", function () { var objUrl = upload_file(this.files[0]); if (objUrl.code == 1) { $('#video_url').val(objUrl.data.photo) $('.imgWrap').html('<audio height="150" src="'+objUrl.data.photo+'" controls id="video_control"></audio>') var audioFile = get_object_uRL(this.files[0]); $("#audio").attr("src", audioFile); $("#audio")[0].pause(); $("#audio").show(); getTime(); } else { layer.msg(objUrl.msg, {icon: 5}); } });
    //获取时长 function getTime() { setTimeout(function () { var duration = $("#audio")[0].duration; if(isNaN(duration)){ getTime(); }else{ console.info("该歌曲的总时间为:"+$("#audio")[0].duration+"秒") $('#ma_time').val(duration) } }, 10); }
  • 相关阅读:
    The hardest problem ever
    1146 Topological Order
    1147 Heaps
    Weekly Contest 184
    1148 Werewolf
    1149 Dangerous Goods Packaging
    1150 Travelling Salesman Problem
    1151 LCA in a Binary Tree (30point(s))
    1152 Google Recruitment
    美团2020春招笔试
  • 原文地址:https://www.cnblogs.com/phpwyl/p/11046470.html
Copyright © 2020-2023  润新知