templates/frontend/default/video.html.twig line 1

Open in your IDE?
  1. <style>
  2. .modal {
  3. background-color: rgba(0, 0, 0, .7);
  4. }
  5. .fade:not(.show) {
  6. opacity: 1;
  7. }
  8. .modal-content {
  9. background-image: unset;
  10. background-color: unset;
  11. background-clip: unset;
  12. position: relative;
  13. -webkit-background-clip: padding-box;
  14. background-clip: padding-box;
  15. border-radius: 15px;
  16. outline: 0;
  17. color: white;
  18. background-color: transparent;
  19. }
  20. .modal-header {
  21. color: white;
  22. text-shadow: black 0.1em 0.1em 0.2em;
  23. padding-bottom: 0;
  24. border: none;
  25. }
  26. .modal-footer{
  27. border-top: none;
  28. }
  29. .modal-backdrop {
  30. display: none;
  31. }
  32. .modal-body {
  33. padding: 0;
  34. margin-bottom: 5%;
  35. }
  36. #video-container{
  37. top: 47vw;
  38. left: 51%;
  39. width: 77%;
  40. transform: translate(-50%, -50%);
  41. position: absolute;
  42. }
  43. .video-timer {
  44. margin: auto;
  45. top: 80%;
  46. left: 50%;
  47. width: 80%;
  48. transform: translate(-50%, -50%);
  49. position: absolute;
  50. font-size: 16px;
  51. color: #FFFFFF;
  52. display: none;
  53. }
  54. #video_overlays{
  55. position: absolute;
  56. background-color: rgba(0, 0, 0, 0.5);
  57. z-index: 2;
  58. left: 0;
  59. right: 0;
  60. top: 0;
  61. bottom: 0;
  62. display: -webkit-flex;
  63. display: flex;
  64. align-items: center;
  65. justify-content: center;
  66. }
  67. #myProgress {
  68. margin: auto;
  69. border-radius: 10px;
  70. top: 75vw;
  71. left: 51%;
  72. width: 77%;
  73. transform: translate(-50%, -50%);
  74. position: absolute;
  75. }
  76. .bar-base {
  77. width: 100%;
  78. height: 15px;
  79. background-image:url('{{ asset('images/loadbar_bg.png') }}');
  80. background-size: 100%;
  81. background-repeat: no-repeat;
  82. border-radius: 10px;
  83. position: relative;
  84. }
  85. #bar {
  86. width: 0%;
  87. height: 15px;
  88. background-image:url('{{ asset('images/loadbar.png') }}');
  89. background-size: 100% 80%;
  90. background-repeat: no-repeat;
  91. border-radius: 10px;
  92. position: absolute;
  93. left: 4px;
  94. }
  95. .video-frame {
  96. min-height: 260px;
  97. }
  98. .frame{
  99. width: 95%
  100. }
  101. .close{
  102. background-color: transparent;
  103. top: 18%;
  104. right: 7%;
  105. z-index: 100;
  106. position: absolute;
  107. border: none;
  108. width: 8% !important;
  109. }
  110. #videoComfirmBtn{
  111. width: 60%;
  112. position: absolute;
  113. bottom: 4vw;
  114. left: 21%;
  115. }
  116. </style>
  117. <script>
  118. function gtag_action_watchVideo(result){
  119. gtag('event', 'video watch', {
  120. 'event_category': '{{ custom_data }}',
  121. 'event_label': result
  122. });
  123. }
  124. </script>
  125. <script>
  126. function reflash(){
  127. pauseVid();
  128. console.log('test');
  129. window.location.href = "{{ path('game_pre_checkAgent', {'language': app.request.locale}) }}";
  130. }
  131. function videoView() {
  132. //pauseVid();
  133. vid = document.getElementById("myVideo");
  134. if (remaingTime >= {{ video_time }}) {
  135. let countdown = vid.duration - vid.currentTime;
  136. $.post("{{ path('api_resign_mission', {'language': app.request.locale}) }}", {"jwt": jwt},
  137. function (data, status) {
  138. if (data.result == 'success') {
  139. //$("#modal_message_success").html(data.message);
  140. //$('#myModal_success').modal('show');
  141. //refresh();
  142. }
  143. else if (data.result == 'fail') {
  144. if (data.action == 'retry') {
  145. $("#modal_message").html(data.message);
  146. $('#myModal_message').modal('show');
  147. }
  148. else if (data.action == 'login') {
  149. window.location.href = "{{ path('game_pre_checkAgent', {'language': app.request.locale}) }}";
  150. }
  151. }
  152. });
  153. }
  154. }
  155. $(function () {
  156. $(document).on('hide.bs.modal', '.modal', function () {
  157. if (typeof vid !== 'undefined') {
  158. closeVideoDiv();
  159. }
  160. });
  161. });
  162. let is_embeded = false;
  163. let starttime = 0;
  164. let remaingTime = 15;
  165. let refreshIntervalId = null;
  166. function playVid() {
  167. if (!vid.paused) {
  168. vid.pause();
  169. } else {
  170. vid.play();
  171. //gtag_action_StartVideo(videoURL);
  172. }
  173. }
  174. function pauseVid() {
  175. vid.pause();
  176. }
  177. function closeVideoDiv() {
  178. if (!vid.paused) {
  179. vid.pause();
  180. }
  181. }
  182. function embedVideo() {
  183. gtag_action_watchVideo('success');
  184. is_embeded = false;
  185. starttime = 0;
  186. remaingTime = 0;
  187. refreshIntervalId = null;
  188. if (is_embeded === false) {
  189. videoURL = '{{ asset('/video/~video_link~') }}';
  190. videoembed = '<div id="video_overlays"><img src="{{ asset('images/play_button.png') }}" style="width: 35%;"/></div><video id="myVideo" width="100%" height="auto" webkit-playsinline="true" playsinline="true" > <source src="{{ asset('video/' ~ video_link) }}" type="video/mp4">Your browser does not support HTML5 video. </video>';
  191. document.getElementById('video-container').innerHTML = videoembed;
  192. document.getElementById("myVideo").controls = true;
  193. document.getElementById("myVideo").load();
  194. vid = document.getElementById("myVideo");
  195. is_embeded = true;
  196. document.getElementById("timer-div").innerHTML = "{{ 'video.countdown' | trans }}" + {{ video_time }};
  197. document.getElementById("bar").style.width = "0%";
  198. $("#videoComfirmBtn").attr('disabled', true);
  199. document.getElementById("videoComfirmBtn").style.visibility = "hidden";
  200. $("#close").attr('disabled', false);
  201. document.getElementById("close").style.visibility = "visible";
  202. let timer = null;
  203. function updateTimeLable() {
  204. remaingTime = Math.floor(remaingTime + 1);
  205. if (remaingTime < {{ video_time }}) {
  206. document.getElementById("timer-div").innerHTML = "{{ 'video.countdown' | trans }}" + remaingTime;
  207. document.getElementById("bar").style.width = ((remaingTime / {{ video_time }})*98) + "%";
  208. }
  209. else {
  210. if (remaingTime == {{ video_time }})
  211. {
  212. document.getElementById("timer-div").innerHTML = "{{ 'video.countdown' | trans }}" + remaingTime;
  213. document.getElementById("bar").style.width = 98 + "%";
  214. }
  215. $("#videoComfirmBtn").attr('disabled', false);
  216. document.getElementById("videoComfirmBtn").style.display = "inline-block";
  217. document.getElementById("videoComfirmBtn").style.visibility = "visible";
  218. videoView();
  219. $("#close").attr('disabled', true);
  220. document.getElementById("close").style.visibility = "hidden";
  221. clearInterval(refreshIntervalId);
  222. }
  223. }
  224. vid.addEventListener("pause", function () {
  225. clearInterval(refreshIntervalId);
  226. $('#video_overlays').show();
  227. });
  228. vid.addEventListener("ended", function () {
  229. if (remaingTime >= 28) {
  230. $("#videoComfirmBtn").attr('disabled', false);
  231. document.getElementById("videoComfirmBtn").style.display = "inline-block";
  232. }
  233. });
  234. vid.addEventListener("play", function () {
  235. if (starttime == 0) {
  236. refreshIntervalId = setInterval(updateTimeLable, 1000);
  237. }
  238. else {
  239. refreshIntervalId = setInterval(updateTimeLable, 1000);
  240. }
  241. $('#video_overlays').hide();
  242. });
  243. }
  244. var myModal_mission_start = $('#myModal_video').offset().top;
  245. var headerOffset = 0; // Adjust this value based on your header height
  246. $('html, body').animate({
  247. scrollTop: myModal_mission_start - headerOffset
  248. }, 500);
  249. }
  250. </script>
  251. <div class="modal fade" id="myModal_video" role="dialog" data-backdrop="static">
  252. <div class="modal-dialog">
  253. <div class="modal-content" style="box-shadow:none;border:none;">
  254. <div class="modal-header">
  255. <button type="button" class="close" data-dismiss="modal">
  256. <img id="close" src="{{ asset('images/close_btn.png') }}" class="close_img" alt="close" align="right">
  257. </button>
  258. </div>
  259. <div class="modal-body" style="margin-top:10%">
  260. <div onclick="playVid()">
  261. <img src="{{ asset('images/resign_message.png') }}" class="frame video-frame"/>
  262. <div id="video-container"></div>
  263. {# <div class="dialog-desc"> {{ 'mission.video' | trans }} </div> #}
  264. <div id="myProgress">
  265. <div id="bar"></div>
  266. <div class='bar-base'></div>
  267. </div>
  268. <div id="timer-div" class="video-timer"></div>
  269. </div>
  270. <div id="videoComfirmBtn" onclick='reflash()'>
  271. <img src="{{ asset('images/done_btn.png') }}" style="width: 65%;"
  272. data-dismiss="modal" class="modal-footer-btn video-btn">
  273. </div>
  274. </div>
  275. </div>
  276. </div>
  277. </div>