Spaces:
Running
Running
Add gi_cutscn_viewer.html
Browse files- gi_cutscn_viewer.html +193 -0
gi_cutscn_viewer.html
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang='en'>
|
3 |
+
<head>
|
4 |
+
<title>tst</title>
|
5 |
+
<meta charset="utf-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.00">
|
7 |
+
<meta name="robots" content="noindex,nofollow,noarchive">
|
8 |
+
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
|
9 |
+
<script src="https://cdn.plyr.io/3.7.3/plyr.js"></script>
|
10 |
+
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js"></script>
|
11 |
+
<link rel="stylesheet" href="https://cdn.plyr.io/3.7.3/plyr.css" />
|
12 |
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" />
|
13 |
+
<link href="https://cdn.jsdelivr.net/gh/daydreamer-json/SomeFontRepo@main/somefontrepo.css" rel="stylesheet" type="text/css" media="all">
|
14 |
+
<style>
|
15 |
+
html, body {
|
16 |
+
color: #fff;
|
17 |
+
background: #000;
|
18 |
+
margin: 0;
|
19 |
+
line-height: 1;
|
20 |
+
width: 100vw;
|
21 |
+
height: 100vh;
|
22 |
+
font-family: 'A-OTF UD Shin Go Pro', system-ui;
|
23 |
+
}
|
24 |
+
.main2 {
|
25 |
+
display: flex;
|
26 |
+
flex-direction: column;
|
27 |
+
height: 100vh;
|
28 |
+
}
|
29 |
+
#video, .plyr {
|
30 |
+
flex-grow: 1;
|
31 |
+
height: 100%;
|
32 |
+
width: 100%;
|
33 |
+
}
|
34 |
+
</style>
|
35 |
+
</head>
|
36 |
+
<body>
|
37 |
+
<div class="main">
|
38 |
+
<div class="main2">
|
39 |
+
<p><span>File:</span><span>
|
40 |
+
<select id="filePullDownMenu" name="videoName" required>
|
41 |
+
</select>
|
42 |
+
</span><span id="audioTrackPullDownRow" hidden><br>
|
43 |
+
<span>Audio:</span><span>
|
44 |
+
<select id="audioTrackPullDownMenu" name="audioTrackName" required>
|
45 |
+
</select>
|
46 |
+
</span></span></p>
|
47 |
+
<video id="video" controls crossorigin>
|
48 |
+
<source type="application/x-mpegURL">
|
49 |
+
</video>
|
50 |
+
</div>
|
51 |
+
</div>
|
52 |
+
<script>
|
53 |
+
const default_file = 'Cs_LQ1101502_ShenheBattle_Boy';
|
54 |
+
const default_hls_pl_type = 'normal';
|
55 |
+
const videoData_BaseURL = 'https://raw.githubusercontent.com/daydreamer-json/gi_cutscn/main/media/hls/master';
|
56 |
+
const defaultOptions = {};
|
57 |
+
document.addEventListener('DOMContentLoaded', () => {
|
58 |
+
loadDatabase();
|
59 |
+
var playerElement = document.getElementById('video');
|
60 |
+
var videoSrc = `${videoData_BaseURL}/${default_hls_pl_type}/${default_file}.m3u8`;
|
61 |
+
var hls = new Hls();
|
62 |
+
document.getElementById('filePullDownMenu').addEventListener('change', changeSrc);
|
63 |
+
document.getElementById('audioTrackPullDownMenu').addEventListener('change', changeAudioTrack);
|
64 |
+
hlsInitialize(videoSrc, playerElement);
|
65 |
+
})
|
66 |
+
function loadDatabase () {
|
67 |
+
let file_database_url = 'https://raw.githubusercontent.com/daydreamer-json/gi_cutscn/main/cutscn_list.json';
|
68 |
+
let file_database_req = new XMLHttpRequest();
|
69 |
+
file_database_req.open('GET', file_database_url);
|
70 |
+
file_database_req.responseType = 'json';
|
71 |
+
file_database_req.send();
|
72 |
+
file_database_req.onload = function () {
|
73 |
+
const file_database = file_database_req.response;
|
74 |
+
for (let i = 0; i < file_database.length; i++) {
|
75 |
+
var temp_option = document.createElement('option');
|
76 |
+
var temp_textNode = document.createTextNode(file_database[i]);
|
77 |
+
temp_option.appendChild(temp_textNode);
|
78 |
+
temp_option.setAttribute('value',file_database[i]);
|
79 |
+
if (file_database[i] == default_file) {
|
80 |
+
temp_option.setAttribute('selected',true);
|
81 |
+
};
|
82 |
+
document.getElementById('filePullDownMenu').appendChild(temp_option);
|
83 |
+
};
|
84 |
+
};
|
85 |
+
}
|
86 |
+
function hlsInitialize (sourceURL, element) {
|
87 |
+
if (hls) {
|
88 |
+
hls.detachMedia();
|
89 |
+
};
|
90 |
+
if (Hls.isSupported()) {
|
91 |
+
var hls = new Hls();
|
92 |
+
hls.loadSource(sourceURL);
|
93 |
+
hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) {
|
94 |
+
const availableQualities = hls.levels.map((l) => l.height);
|
95 |
+
availableQualities.unshift(0);
|
96 |
+
defaultOptions.quality = {
|
97 |
+
default: 0,
|
98 |
+
options: availableQualities,
|
99 |
+
forced: true,
|
100 |
+
onChange: (e) => updateQuality(e)
|
101 |
+
};
|
102 |
+
defaultOptions.i18n = {
|
103 |
+
qualityLabel: {
|
104 |
+
0: 'Auto'
|
105 |
+
}
|
106 |
+
};
|
107 |
+
hls.on(Hls.Events.LEVEL_SWITCHED, function (event, data) {
|
108 |
+
if (hls.autoLevelEnabled) {
|
109 |
+
document.querySelector(".plyr__menu__container [data-plyr='quality'][value='0'] span").innerHTML = `Auto (${hls.levels[data.level].height}p)`;
|
110 |
+
} else {
|
111 |
+
document.querySelector(".plyr__menu__container [data-plyr='quality'][value='0'] span").innerHTML = `Auto`;
|
112 |
+
}
|
113 |
+
});
|
114 |
+
const player = new Plyr(element, defaultOptions);
|
115 |
+
loadAvailableAudioTracks();
|
116 |
+
player.on('ready',function () {
|
117 |
+
if (hls.audioTrack) {
|
118 |
+
let audioTrackPullDownMenu = document.getElementById('audioTrackPullDownMenu');
|
119 |
+
audioTrackPullDownMenu.getElementsByTagName('option')[hls.audioTrack].setAttribute('selected',true);
|
120 |
+
};
|
121 |
+
});
|
122 |
+
|
123 |
+
});
|
124 |
+
hls.attachMedia(element);
|
125 |
+
window.hls = hls;
|
126 |
+
} else if (element.canPlayType('application/vnd.apple.mpegurl')) {
|
127 |
+
element.getElementsByTagName('source')[0].src = sourceURL;
|
128 |
+
};
|
129 |
+
}
|
130 |
+
function updateQuality (newQuality) {
|
131 |
+
if (newQuality === 0) {
|
132 |
+
window.hls.currentLevel = -1;
|
133 |
+
} else {
|
134 |
+
window.hls.levels.forEach((level, levelIndex) => {
|
135 |
+
if (level.height === newQuality) {
|
136 |
+
console.log("Found quality match with " + newQuality);
|
137 |
+
window.hls.currentLevel = levelIndex;
|
138 |
+
}
|
139 |
+
});
|
140 |
+
}
|
141 |
+
}
|
142 |
+
function changeSrc () {
|
143 |
+
let selectedFileName = document.getElementById('filePullDownMenu').value;
|
144 |
+
hlsInitialize(`${videoData_BaseURL}/${default_hls_pl_type}/${selectedFileName}.m3u8`, document.getElementById('video'));
|
145 |
+
var element = document.getElementById('video');
|
146 |
+
if (element.canPlayType('application/vnd.apple.mpegurl')) {
|
147 |
+
element.remove();
|
148 |
+
var temp_video = document.createElement('video');
|
149 |
+
temp_video.setAttribute('id', 'video');
|
150 |
+
temp_video.setAttribute('controls', true);
|
151 |
+
temp_video.setAttribute('crossorigin', true);
|
152 |
+
var temp_source = document.createElement('source');
|
153 |
+
temp_source.setAttribute('type', 'application/x-mpegURL');
|
154 |
+
temp_source.setAttribute('src', `${videoData_BaseURL}/${default_hls_pl_type}/${selectedFileName}.m3u8`);
|
155 |
+
temp_video.appendChild(temp_source);
|
156 |
+
var temp_main2 = document.getElementsByClassName('main2')[0];
|
157 |
+
temp_main2.appendChild(temp_video);
|
158 |
+
}
|
159 |
+
}
|
160 |
+
function loadAvailableAudioTracks () {
|
161 |
+
while (document.getElementById('audioTrackPullDownMenu').firstChild) {
|
162 |
+
document.getElementById('audioTrackPullDownMenu').removeChild(document.getElementById('audioTrackPullDownMenu').firstChild);
|
163 |
+
}
|
164 |
+
document.getElementById('audioTrackPullDownRow').removeAttribute('hidden');
|
165 |
+
let availableAudioTracks = {};
|
166 |
+
/*
|
167 |
+
availableAudioTracks.lang = hls.audioTracks.map((l) => l.lang);
|
168 |
+
availableAudioTracks.name = hls.audioTracks.map((l) => l.name);
|
169 |
+
*/
|
170 |
+
availableAudioTracks.lang = ['zh', 'en', 'ja', 'ko'];
|
171 |
+
availableAudioTracks.name = ['Chinese', 'English', 'Japanese', 'Korean'];
|
172 |
+
for (let i = 0; i < availableAudioTracks.lang.length; i++) {
|
173 |
+
var temp_option = document.createElement('option');
|
174 |
+
var temp_textNode = document.createTextNode(`${availableAudioTracks.lang[i]} (${availableAudioTracks.name[i]})`);
|
175 |
+
temp_option.appendChild(temp_textNode);
|
176 |
+
temp_option.setAttribute('value',i);
|
177 |
+
/*
|
178 |
+
if (hls.audioTrack == i) {
|
179 |
+
temp_option.setAttribute('selected',true);
|
180 |
+
}
|
181 |
+
*/
|
182 |
+
document.getElementById('audioTrackPullDownMenu').appendChild(temp_option);
|
183 |
+
};
|
184 |
+
}
|
185 |
+
function changeAudioTrack () {
|
186 |
+
let selectedAudioTrack = document.getElementById('audioTrackPullDownMenu').value;
|
187 |
+
if (hls) {
|
188 |
+
hls.audioTrack = selectedAudioTrack;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
</script>
|
192 |
+
</body>
|
193 |
+
</html>
|