tRPC and playing audio files on the frontend
Hello all!
Reaching out to the community here to see if anyone can help. I am putting together an audio player component for my electron app and use tRPC for all backend communication. Specifically I am using the electron tRPC setup (https://github.com/jsonnull/electron-trpc)
I was wondering if anyone has used something like the react h5 audio player and served audio files to it using tRPC yet or should I just go with an express server setup?
Ideally I would like to avoid two comms systems but if needs must then I will go ahead.
Cheers!
// Ben
2 Replies
It's been some time since I last used trpc, but
https://trpc.io/docs/rpc#http-response-specification
I don't think tRPC wants to support that at all. They are different comm systems, and trying to stream files through a spec that only makes it more difficult to do so is like asking for bugs.
You should probably serve the trpc endpoints with express
https://trpc.io/docs/server/adapters/express
And just make an endpoint that streams the file
Unless you already got a system like s3 to generate presigned/download urls, then your server just has to send the url for the client to download, and that can be done easily in trpc.
I forgot about the tRPC express hook, I will try it through that and it should keep me in line with a single comms system in the app