mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-13 02:40:21 +00:00
force update entry data on playback, hide subtitle button if no sub tracks are found, first load settings fix, multi-audio track support
This commit is contained in:
parent
0307755ee0
commit
f9a7e3eea0
6 changed files with 55 additions and 21 deletions
|
|
@ -195,7 +195,7 @@
|
|||
</div>
|
||||
<div class="col-4 d-flex justify-content-end">
|
||||
<span id="dl" class="material-icons pointer"
|
||||
title="Wait For File To Fully Download Before Saving To Drive">
|
||||
title="Wait For File To Fully Download Before Saving To Drive" disabled>
|
||||
get_app
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -213,11 +213,10 @@
|
|||
</span>
|
||||
<div class="playlist dropdown dropup">
|
||||
<span class="material-icons ctrl" title="Playlist [P]" id="bpl" data-toggle="dropdown"
|
||||
id="playlist-popover" aria-haspopup="true" aria-expanded="false" data-name="btnpl"
|
||||
disabled>
|
||||
aria-haspopup="true" aria-expanded="false" data-name="btnpl" disabled>
|
||||
playlist_play
|
||||
</span>
|
||||
<div class="dropdown-menu" aria-labelledby="playlist-popover" id="playlistMenu">
|
||||
<div class="dropdown-menu" aria-labelledby="bpl" id="playlistMenu">
|
||||
</div>
|
||||
</div>
|
||||
<div class="volume">
|
||||
|
|
@ -226,6 +225,15 @@
|
|||
</span>
|
||||
<input type="range" value="100" id="volume">
|
||||
</div>
|
||||
<div class="audio-tracks dropdown dropup">
|
||||
<span class="material-icons ctrl" title="Audio Tracks [T]" id="baudio"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-name="btnaudio"
|
||||
disabled>
|
||||
queue_music
|
||||
</span>
|
||||
<div class="dropdown-menu" aria-labelledby="baudio" id="audioTracksMenu">
|
||||
</div>
|
||||
</div>
|
||||
<span class="ts" id="elapsed">00:00</span>
|
||||
<div class="prog">
|
||||
<input type="range" min="0" max="1000" value="0" id="progress">
|
||||
|
|
@ -234,11 +242,10 @@
|
|||
<span class="ts" id="remaining">00:00</span>
|
||||
<div class="subtitles dropdown dropup with-arrow">
|
||||
<span class="material-icons ctrl" title="Subtitles [C]" id="bcap" data-toggle="dropdown"
|
||||
id="subtitle-popover" aria-haspopup="true" aria-expanded="false" data-name="btncap">
|
||||
aria-haspopup="true" aria-expanded="false" data-name="btncap" disabled>
|
||||
subtitles
|
||||
</span>
|
||||
<div class="dropdown-menu dropdown-menu-center" aria-labelledby="subtitle-popover"
|
||||
id="subMenu">
|
||||
<div class="dropdown-menu dropdown-menu-center" aria-labelledby="bcap" id="subMenu">
|
||||
</div>
|
||||
</div>
|
||||
<span class="material-icons ctrl" title="Popout Window [P]" id="bpip" data-name="btnpip">
|
||||
|
|
@ -334,7 +341,7 @@
|
|||
</div>
|
||||
<div class="custom-switch mb-20" data-toggle="tooltip" data-placement="top"
|
||||
data-title="Pauses/Resumes Video Playback When Tabbing In/Out Of The App.">
|
||||
<input type="checkbox" id="player10">
|
||||
<input type="checkbox" id="player10" checked>
|
||||
<label for="player10">Pause When Tabbing Out</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -510,9 +510,6 @@ async function nyaaSearch(media, episode) {
|
|||
if (parseInt(episode) < 10) {
|
||||
episode = `0${episode}`
|
||||
}
|
||||
if (media.status == "FINISHED") {
|
||||
|
||||
}
|
||||
|
||||
let table = document.querySelector("tbody.results")
|
||||
let results = await nyaaRss(media, episode)
|
||||
|
|
@ -617,8 +614,10 @@ async function releasesRss() {
|
|||
|
||||
let media = await resolveName(regexParse[2], "SearchReleasesSingle"),
|
||||
template = cardCreator(media, regexParse[2], episode)
|
||||
template.onclick = () => {
|
||||
template.onclick = async () => {
|
||||
addTorrent(i('link').textContent, media, episode)
|
||||
let res = await alRequest(media.id, "SearchIDSingle")
|
||||
store[regexParse[2]] = res.data.Media // force updates entry data on play in case its outdated, needs to be made cleaner and somewhere else...
|
||||
}
|
||||
frag.appendChild(template)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ function cleanupVideo() { // cleans up objects, attemps to clear as much video c
|
|||
}
|
||||
nowPlayingDisplay.textContent = ""
|
||||
onProgress = undefined;
|
||||
bcap.setAttribute("disabled", "")
|
||||
bnext.removeAttribute("disabled")
|
||||
navNowPlaying.classList.add("d-none")
|
||||
if ('mediaSession' in navigator)
|
||||
|
|
@ -86,6 +87,11 @@ async function buildVideo(file, nowPlaying) {
|
|||
video.addEventListener("canplay", resetBuffer);
|
||||
video.addEventListener("loadeddata", initThumbnail);
|
||||
video.addEventListener("loadedmetadata", updateDisplay);
|
||||
video.onloadedmetadata = () => {
|
||||
updateDisplay();
|
||||
if (video.audioTracks && video.audioTracks.length > 1)
|
||||
baudio.removeAttribute("disabled")
|
||||
}
|
||||
video.addEventListener("ended", autoNext);
|
||||
video.addEventListener("waiting", isBuffering);
|
||||
video.addEventListener("timeupdate", updateDisplay);
|
||||
|
|
@ -172,7 +178,7 @@ let onProgress
|
|||
|
||||
// visibility loss
|
||||
document.addEventListener("visibilitychange", () => {
|
||||
if (settings.player10 && typeof video !== 'undefined')
|
||||
if (settings.player10 && typeof video !== 'undefined' && !video.ended)
|
||||
document.visibilityState === "hidden" ? video.pause() : playVideo();
|
||||
})
|
||||
|
||||
|
|
@ -445,7 +451,7 @@ updateVolume(parseInt(settings.player1))
|
|||
// PiP
|
||||
|
||||
async function btnpip() {
|
||||
if (typeof video !== 'undefined') {
|
||||
if (typeof video !== 'undefined' && video.readyState) {
|
||||
if (!playerData.octopusInstance) {
|
||||
video !== document.pictureInPictureElement ? await video.requestPictureInPicture() : await document.exitPictureInPicture();
|
||||
} else {
|
||||
|
|
@ -591,12 +597,7 @@ function btncap() {
|
|||
}
|
||||
function selectLang(lang) {
|
||||
for (let track of video.textTracks) {
|
||||
if (track.language == lang) {
|
||||
track.mode = 'showing';
|
||||
}
|
||||
else {
|
||||
track.mode = 'hidden';
|
||||
}
|
||||
track.language == lang ? track.mode = 'showing' : track.mode = 'hidden';
|
||||
}
|
||||
btncap()
|
||||
}
|
||||
|
|
@ -620,6 +621,31 @@ function btnpl() {
|
|||
playlistMenu.appendChild(frag)
|
||||
}
|
||||
|
||||
// audio tracks
|
||||
|
||||
function btnaudio() {
|
||||
let frag = document.createDocumentFragment()
|
||||
for (let track of video.audioTracks) {
|
||||
let template = document.createElement("a")
|
||||
template.classList.add("dropdown-item", "pointer", "text-capitalize")
|
||||
template.innerHTML = track.language || (!Object.values(video.audioTracks).some(track => track.language == "eng" || track.language == "en") ? "eng" : track.label)
|
||||
track.enabled == true ? template.classList.add("text-white") : template.classList.add("text-muted")
|
||||
template.onclick = () => {
|
||||
selectAudio(track.id)
|
||||
}
|
||||
frag.appendChild(template)
|
||||
}
|
||||
|
||||
audioTracksMenu.textContent = '';
|
||||
audioTracksMenu.appendChild(frag)
|
||||
}
|
||||
function selectAudio(id) {
|
||||
for (let track of video.audioTracks) {
|
||||
track.id == id ? track.enabled = true : track.enabled = false;
|
||||
}
|
||||
seek(-1); // stupid fix because video freezes up when chaging tracks
|
||||
btnaudio()
|
||||
}
|
||||
// keybinds
|
||||
|
||||
document.onkeydown = (a) => {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ function registerProtocol() {
|
|||
|
||||
if (!localStorage.getItem("settings")) {
|
||||
saveSettings()
|
||||
location.reload()
|
||||
} else {
|
||||
settings = JSON.parse(localStorage.getItem("settings"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ function subStream(stream) {
|
|||
} else {
|
||||
playerData.subtitleStream = new SubtitleStream()
|
||||
playerData.subtitleStream.once('tracks', pTracks => {
|
||||
bcap.removeAttribute("disabled")
|
||||
pTracks.forEach(track => {
|
||||
if (track.type == "ass") {
|
||||
if (!playerData.headers) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ window.onbeforeunload = () => {
|
|||
}
|
||||
client.torrents[0] ? client.torrents[0].destroy() : ""
|
||||
client.destroy()
|
||||
resetVideo()
|
||||
cleanupVideo()
|
||||
if (playerData.fonts) {
|
||||
playerData.fonts.forEach(file => {
|
||||
URL.revokeObjectURL(file)
|
||||
|
|
|
|||
Loading…
Reference in a new issue