user2253332
user2253332

Reputation: 827

Playing audio files in Django app?

I have a Django app and I want to try to play a song on it. Before, I had this in my HTML:

<audio autoplay="autoplay">  
<source src="audio/song.ogg" /> 

where audio is a folder within my templates folder. This works when I just run the HTML file inside my browser, but it no longer works when I access the site from my Django server. If anyone has any help, I'd appreciate it!

Upvotes: 2

Views: 4248

Answers (1)

user4375224
user4375224

Reputation:

Try this and let me know :)

settings.py

MEDIA_URL = 'file_location'

html

<audio id="Player" autoplay>
     <source src="{{MEDIA_URL}}audio/song.ogg"/>
</audio>

Upvotes: 1

Related Questions