根据视频URL获取视频时长()

    // 通过url链接获取视频时长
    const getDurationByUrl = (videoUrl) => {
      // const videoDom = document.getElementById('video')
      const audio = new Audio(videoUrl)
      let duration = 0
      audio.addEventListener("loadedmetadata", function (e) {
        duration = audio.duration // 通过添加监听来获取视频总时长字段,即duration
        console.log('视频时长为', duration)
      })
    }
————————
    // 通过url链接获取视频时长
    const getDurationByUrl = (videoUrl) => {
      // const videoDom = document.getElementById('video')
      const audio = new Audio(videoUrl)
      let duration = 0
      audio.addEventListener("loadedmetadata", function (e) {
        duration = audio.duration // 通过添加监听来获取视频总时长字段,即duration
        console.log('视频时长为', duration)
      })
    }