I'm currently building a soundboard for our Pen and Paper session and I am loading the sounds as a static source from my Django backend as new Audio(data.url). I am simply using the Django Rest Framework to handle everything about the file data, like uploads and accessing the sound files:
class File(models.Model):
file = models.FileField(upload_to='sound-files')
filename = models.CharField(max_length=100)
looped = models.BooleanField()
type = models.CharField(
max_length=16,
choices=[('bgm', 'background music'), ('sfx', 'sound effects')],
default="bgm"
)
But the initial loading time for the clients may be long as it needs to load a bigger 1 hour sound file for example, so I want to stream the audio instead of load it as a src.
How can I go about implementing this in Django? Do I need to use another module on top of DRF or do I need to replace DRF entirely? And can I keep the instantiation of the new Audio() in the Frontend or is a different approach required there?