1 2function initVideoOnPage() { 3 $('.video-player').each(function () { initVideoPlayer(this) }); 4} 5 6function initVideoPlayer(videoElem) { 7 8 const source = $(videoElem).data('url'); 9 const poster = $(videoElem).data('poster') 10 const video = videoElem; 11 12 if (poster) { 13 video.poster = poster; 14 } 15 16 const defaultOptions = {}; 17 18 if (Hls.isSupported()) { 19 // For more Hls.js options, see https://github.com/dailymotion/hls.js 20 const hls = new Hls(); 21 hls.loadSource(source); 22 23 // From the m3u8 playlist, hls parses the manifest and returns 24 // all available video qualities. This is important, in this approach, 25 // we will have one source on the Plyr player. 26 hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) { 27 28 // Transform available levels into an array of integers (height values). 29 const availableQualities = hls.levels.map((l) => l.height) 30 availableQualities.unshift(0) 31 // Add new qualities to option 32 defaultOptions.quality = { 33 default: 0, 34 options: availableQualities, 35 forced: true, 36 onChange: (e) => updateQuality(e), 37 } 38 39 hls.on(Hls.Events.LEVEL_SWITCHED, function (event, data) { 40 var span = document.querySelector(".plyr__menu__container [data-plyr='quality'][value='0'] span") 41 if (hls.autoLevelEnabled) { 42 span.innerHTML = `Auto (${hls.levels[data.level].height}p)` 43 } else { 44 span.innerHTML = `Auto` 45 } 46 }) 47 48 const player = new Plyr(video, defaultOptions); 49 player.on('languagechange', () => { 50 // Caption support is still flaky. See: https://github.com/sampotts/plyr/issues/994 51 setTimeout(() => hls.subtitleTrack = player.currentTrack, 50); 52 }); 53 54 // ÐобавиÑÑ Ð¿ÑовеÑÐºÑ Ð½Ð° завиÑание видео и попÑÑÐºÑ Ð¿ÐµÑепÑÑгнÑÑÑ Ð·Ð°Ð²Ð¸Ñание 55 let lastTime = 0; 56 window.setInterval(() => { 57 if (!player.paused) { 58 if (player.currentTime === lastTime) { 59 player.currentTime += 1; 60 } 61 lastTime = player.currentTime; 62 } 63 }, 2000); 64 }); 65 hls.attachMedia(video); 66 window.hls = hls; 67 } else { 68 // default options with no quality update in case Hls is not supported 69 video.src = source 70 const player = new Plyr(video, defaultOptions); 71 } 72 73} 74 75function updateQuality(newQuality) { 76 if (newQuality === 0) { 77 window.hls.currentLevel = -1; //Enable AUTO quality if option.value = 0 78 } else { 79 window.hls.levels.forEach((level, levelIndex) => { 80 if (level.height === newQuality) { 81 window.hls.currentLevel = levelIndex; 82 } 83 }); 84 } 85} 86 87function PrepareModal(element, intensiveId = 0, canAddToResult = false) { 88 var fileId = $(element).data('id'); 89 var path = $(element).attr('href'); 90 const params = { 91 fileId: fileId, 92 path: path 93 }; 94 const options = { 95 intensiveChildLinkId: intensiveId, 96 fileId: fileId 97 }; 98 $("#addToProgress").hide(); 99 if (canAddToResult) { 100 $("#addToProgress").click(function () { 101 $.ajax('/intensive/AddVideoToChildResult', { 102 type: 'POST', 103 data: options, 104 success: function (data, status, xhr) { 105 if (data.success) { 106 $("#addToProgress").hide(); 107 } 108 Notice.showL(data.data.message, 2000); 109 }, 110 error: function (jqXhr, textStatus, errorMessage) { 111 Notice.showL('Ðе ÑдалоÑÑ Ð´Ð¾Ð±Ð°Ð²Ð¸ÑÑ Ð²Ð¸Ð´ÐµÐ¾ в пÑогÑеÑÑ ÑÑеника', 2000); 112 } 113 }); 114 }); 115 } 116 $.ajax('/video/ShowVideoInModal', { 117 type: 'GET', 118 data: params, 119 success: function (data, status, xhr) { 120 var video = document.getElementById('videoPlayer'); 121 122 if (data.IsEncodingFailed) { 123 $('#videoEncodingErrorMessage').show(); 124 $('#videoEncodingMessage').hide(); 125 $('#videoPlayer').hide(); 126 } 127 else if (data.StreamingUrl) { 128 $('#videoPlayer').show(); 129 $('#videoEncodingErrorMessage').hide(); 130 $('#videoEncodingMessage').hide(); 131 $(video).data('url', data.StreamingUrl); 132 $(video).data('poster', data.PreviewPath); 133 134 initVideoPlayer(video); 135 } 136 else { 137 $('#videoEncodingMessage').show(); 138 $('#videoEncodingErrorMessage').hide(); 139 $('#videoPlayer').hide(); 140 } 141 142 $('#downloadVideoLink').text(data.Name) 143 $('#downloadVideoLink').attr('href', path) 144 $('#videoPlayerModal').modal('show'); 145 if (canAddToResult) { 146 $("#addToProgress").show(); 147 } 148 }, 149 error: function (jqXhr, textStatus, errorMessage) { 150 Notice.showL('Ðидео недоÑÑÑпно', 1000) 151 } 152 }); 153} 154 155 156
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.