Duration in media plugin


#1

Hi guys
i use media plugin for playing mp3 online
but for using getting duration of play i have problem
i use this code :

this.file = this.media.create(this.post.cd_meta.tracks[0].mp3);
    this.file.play();

    var mediaTimer = setInterval(function () {
      // get media position
      this.file.getCurrentPosition(
        // success callback
        function (position) {
          if (position > -1) {
            console.log((position) + " sec");
          }
        },
        // error callback
        function (e) {
          console.log("Error getting pos=" + e);
        }
      );
    }, 1000);

but i wouldn’t get duration, if has guide or experience please help

Thanks


#2

Please help

thanks all


#3

Replace all references to function() { with fat arrows () => {.

E.g.
function (position) { becomes (position) => {, and function() { becomes () => {.