subtitle fixes, destroying fixes

This commit is contained in:
ThaUnknown 2020-10-02 22:10:20 +02:00
parent 906301a61e
commit c0c587e5f5
6 changed files with 42 additions and 34 deletions

View file

@ -196,7 +196,6 @@ input#progress[type=range]::before {
color: #ececec;
white-space: nowrap;
align-self: center;
padding: 0 1.2rem;
left: var(--progress);
font-weight: 600;
transition: .2s opacity ease;

View file

@ -156,7 +156,7 @@
<span class="ts" id="upSpeed">0 B/s</span>
</div>
<div class="col d-flex justify-content-end">
<a id="dl" class="material-icons">
<a id="dl" class="material-icons" title="Wait For File To Fully Download Before Saving To Drive">
<span class="material-icons">
get_app
</span>

View file

@ -314,8 +314,8 @@ function btncap() {
for (let track of video.textTracks) {
let template = document.createElement("a")
template.classList.add("dropdown-item", "pointer")
template.innerHTML = track.language
template.classList.add("dropdown-item", "pointer", "text-capitalize")
template.innerHTML = track.language || (!Object.values(video.textTracks).some(track => track.language == "eng" || track.language == "en") ? "eng" : track.label)
if (track.mode == "showing") {
template.classList.add("text-white")
off.classList.add("text-muted")
@ -341,7 +341,7 @@ function selectLang(lang) {
track.mode = 'hidden';
}
}
bcap()
btncap()
}
// keybinds

View file

@ -8,9 +8,9 @@ function parseSubs(stream) {
subtitleStream = new SubtitleStream(subtitleStream)
} else {
subtitleStream = new SubtitleStream()
subtitleStream.once('tracks', function (pTracks) {
subtitleStream.once('tracks', pTracks => {
pTracks.forEach(track => {
tracks[track.number] = video.addTextTrack('captions', track.type, track.language || track.number)
tracks[track.number] = video.addTextTrack('captions', track.type, track.language)
})
if (video.textTracks[0]) {
video.textTracks[0].mode = "showing"

View file

@ -1,28 +1,29 @@
var client = new WebTorrent()
window.onbeforeunload = ()=>{
client.torrents[0].store.destroy()
client.torrents[0].destroy()
let client = new WebTorrent()
window.onbeforeunload = () => {
client.torrents[0] ? client.torrents[0].store.destroy() : ""
client.torrents[0] ? client.torrents[0].destroy() : ""
client.destroy()
}
}
const announceList = [
['wss://tracker.openwebtorrent.com'],
['wss://tracker.btorrent.xyz'],
// ['wss://tracker.webtorrent.io'],
// ['wss://tracker.fastcast.nz'],
['wss://video.blender.org:443/tracker/socket'],
['wss://tube.privacytools.io:443/tracker/socket'],
['wss://tracker.sloppyta.co:443/announce'],
['wss://tracker.lab.vvc.niif.hu:443/announce'],
['wss://tracker.files.fm:7073/announce'],
['wss://open.tube:443/tracker/socket'],
['wss://hub.bugout.link:443/announce'],
['wss://peertube.cpy.re:443/tracker/socket'],
['ws://tracker.sloppyta.co:80/announce'],
['ws://tracker.lab.vvc.niif.hu:80/announce'],
['ws://tracker.files.fm:7072/announce'],
['ws://tracker.btsync.cf:6969/announce'],
['ws://hub.bugout.link:80/announce']
],
['wss://tracker.openwebtorrent.com'],
['wss://tracker.btorrent.xyz'],
// ['wss://tracker.webtorrent.io'],
// ['wss://tracker.fastcast.nz'],
// ['wss://video.blender.org:443/tracker/socket'],
// ['wss://tube.privacytools.io:443/tracker/socket'],
['wss://tracker.sloppyta.co:443/announce'],
['wss://tracker.lab.vvc.niif.hu:443/announce'],
['wss://tracker.files.fm:7073/announce'],
['wss://open.tube:443/tracker/socket'],
['wss://hub.bugout.link:443/announce'],
// ['wss://peertube.cpy.re:443/tracker/socket'],
['ws://tracker.sloppyta.co:80/announce'],
['ws://tracker.lab.vvc.niif.hu:80/announce'],
['ws://tracker.files.fm:7072/announce'],
['ws://tracker.btsync.cf:6969/announce'],
['ws://hub.bugout.link:80/announce']
],
videoExtensions = [
'.avi', '.mp4', '.m4v', '.webm', '.mov', '.mkv', '.mpg', '.mpeg', '.ogv', '.webm', '.wmv', '.m2ts'
],
@ -54,7 +55,7 @@ let nowPlaying,
selectedTorrent
async function addTorrent(magnet) {
if (client.torrents.length >= maxTorrents) {
client.torrents[0].store.destroy()
client.torrents[0].store ? client.torrents[0].store.destroy() : ""
client.torrents[0].destroy()
}
halfmoon.hideModal("tsearch")
@ -143,6 +144,7 @@ function serveFile(file, req) {
}
// kind of a fetch event from service worker but for the main thread.
let lastport
navigator.serviceWorker.addEventListener('message', evt => {
const request = new Request(evt.data.url, {
headers: evt.data.headers,
@ -168,6 +170,10 @@ navigator.serviceWorker.addEventListener('message', evt => {
}
port.onmessage = pull
// hack: stop hiding the old stream somewhere in memory land
if (lastport) lastport.onmessage = null
lastport = port
})
function prettyBytes(num) {

View file

@ -27,7 +27,7 @@
e.preventDefault();
deferredPrompt = e;
});
document.querySelector(".btn").addEventListener('click', (e) => {
add.addEventListener('click', (e) => {
deferredPrompt.prompt();
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
@ -61,9 +61,12 @@
no buffering, no ads, no delays, everything done client-side for free.
</p>
<div class="mt-20">
<div class="btn btn-primary" role="button">
Add app
<div class="btn btn-primary" role="button" id="add">
Add App
</div>
<a class="btn" role="button" href="/app/">
Open In Browser
</a>
</div>
</div>
</div>