video.html 4.62 KB
Newer Older
1
<%page expression_filter="h"/>
2

3 4 5 6
<%!
from django.utils.translation import ugettext as _
from openedx.core.djangolib.js_utils import js_escaped_string
%>
7
% if display_name is not UNDEFINED and display_name is not None:
8
    <h3 class="hd hd-2">${display_name}</h3>
Piotr Mitros committed
9
% endif
10

11 12
<div
    id="video_${id}"
13
    class="video closed"
Alexander Kryklia committed
14 15 16
    data-metadata='${metadata}'
    data-bumper-metadata='${bumper_metadata}'
    data-poster='${poster}'
17
    tabindex="-1"
18
>
Valera Rozuvan committed
19 20
    <div class="focus_grabber first"></div>

21
    <div class="tc-wrapper">
22
      <div class="video-wrapper">
23
          <span tabindex="0" class="spinner" aria-hidden="false" aria-label="${_('Loading video player')}"></span>
24
          <span tabindex="-1" class="btn-play is-hidden" aria-hidden="true" aria-label="${_('Play video')}"></span>
25
          <div class="video-player-pre"></div>
26
          <div class="video-player">
27
              <div id="${id}"></div>
28
              <h4 class="hd hd-4 video-error is-hidden">${_('No playable video sources found.')}</h4>
29
          </div>
30
          <div class="video-player-post"></div>
31
          <div class="closed-captions"></div>
32
          <div class="video-controls is-hidden">
33
              <div>
Alexander Kryklia committed
34 35
                  <div class="vcr"><div class="vidtime">0:00 / 0:00</div></div>
                  <div class="secondary-controls"></div>
36
              </div>
37 38
          </div>
      </div>
39
    </div>
40

Valera Rozuvan committed
41
    <div class="focus_grabber last"></div>
42
  <ul class="wrapper-downloads">
43
    % if download_video_link:
polesye committed
44
        <li class="video-sources video-download-button">
45
            <a href="${download_video_link}">${_('Download video')}</a>
46 47 48
        </li>
    % endif
    % if track:
polesye committed
49
        <li class="video-tracks video-download-button">
50
          % if transcript_download_format:
51
            <a href="${track}">${_('Download transcript')}</a>
52
            <div class="a11y-menu-container">
Alexander Kryklia committed
53 54
                <a class="a11y-menu-button" href="#" title="${'.' + transcript_download_format}" role="button" aria-disabled="false">${'.' + transcript_download_format}</a>
                <ol class="a11y-menu-list" role="menu">
55 56 57 58 59 60
                % for item in transcript_download_formats_list:
                  % if item['value'] == transcript_download_format:
                  <li class="a11y-menu-item active">
                  % else:
                  <li class="a11y-menu-item">
                  % endif
61 62
                  ## This is necessary so we don't scrape 'display_name' as a string.
                  <% dname = item['display_name'] %>
Alexander Kryklia committed
63
                      <a class="a11y-menu-item-link" href="#${item['value']}" title="${_(dname)}" data-value="${item['value']}" role="menuitem" aria-disabled="false">
64
                        ${_(dname)}
65 66 67 68 69 70
                      </a>
                  </li>
                % endfor
                </ol>
            </div>
          % else:
71
            <a href="${track}" class="external-track">${_('Download transcript')}</a>
72
          % endif
73 74
        </li>
    % endif
polesye committed
75 76
    % if handout:
        <li class="video-handout video-download-button">
77
            <a href="${handout}" target="_blank">${_('Download Handout')}</a>
polesye committed
78 79
        </li>
    % endif
80 81 82 83 84 85 86

    % if branding_info:
      <li id="branding" class="branding">
        <span class="host-tag">${branding_info['logo_tag']}</span>
        <a href="${branding_info['url']}" target="_blank" title="${branding_info['logo_tag']}"><img class="brand-logo" src="${branding_info['logo_src']}" alt="${branding_info['logo_tag']}" /></a>
      </li>
    % endif
87
  </ul>
88
</div>
89 90
% if cdn_eval:
<script>
91
  //TODO: refactor this js into a separate file.
92 93
  function sendPerformanceBeacon(id, expgroup, value, event_name) {
    var data = {event: event_name, id: id, expgroup: expgroup, value: value, page: "html5vid"};
94 95
    $.ajax({method: "POST", url: "/performance", data: data});
  }
alawibaba committed
96 97
  var cdnStartTime;
  var salt = Math.floor((1 + Math.random()) * 0x100000).toString(36);
98
  var id = "${id | n, js_escaped_string}";
99
  function initializeCDNExperiment() {
100
    sendPerformanceBeacon(id + "_" + salt, ${cdn_exp_group}, "", "load");
101
    cdnStartTime = Date.now();
102 103 104
    $.each(['loadstart', 'abort', 'error', 'stalled', 'loadedmetadata',
                    'loadeddata', 'canplay', 'canplaythrough', 'seeked'],
                    function(index, eventName) {
105
      $("#video_" + id).bind("html5:" + eventName, null, function() {
106
        timeElapsed = Date.now() - cdnStartTime;
107
        sendPerformanceBeacon(id + "_" + salt, ${cdn_exp_group}, timeElapsed, eventName);
108
      });
109 110
    });
  }
111 112
  $("#video_" + id).bind("initialize", null, initializeCDNExperiment);
  if ($("#video_" + id).hasClass("is-initialized")) {
113 114 115
    initializeCDNExperiment();
  }
</script>
116
% endif;