PhoneGap unable to getDuration() out of Media API, but other methods work

前端 未结 4 2195
[愿得一人]
[愿得一人] 2021-02-15 14:29

I\'m building out an audio media recorder/player with PhoneGap. It\'s all working beautifully, but I\'ve hit a wrinkle I can\'t seem to iron.

my_media.play();

4条回答
  •  执念已碎
    2021-02-15 15:16

    I also faced similar problem in cordova for iOS. I was successfully able to record, play and stop audio but unable to get current position and total duration for audio file. So I added my_media.release() just after I was done finishing recording audio i.e. after my_media.stopRecord() and it worked like a charm. Earlier I was getting -1 for getDuration() and 0 for getCurrentPosition().

    Hope it helps someone.

提交回复
热议问题