nstudio / nativescript-audio

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

Play audio bytes #154

Open FlawaCLV opened 4 years ago

FlawaCLV commented 4 years ago

I've created an audio live stream with my previous mobile app (Cordova). I send audio bytes using socket.io, buffer for a few seconds and play the array of bytes.

Is there a way to play audio bytes using your plugin? Or maybe you are familiar with a plugin that can convert my bytes first?

I was thinking, creating a file with the received audio bytes, then play it with player. playFromFile(), but I guess this isn't optimal. Any idea ?

bradmartin commented 4 years ago

Honestly, not sure myself. Never had to do that.

On Android the MediaPlayer is calling setDataSource https://developer.android.com/reference/android/media/MediaPlayer.html#setDataSource(java.io.FileDescriptor) - there are a few overrides accepting different types for the source. Just at quick glance it looks like you'll need to create a file first and then play it, but maybe I'm overlooking one of the methods that will accept bytes as the input.

Hope that helps. I haven't looked at iOS to see if the player there accepts bytes as the audio source.

zangarmarsh commented 3 years ago

@FlawaCLV @bradmartin Have you found a real solution to this by the chance?

FlawaCLV commented 3 years ago

@zangarmarsh I didn't use this plugin, I used AudioContext instead.

zangarmarsh commented 3 years ago

Thank you for your feedback @FlawaCLV . Do you mean JavaScript AudioContext? If so, do you already know if it supports background playback and playing speed variations?

FlawaCLV commented 3 years ago

I honestly don’t remember. You should look into the AudioContext API to find your answers.

Le mar. 27 avr. 2021 à 22:14, zangarmarsh @.***> a écrit :

Thank you for your feedback @FlawaCLV https://github.com/FlawaCLV . Do you mean JavaScript AudioContext? If so, do you already know if it supports background playback and playing speed variations?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/nstudio/nativescript-audio/issues/154#issuecomment-827899258, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBZHXDAGTC54KBHBIX7LFLTK4LIVANCNFSM4IXCVEWA .

--

Hugo Pozzoli

CEO & Fondateur de Pas de panique ! https://mobile.pasdepaniqueapp.fr

📱 +33 (0)6 68 37 00 76