mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-20 10:52:09 +00:00
feat: playnext playlast
This commit is contained in:
parent
87517a473f
commit
ae7744e966
5 changed files with 57 additions and 18 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Miru",
|
||||
"version": "0.1.1",
|
||||
"version": "0.2.0",
|
||||
"author": "ThaUnknown_",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@
|
|||
let gallery = writable(null)
|
||||
setContext('gallery', gallery)
|
||||
|
||||
let rss = writable({})
|
||||
setContext('rss', rss)
|
||||
</script>
|
||||
|
||||
<ViewAnime />
|
||||
|
|
|
|||
|
|
@ -3,8 +3,16 @@
|
|||
import { updateMedia } from './pages/Player.svelte'
|
||||
import { set } from './pages/Settings.svelte'
|
||||
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
const rss = writable({})
|
||||
|
||||
const settings = set
|
||||
|
||||
export function playAnime(media, episode){
|
||||
rss.set({ media, episode })
|
||||
}
|
||||
|
||||
export function getRSSContent(url) {
|
||||
return fetch(url)
|
||||
.then(res => {
|
||||
|
|
@ -36,12 +44,10 @@
|
|||
</script>
|
||||
|
||||
<script>
|
||||
import { getContext } from 'svelte'
|
||||
import { add } from '@/modules/torrent.js'
|
||||
import { episodeRx } from '@/modules/anime.js'
|
||||
|
||||
const media = getContext('rss')
|
||||
$: parseRss($media)
|
||||
$: parseRss($rss)
|
||||
|
||||
let table = null
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
<script>
|
||||
import { playAnime } from './RSSView.svelte'
|
||||
import { getContext } from 'svelte'
|
||||
import { countdown } from '@/modules/util.js'
|
||||
|
||||
let view = getContext('view')
|
||||
let rss = getContext('rss')
|
||||
function playAnime(episode = 1) {
|
||||
$rss = { media: $view, episode }
|
||||
$view = null
|
||||
}
|
||||
function close() {
|
||||
$view = null
|
||||
}
|
||||
|
|
@ -113,7 +109,10 @@
|
|||
<button
|
||||
class="btn btn-primary d-flex align-items-center font-weight-bold font-size-24 h-50 mb-5"
|
||||
type="button"
|
||||
on:click={() => playAnime($view.mediaListEntry?.progress + 1)}>
|
||||
on:click={() => {
|
||||
playAnime($view, $view.mediaListEntry?.progress + 1)
|
||||
close()
|
||||
}}>
|
||||
<span class="material-icons mr-10 font-size-24 w-30"> play_arrow </span>
|
||||
<span>{$view.mediaListEntry?.progress ? 'Continue' : 'Play'}</span>
|
||||
</button>
|
||||
|
|
@ -147,7 +146,12 @@
|
|||
<tbody>
|
||||
{#each Array($view.nextAiringEpisode?.episode - 1 || $view.episodes) as _, i}
|
||||
{@const index = ($view.nextAiringEpisode?.episode - 1 || $view.episodes) - i - 1}
|
||||
<tr class="font-size-20 py-10 pointer" on:click={() => playAnime(index + 1)}>
|
||||
<tr
|
||||
class="font-size-20 py-10 pointer"
|
||||
on:click={() => {
|
||||
playAnime($view, index + 1)
|
||||
close()
|
||||
}}>
|
||||
<td class="w-full">Episode {index + 1}</td>
|
||||
<td class="material-icons text-right">play_arrow</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<script context="module">
|
||||
import { playAnime } from '../RSSView.svelte'
|
||||
export let media = null
|
||||
let fileMedia = null
|
||||
let hadImage = false
|
||||
|
|
@ -45,6 +46,7 @@
|
|||
const data = await resolveFileMedia({ fileName: current.name })
|
||||
if (image) data.episodeThumbnail = image
|
||||
updateMedia(data)
|
||||
checkAvail(current)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -173,11 +175,31 @@
|
|||
current = file
|
||||
video?.load()
|
||||
paused = false
|
||||
checkAvail(current)
|
||||
})
|
||||
}
|
||||
}
|
||||
$: initSubs(current, video)
|
||||
|
||||
let hasNext = false
|
||||
let hasLast = false
|
||||
function checkAvail(current) {
|
||||
if ((media?.nextAiringEpisode?.episode - 1 || media?.episodes) > fileMedia?.episodeNumber) {
|
||||
hasNext = true
|
||||
} else if (videos.indexOf(current) !== videos.length - 1) {
|
||||
hasNext = true
|
||||
} else {
|
||||
hasNext = false
|
||||
}
|
||||
if (media && fileMedia?.episodeNumber > 1) {
|
||||
hasLast = true
|
||||
} else if (videos.indexOf(current) > 0) {
|
||||
hasLast = true
|
||||
} else {
|
||||
hasLast = false
|
||||
}
|
||||
}
|
||||
|
||||
function initSubs(current, video) {
|
||||
if (current && video) {
|
||||
if (subs) subs.destroy()
|
||||
|
|
@ -221,11 +243,20 @@
|
|||
muted = !muted
|
||||
}
|
||||
function playNext() {
|
||||
handleCurrent(videos[(videos.indexOf(current) + 1) % videos.length])
|
||||
const index = videos.indexOf(current)
|
||||
if (index + 2 < videos.length) {
|
||||
handleCurrent(videos[(index + 1) % videos.length])
|
||||
} else if (media?.nextAiringEpisode?.episode - 1 || media?.episodes > fileMedia?.episodeNumber) {
|
||||
playAnime(media, fileMedia?.episodeNumber + 1)
|
||||
}
|
||||
}
|
||||
function playLast() {
|
||||
const index = videos.indexOf(current)
|
||||
handleCurrent(videos[index === 0 ? videos.length - 1 : index - 1])
|
||||
if (index > 1) {
|
||||
handleCurrent(videos[index - 1])
|
||||
} else if (media && fileMedia?.episodeNumber > 1) {
|
||||
playAnime(media, fileMedia?.episodeNumber - 1)
|
||||
}
|
||||
}
|
||||
function toggleFullscreen() {
|
||||
document.fullscreenElement ? document.exitFullscreen() : container.requestFullscreen()
|
||||
|
|
@ -720,20 +751,20 @@
|
|||
<div class="position-absolute w-full h-full" on:dblclick={toggleFullscreen}>
|
||||
<div class="play-overlay w-full h-full" on:click={playPause} />
|
||||
</div>
|
||||
{#if videos?.length > 1}
|
||||
{#if hasLast}
|
||||
<span class="material-icons ctrl" data-name="playLast" on:click={playLast}> skip_previous </span>
|
||||
{/if}
|
||||
<span class="material-icons ctrl" data-name="rewind" on:click={rewind}> fast_rewind </span>
|
||||
<span class="material-icons ctrl" data-name="playPause" on:click={playPause}> {ended ? 'replay' : paused ? 'play_arrow' : 'pause'} </span>
|
||||
<span class="material-icons ctrl" data-name="forward" on:click={forward}> fast_forward </span>
|
||||
{#if videos?.length > 1}
|
||||
{#if hasNext}
|
||||
<span class="material-icons ctrl" data-name="playNext" on:click={playNext}> skip_next </span>
|
||||
{/if}
|
||||
<div data-name="bufferingDisplay" class="position-absolute" />
|
||||
</div>
|
||||
<div class="bottom d-flex z-40">
|
||||
<span class="material-icons ctrl" title="Play/Pause [Space]" data-name="playPause" on:click={playPause}> {ended ? 'replay' : paused ? 'play_arrow' : 'pause'} </span>
|
||||
{#if videos?.length > 1}
|
||||
{#if hasNext}
|
||||
<span class="material-icons ctrl" title="Next [N]" data-name="playNext" on:click={playNext}> skip_next </span>
|
||||
{/if}
|
||||
<div class="d-flex w-auto volume">
|
||||
|
|
|
|||
Loading…
Reference in a new issue