templates/play/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}UrConnex - Watching {{ seotag }}{% endblock %}
  3. {% block body %}
  4.     <nav class="navbar navbar-default navbar-fixed-top">
  5.         <div class="container">
  6.             <div class="navbar-header">
  7.                 <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
  8.                     <span class="sr-only">Toggle navigation</span>
  9.                     <span class="icon-bar"></span>
  10.                     <span class="icon-bar"></span>
  11.                     <span class="icon-bar"></span>
  12.                 </button>
  13.                 <a class="navbar-brand" href="/"><img src="/images/urlogo.png" width="100px" class="img-responsive"/></a>
  14.                 {% if uid is defined %}
  15.                     <ul class="nav navbar-nav navbar-right">
  16.                         <li><a href="/dashboard"><i class="fa fa-2x fa-home"></i></a></li>
  17.                         <li><a href="/chat"><i class="fa fa-2x fa-comment"></a></i></li>
  18.                         <li><a href="/profile"><i class="fa fa-2x fa-user"></i></a></li>
  19.                         <li><a href="/addressbook"><i class="fa fa-2x fa-phone-square"></i></a></li>
  20.                         <li><a href="/index/logout"><i class="fa fa-2x fa-sign-out"></i></a></li>
  21.                     </ul>
  22.                 {% else %}
  23.                     <a href="/home/login">Login</a> | 
  24.                     <a href="/home/signup">Signup</a>
  25.                 {% endif %}
  26.             </div>
  27.         </div>
  28.     </nav>
  29.     <div class="container loading" style="width: 1000px; margin-left: auto; margin-right: auto; margin-top: 150px;">
  30.         <div class="row">
  31.             <div class="col-lg-6">
  32.                 <input type="hidden" id="filename" value="{{ filename }}">
  33.                 <img src="/images/image_loading.gif" class="img-responsive"/>
  34.                 <p>Loading Video...Please be patient...
  35.                 <div id="progress"></div>
  36.                 </p>
  37.             </div>
  38.         </div>
  39.     </div>
  40.     <div class="container links" style="width: 1000px; margin-left: auto; margin-right: auto; margin-top: 150px;">
  41.         <div class="row">
  42.             <div class="col-lg-6 col-lg-offset-2">
  43.                 {% if uid is defined %}
  44.                     <a href="/tools/convert?name={{ mp4 }}" class="btn btn-primary btn-block">Make Ringtone</a>
  45.                     <a href="/tools/makevideo?name={{ mp4 }}" class="btn btn-primary btn-block">Make Video</a>
  46.                     <a href="/tools/capture?name={{ mp4 }}" class="btn btn-primary btn-block">Screenshot</a>
  47.                     <a href="/tools/share" class="btn btn-primary btn-block">Share Video</a>
  48.                     <a href="/tools/shorten?name={{ mp4 }}" class="btn btn-primary btn-block">Make Clip</a>
  49.                     <a href="/tools/delete?name={{ mp4 }}" class="btn btn-primary btn-block">Delete</a>
  50.                     <a href="{{ gp }}" class="btn btn-primary btn-block">Download Video</a>
  51.                     <p>OR copy below link and open in your device player</p>
  52.                 {% else %}
  53.                     {% if gp is defined %}
  54.                         <a href="{{ gp }}" class="btn btn-primary btn-block">Download Video</a>
  55.                         <p>OR copy below link and open in your device player</p>
  56.                         <a href="{{gp}}">{{ gp }}
  57.                     {% endif %}
  58.                 {%  endif %}
  59.                             {% if desktop is defined %}
  60.                                 <div class="container links"></div>
  61.                             {% else %}
  62.                                 <div class="container links"></div>
  63.                             {% endif %}
  64.             </div>
  65.         </div>
  66.     </div>
  67.         <hr/>
  68.         <div class="row">
  69.             {% for media in mediafiles %}
  70.                 {# {% if file_exists(media.filename) %} #}
  71.                     <div class="col-md-4" style="margin:10px;">
  72.                         <a class="thumbnail" href="/play/index/{{ media.filename }}">
  73.                             <img class="img-fluid"
  74.                                  src="{{ media.thumbnail }}"
  75.                                  alt="{{ media.filename }}" width="150em"> 
  76.                         </a> 
  77.                    </div>
  78.                 {# {% endif %} #}
  79.             {% endfor %}
  80.         </div>
  81.     </div>
  82. {% endblock %}
  83. {% block javascripts %}
  84. <script src="/js/jquery.min.js"></script>   
  85. <script>
  86. $(document).ready(function() {
  87.   var filename = $('#filename').val();
  88.   console.log("We are here" + filename);
  89.     // Display the loading image and progress bar
  90.     $('.links').html(
  91.       '<div class="container loading" style="width: 1000px; margin-left: auto; margin-right: auto;">' +
  92.       '<div class="row">' +
  93.       '<div class="col-lg-6">' +
  94.       '' +
  95.       '<div id="progress"></div>' +
  96.       '</div>' +
  97.       '</div>' +
  98.       '</div>'
  99.     );
  100.     // Make the AJAX call to the process method
  101.   $.ajax({
  102.       url: '/play/process/' + filename,
  103.       type: 'GET',
  104.       dataType: 'json',
  105.       xhr: function() {
  106.         var xhr = new window.XMLHttpRequest();
  107.         console.log(xhr);
  108.         // Add progress event listener to update progress bar
  109.         xhr.addEventListener('progress', function(event) {
  110.           if (event.lengthComputable) {
  111.             var percentComplete = event.loaded / event.total * 100;
  112.             $('#progress').css('width', percentComplete + '%');
  113.           }
  114.         }, false);
  115.         return xhr;
  116.       },
  117.       success: function(response) {
  118.           console.log(response);
  119.         // Hide the loading image and progress bar
  120.         $('.loading').hide();
  121.         $('.links').show();
  122.         {% if desktop is defined %}
  123.             // Display the video player
  124.             var videoPlayer = $('<video></video>')
  125.               .attr('id', 'my-video')
  126.               .attr('class', 'video-js')
  127.               .attr('controls', 'controls')
  128.               .attr('preload', 'auto')
  129.               .attr('width', '640')
  130.               .attr('height', '264')
  131.               .attr('poster', response.poster)
  132.               .attr('data-setup', '{}');
  133.             var mp4Source = $('<source></source>')
  134.               .attr('src', response.mp4)
  135.               .attr('type', 'video/mp4');
  136.             var webmSource = $('<source></source>')
  137.               .attr('src', response.webm)
  138.               .attr('type', 'video/webm');
  139.             videoPlayer.append(mp4Source, webmSource);
  140.             $('.links').html('').append(videoPlayer);
  141.         {% else %}
  142.             // Display the links
  143.             var linksContainer = $('.links');
  144.             var downloadLink = $('<a></a>')
  145.               .attr('href', response.gp)
  146.               .addClass('btn btn-primary btn-block')
  147.               .text('Download Video');
  148.             var copyLink = $('<p></p>')
  149.               .text('OR copy below link and open in your device player');
  150.             var copyLinkUrl = $('<a></a>')
  151.               .attr('href', response.gp)
  152.               .text(response.gp);
  153.             console.log("The link is" + copyLinkUrl);
  154.             linksContainer.html('').append(downloadLink, copyLink, copyLinkUrl);
  155.         {% endif %}
  156.     },
  157.     error: function(xhr, status, error) {
  158.         console.error(error);
  159.         console.error(xhr);
  160.         console.error(status);
  161.     }
  162.   });
  163. });
  164. </script>
  165. {% endblock %}
  166.