mirror of
https://github.com/NoCrypt/migu.git
synced 2026-04-20 08:02:12 +00:00
fix: autoplay indications
This commit is contained in:
parent
4658473546
commit
5f022b3209
2 changed files with 10 additions and 67 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Miru",
|
||||
"version": "3.1.12",
|
||||
"version": "3.1.13",
|
||||
"author": "ThaUnknown_ <ThaUnknown@users.noreply.github.com>",
|
||||
"description": "Stream anime torrents, real-time with no waiting for downloads.",
|
||||
"main": "src/index.js",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
import { set } from '../Settings.svelte'
|
||||
import { playAnime } from '../RSSView.svelte'
|
||||
import { client } from '@/modules/torrent.js'
|
||||
import { onMount, createEventDispatcher } from 'svelte'
|
||||
import { onMount, createEventDispatcher, tick } from 'svelte'
|
||||
import { alEntry } from '@/modules/anilist.js'
|
||||
// import Peer from '@/modules/Peer.js'
|
||||
import Subtitles from '@/modules/subtitles.js'
|
||||
|
|
@ -76,56 +76,6 @@
|
|||
})
|
||||
}
|
||||
}
|
||||
function getFPS () {
|
||||
video.fps = new Promise(resolve => {
|
||||
let lastmeta = null
|
||||
let count = 0
|
||||
|
||||
function handleFrames (now, metadata) {
|
||||
if (count) {
|
||||
// resolve on 2nd frame, 1st frame might be a cut-off
|
||||
if (lastmeta) {
|
||||
const msbf = (metadata.mediaTime - lastmeta.mediaTime) / (metadata.presentedFrames - lastmeta.presentedFrames)
|
||||
const rawFPS = (1 / msbf).toFixed(3)
|
||||
// this is accurate for mp4, mkv is a few ms off
|
||||
if (current.name.endsWith('.mkv')) {
|
||||
if (rawFPS < 25 && rawFPS > 22) {
|
||||
resolve(23.976)
|
||||
} else if (rawFPS < 31 && rawFPS > 28) {
|
||||
resolve(29.97)
|
||||
} else if (rawFPS < 62 && rawFPS > 58) {
|
||||
resolve(59.94)
|
||||
} else {
|
||||
resolve(rawFPS) // smth went VERY wrong
|
||||
}
|
||||
} else {
|
||||
resolve(rawFPS)
|
||||
}
|
||||
} else {
|
||||
lastmeta = metadata
|
||||
video.requestVideoFrameCallback(handleFrames)
|
||||
}
|
||||
} else {
|
||||
count++
|
||||
video.requestVideoFrameCallback(handleFrames)
|
||||
}
|
||||
}
|
||||
video.requestVideoFrameCallback(handleFrames)
|
||||
playFrame()
|
||||
})
|
||||
}
|
||||
|
||||
// plays one frame
|
||||
function playFrame () {
|
||||
let wasPaused = false
|
||||
video.requestVideoFrameCallback(() => {
|
||||
if (wasPaused) paused = true
|
||||
})
|
||||
if (paused) {
|
||||
wasPaused = true
|
||||
paused = false
|
||||
}
|
||||
}
|
||||
|
||||
// if ('PresentationRequest' in window) {
|
||||
// const handleAvailability = aval => {
|
||||
|
|
@ -160,9 +110,9 @@
|
|||
}
|
||||
} else {
|
||||
src = ''
|
||||
video?.load()
|
||||
currentTime = 0
|
||||
targetTime = 0
|
||||
tick().then(() => video?.play())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,8 +132,9 @@
|
|||
initSubs()
|
||||
src = file.url
|
||||
client.send('current', file)
|
||||
video?.load()
|
||||
clearCanvas()
|
||||
await tick()
|
||||
video?.play()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -244,7 +195,11 @@
|
|||
}
|
||||
|
||||
function autoPlay () {
|
||||
if (!miniplayer) video.play()
|
||||
if (!miniplayer) {
|
||||
video.play()
|
||||
} else {
|
||||
video.pause()
|
||||
}
|
||||
}
|
||||
function playPause () {
|
||||
paused = !paused
|
||||
|
|
@ -413,16 +368,6 @@
|
|||
fn: () => seek(-90),
|
||||
id: '-90'
|
||||
},
|
||||
Comma: {
|
||||
fn: async () => seek(-1 / (await video.fps) || 0),
|
||||
id: 'fast_rewind',
|
||||
type: 'icon'
|
||||
},
|
||||
Period: {
|
||||
fn: async () => seek(1 / (await video.fps) || 0),
|
||||
id: 'fast_forward',
|
||||
type: 'icon'
|
||||
},
|
||||
KeyI: {
|
||||
fn: () => toggleStats(),
|
||||
id: 'list',
|
||||
|
|
@ -894,7 +839,6 @@
|
|||
crossorigin='anonymous'
|
||||
class='position-absolute h-full w-full'
|
||||
style={`margin-top: ${menubarOffset}px`}
|
||||
autoplay
|
||||
preload='auto'
|
||||
{src}
|
||||
bind:videoHeight
|
||||
|
|
@ -919,7 +863,6 @@
|
|||
on:playing={hideBuffering}
|
||||
on:loadedmetadata={hideBuffering}
|
||||
on:ended={tryPlayNext}
|
||||
on:loadedmetadata={getFPS}
|
||||
on:loadedmetadata={initThumbnails}
|
||||
on:loadedmetadata={autoPlay}
|
||||
on:loadedmetadata={checkAudio}
|
||||
|
|
|
|||
Loading…
Reference in a new issue