$('.countdown-overlay').show();
}
-function CountDownTimer(json_event, id, video_id)
+function CountDownTimer(json_event, id, video_id, video_container)
{
var curr_event;
var timer;
var distance_out = 1;
var distance_in = 1;
+ var video_html;
function init() {
+
if (Object.keys(json_event).length > 0 ) {
curr_event = json_event[curr_event_index];
begin = moment(new Date(curr_event.begin));
var distance_out = begin.diff(now);
updateDisplay(distance_out);
if (distance_out < 0) {
- //clearInterval(timer);
- // $('#countdown-title').html('<br /><br />');
- // $('#'+id).html('<br />');
- // $('#live').html('- Live !');
- //switchVideo(video_id, video_url);
+ if ($(video_container).is(':empty')){
+ $(video_container).html(video_html);
+ }
$('.countdown-overlay').hide();
hideRemaining();
+ distance_out = 0;
}
}
function hideRemaining() {
- var now = moment().tz("Europe/Paris").format(); //moment(new Date());
+ var now = moment().tz("Europe/Paris").format();
var distance_in = end.diff(now);
if (distance_in < 0) {
nextEvent();
showRemaining();
+ if (! $(video_container).is(':empty')){
+ $(video_container).empty();
+ }
$('.countdown-overlay').show();
+ distance_in = 0;
}
}
}
function start() {
- // out of event
- if (distance_out > 0) {
- showRemaining();
- }
+ // out of event
+ if (distance_out > 0) {
+ showRemaining();
+ }
- // meanwhile an event
- if (distance_in > 0) {
- hideRemaining();
- }
+ // meanwhile an event
+ if (distance_in > 0) {
+ hideRemaining();
+ }
}
// initialize
+ video_html = $(video_container).html();
+ $(video_container).empty();
init();
}
{% endblock %}
{% block page_content %}
-
- {% if type == "youtube" %}
- {% if object.youtube_id %}
- <p class="intro">If YouTube streaming is not working, try HTML5 version by <a href="{% url 'organization-streaming-detail' slug 'html5' %}" title="">clicking here</a></p>
- <iframe src="https://www.youtube.com/embed/{{ object.youtube_id }}?ecver=2" width="100%" height="100%" frameborder="0" allowfullscreen></iframe>
- {% else %}
- <p>Please fill youtube id</p>
- {% endif %}
- {% elif type == "html5" %}
- {% if object.html5_url %}
- <p class="intro">If HTML5 streaming is not working, try Youtube version by <a href="{% url 'organization-streaming-detail' slug 'youtube' %}" title="">clicking here</a></p>
- <video id="live-streaming" width="100%" height="100%" controls autoplay>
- <source src="{{ object.html5_url }}" type="video/webm">
- </video>
- {% else %}
- <p>Please fill html5 live streaming url</p>
+ <div id="video_container">
+ {% if type == "youtube" %}
+ {% if object.youtube_id %}
+ <p class="intro">If YouTube streaming is not working, try HTML5 version by <a href="{% url 'organization-streaming-detail' slug 'html5' %}" title="">clicking here</a></p>
+ <iframe src="https://www.youtube.com/embed/{{ object.youtube_id }}?ecver=2" width="100%" height="100%" frameborder="0" allowfullscreen></iframe>
+ {% else %}
+ <p>Please fill youtube id</p>
+ {% endif %}
+ {% elif type == "html5" %}
+ {% if object.html5_url %}
+ <p class="intro">If HTML5 streaming is not working, try Youtube version by <a href="{% url 'organization-streaming-detail' slug 'youtube' %}" title="">clicking here</a></p>
+ <video id="live-streaming" width="100%" height="100%" controls autoplay>
+ <source src="{{ object.html5_url }}" type="video/webm">
+ </video>
+ {% else %}
+ <p>Please fill html5 live streaming url</p>
+ {% endif %}
{% endif %}
- {% endif %}
-
+ </div>
<div class="countdown-overlay">
<div id="countdown-title"></div>
<div id="countdown"></div>
<script type="text/javascript">
var json_event = {{ json_event|safe }}
- CountDownTimer(json_event, 'countdown', 'live-streaming');
+ CountDownTimer(json_event, 'countdown', 'live-streaming', '#video_container');
</script>
{% endblock %}