< html > < head > < meta name = "viewport" content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" /> </ head > < style > .test { outline: none; background-color: transparent; } </ style > < body > < input type = "file" name = "file" capture = "camcorder" id = "file" /> < video id = "audio_id" controls autoplay loop hidden>Your browser can't support HTML5 Audio</ video > < script > let file = document.getElementById('file'); file.addEventListener('change', (e) => { console.log(document.getElementById('file').files[0]); var url = URL.createObjectURL(document.getElementById('file').files[0]); var videos = document.getElementById("audio_id"); console.log(url); videos.src = url; videos.ondurationchange = function () { var minutes = parseInt(videos.duration / 60, 10); var seconds = videos.duration % 60; alert(`${minutes}m ${seconds}s`); } }) </ script > </ body > </ html > |
web-view 中src设置为该html文件时无法触发ondurationchange 和其他video事件,在开发者工具中可以触发ondurationchange 和其他video事件
18.18分左右已上传日志
麻烦提供能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)