nstudio / nativescript-audio

:microphone: NativeScript plugin to record and play audio :musical_note:
Other
150 stars 104 forks source link

playFromUrl -> Error -38 #108

Open alereisan opened 6 years ago

alereisan commented 6 years ago

Using the same code as it is used in the demo folder.

Playing from the remote file returns: {"player":{},"error":-38,"extra":0}

rudii1410 commented 6 years ago

Hi @alereisan , the error comes when android MediaPlayer call start() method before the audio file is ready. You can check this for more info: https://stackoverflow.com/questions/9008770/media-player-called-in-state-0-error-38-0

Actually i found that situation is already handled on this line, so the error is not supposed to happen. One possible scenario that i could think of is you called start() method right after playFromUrl().

bradmartin commented 6 years ago

Indeed @rudii1410 - if you have autoplay = true then in that listener the player will start (https://github.com/nstudio/nativescript-audio/blob/02017d8b55abe9b0973662b0ecd6dc5529135015/src/android/player.ts#L156)