nstudio / nativescript-audio

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

error playing remote audio #146

Closed joey0xx closed 3 years ago

joey0xx commented 5 years ago

Im trying to play a remote audio hosted in an azure blob storage, but I get this error when i play it:

JS: {
JS: "player": {},
JS: "error": 1,
JS: "extra": -2147483648
JS: }

I can play it locally fine without any errors. Tried to see if it was because of the size (only around 4.0 mb) but i also tried uploading another audio to the blob storage that has bigger size and it played fine. Tried on an android 9.0 emulator and android 8.0 device but none of them worked. Then I uploaded it again after playing it locally but still doesnt work.

Below im attaching a project with the local audio and the remote url sampleaudioproj.zip

alexander171294 commented 5 years ago

Same here, android 9 nexus 5 emulator.

joseatelevoro commented 5 years ago

@NathanWalker we can pay for this bug fix! Is jose from https://twitter.com/nativoplus brotha!

alexander171294 commented 5 years ago

I have found solution for this, but i'm not remember how it is D:

pabloacastillo commented 5 years ago

I have found solution for this, but i'm not remember how it is D:

Perhaps something like this @alexander171294 ?

Add an attribute to the <application> tag in AndroidManifest.xml

android:usesCleartextTraffic="true"

Hope this helps.

jakoguta commented 3 years ago

I am having trouble playing remote files on Android version 10.

reference back to player: {
    "player": {},
    "error": 1,
    "extra": -1015
}

I have this android:usesCleartextTraffic="true" set in AndroidManifest.xml <application> tag. I am using nativescript-audio v6.2.1, @nativescript/core v7.0.13, angular 11, and also set <uses-permission android:name="android.permission.INTERNET"/>

The streaming works on other devices (Honor, running Android 7) but fail on others (Samsung, running Android 10). Any help to fix this bug would really be appreciated.

bradmartin commented 3 years ago

@jakoguta - your error value of 1 https://stackoverflow.com/a/18084143/1893557 indicates the error is unknown. It's possible the audio file might have issues with playback on Samsung devices. Can you share the file you're attempting to play?

jakoguta commented 3 years ago

@bradmartin I managed to solve the issue. I was streaming the audio file (.mp3) form a python server, using flask Response() function without specifying the mimetype="audio/mpeg". Other devices would work fine but some needed this to be specified. I hope others may learn from my mistake.