Medai.getDuration is not working

I am trying to use media.getDuration() function to get total duration of an audio file but I am always getting -1.
This function used to work perfectly in phonegap but not with ionic.

Please someone help in this.

Thanks