Commit d0b0c60a authored by Simon Daron's avatar Simon Daron

Adding unique ID for audio layer

parent c80530c5
from datetime import datetime, timedelta
import math
import math, uuid
from django.views.generic.base import TemplateView
from django.views.decorators.csrf import csrf_exempt
......@@ -161,6 +161,7 @@ class Home(TemplateView):
context = super(Home, self).get_context_data(**kwargs)
context['news'] = NewsItem.objects.all().exclude(image__isnull=True).exclude(image__exact='').order_by('-datetime')[:5]
context['emissions'] = Emission.objects.filter(archived=False).order_by('?')
context['player'] = audioPlayer()
return context
home = Home.as_view()
......@@ -180,10 +181,25 @@ class Player(TemplateView):
def get_context_data(self, **kwargs):
context = super(Player, self).get_context_data(**kwargs)
context['player'] = audioPlayer()
return context
player = Player.as_view()
class loadPlayer(TemplateView):
template_name = 'player.html'
def get_context_data(self, **kwargs):
context = super(Player, self).get_context_data(**kwargs)
context['player'] = audioPlayer()
return context
player = Player.as_view()
class audioPlayer:
def __init__(self):
self.unique = uuid.uuid4()
@csrf_exempt
@to_json('api')
......
......@@ -6,8 +6,14 @@
<span class="label">&nbsp;en direct</span>
</button>
<div id="WhatsOnAir"></div>
<audio id="DirectStreamPanik" class="hidden" tabindex="0" src="http://streaming.domainepublic.net:8000/radiopanik.ogg" controls="controls">
</audio>
<audio
id="DirectStreamPanik"
preload="none"
class="hidden"
tabindex="0"
src="http://streaming.domainepublic.net:8000/radiopanik.ogg?&unique={{ player.unique }}"
controls="controls"
></audio>
<ul class="inline metas small">
<li class="right">
<button id="BufferStateTODO"></button>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment