serenity-rs / songbird

An async Rust library for the Discord voice API
ISC License
381 stars 108 forks source link

How to play/load audio source from base64 #196

Closed beig closed 11 months ago

beig commented 12 months ago

Hello,

I am pretty new to rust but creating a discord bot seems like a nice project.

I am storing my mp3 as base64 string in jammdb. Is there a way to load the sound directly from memory? The only way I found is writing the base64 to a file and then load it

Thanks

FelixMcFelix commented 11 months ago

If you're on next, then you should be able to play any supported file format from memory (every owned byte slice e.g., &'static [u8], Bytes, or Vec<u8>). Obviously you'd need to parse the Base64 string back into actual bytes.

If you're on current, then you're correct, you either need to write it out to a local file, transform and pipe it to ffmpeg, or decode it locally into raw f32s/i16s.