title: How to retrive the duration of a mp3 or wav audio file in Vue
body: <p>Im trying to achive when i upload an audio file to see te duration of the uploaded mp3 or wav, but i don't know how to do that in vue, any sugestions ? I have find this script but i don't have a clue how to manage'it with vue. Any help appreciated, thanks.</p>
  <p>Javascript:</p>
  <pre><code>var objectUrl;
  
      $(&quot;#audio&quot;).on(&quot;canplaythrough&quot;, function(e){
          var seconds = e.currentTarget.duration;
          var duration = moment.duration(seconds, &quot;seconds&quot;);
          
          var time = &quot;&quot;;
          var hours = duration.hours();
          if (hours &gt; 0) { time = hours + &quot;:&quot; ; }
          
          time = time + duration.minutes() + &quot;:&quot; + duration.seconds();
          $(&quot;#duration&quot;).text(time);
          
          URL.revokeObjectURL(objectUrl);
      });
      
      $(&quot;#file&quot;).change(function(e){
          var file = e.currentTarget.files[0];
         
          $(&quot;#filename&quot;).text(file.name);
          $(&quot;#filetype&quot;).text(file.type);
          $(&quot;#filesize&quot;).text(file.size);
          
          objectUrl = URL.createObjectURL(file);
          $(&quot;#audio&quot;).prop(&quot;src&quot;, objectUrl);
      });
  </code></pre>
  <p><a href="http://jsfiddle.net/derickbailey/s4P2v/" rel="nofollow noreferrer">http://jsfiddle.net/derickbailey/s4P2v/</a></p>
  <p>What i have tried so far but in console i get: 0:00:</p>
  <pre><code> &lt;input type=&quot;file&quot; id=&quot;file&quot; ref=&quot;file&quot; v-on:change=&quot;handleFileUpload()&quot;/&gt;
    &lt;button @click=&quot;submitAudioFile&quot;&gt; SUBMIT&lt;/button&gt;
  
    handleFileUpload () { 
        this.file = this.$refs.file.files[0]  
      },
  submitAudioFile () {
       let objectUrl = ''
            const myAudio = this.$refs.file.files[0]
            objectUrl = URL.createObjectURL(myAudio)
            const seconds = myAudio.duration
            const duration = moment.duration(seconds, 'seconds')
          
            let time = ''
            const hours = duration.hours()
            if (hours &gt; 0) { time = `${hours  }:`  }
          
            time = `${time + duration.minutes()  }:${  duration.seconds()}`
            console.log(time)
          
            URL.revokeObjectURL(objectUrl)
  }
  </code></pre>