include audio player on event views
This commit is contained in:
parent
38930cd4dd
commit
5c587d56f7
|
@ -1,11 +1,20 @@
|
|||
import os
|
||||
|
||||
from five import grok
|
||||
from zope import schema, component
|
||||
from Products.CMFCore.utils import getToolByName
|
||||
from parlevent import ParlEventBaseView
|
||||
from tabellio.agenda.comevent import IComEvent
|
||||
import tabellio.config.utils
|
||||
from plone.registry.interfaces import IRegistry
|
||||
from tabellio.config.interfaces import ITabellioSettings
|
||||
|
||||
class CommissionView(ParlEventBaseView):
|
||||
def get_stream_name(self):
|
||||
settings = component.getUtility(IRegistry).forInterface(ITabellioSettings, False)
|
||||
if settings.audiofiles_path:
|
||||
if os.path.exists(os.path.join(settings.audiofiles_path, self.context.id + '.mp3')):
|
||||
return self.context.id + '.mp3'
|
||||
if not self.context.commission:
|
||||
return 'XXXX'
|
||||
com_id = self.context.commission.to_path.split('/')[-1]
|
||||
|
|
|
@ -36,7 +36,14 @@
|
|||
<li><a href="#" class="cri" tal:condition="python: context.cri and context.cri.to_object"
|
||||
tal:attributes="href context/cri/to_object/absolute_url">Rapport / Compte rendu</a>
|
||||
<span class="cri" tal:condition="python: not(context.cri and context.cri.to_object)">Rapport / Compte rendu (non disponible)</span></li>
|
||||
<li><a tal:attributes="href string:${context/absolute_url}/ecouter.m3u" class="streaming" tal:condition="view/has_stream">Streaming</a>
|
||||
<li><tal:block tal:condition="view/has_stream">
|
||||
<span class="streaming">Réécouter :
|
||||
<br/><audio controls preload="metadata">
|
||||
<source tal:attributes="src string:/mp3/${view/get_stream_name}" type="audio/mpeg"/>
|
||||
(non pris en charge par votre navigateur)
|
||||
</audio>
|
||||
</span>
|
||||
</tal:block>
|
||||
<span class="streaming" tal:condition="not: view/has_stream">Streaming (non disponible)</span></li>
|
||||
</ul>
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@ class ParlEventBaseView(tabellio.agenda.parlevent.ParlEventBaseView):
|
|||
|
||||
class ParlEventView(ParlEventBaseView):
|
||||
def get_stream_name(self):
|
||||
settings = component.getUtility(IRegistry).forInterface(ITabellioSettings, False)
|
||||
if settings.audiofiles_path:
|
||||
if os.path.exists(os.path.join(settings.audiofiles_path, self.context.id + '.mp3')):
|
||||
return self.context.id + '.mp3'
|
||||
filename = '%04d%02d%02d%02d-SEAN.mp3' % (
|
||||
self.context.start.year, self.context.start.month,
|
||||
self.context.start.day, self.context.start.hour)
|
||||
|
|
Reference in New Issue