forked from Mastodon/mastoradio-la-radio-di-mastodon
format viewer times
This commit is contained in:
parent
56fd65b775
commit
bc16948f16
|
@ -1,13 +1,13 @@
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div class:hidden={!duration}>
|
||||||
<div bind:this={element}></div>
|
<div bind:this={element}></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if duration}
|
{#if duration}
|
||||||
{Math.round(currentTime)} / {Math.round(duration)}
|
{currentTimeText}
|
||||||
<input type="range" min="0" max={duration} value={currentTime} disabled>
|
<input type="range" min="0" max={duration} value={currentTime} disabled>
|
||||||
|
{durationText}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
import YoutubePlayer from 'yt-player'
|
import YoutubePlayer from 'yt-player'
|
||||||
import { entry, paused, muted, volume } from '/store.js'
|
import { entry, paused, muted, volume } from '/store.js'
|
||||||
|
import { secondsToElapsedTime } from '/util.js'
|
||||||
|
|
||||||
let element
|
let element
|
||||||
let player
|
let player
|
||||||
|
@ -22,6 +23,12 @@
|
||||||
let currentTime = null
|
let currentTime = null
|
||||||
let duration = null
|
let duration = null
|
||||||
|
|
||||||
|
let currentTimeText = null
|
||||||
|
let durationText = null
|
||||||
|
|
||||||
|
$: currentTimeText = currentTime !== null ? secondsToElapsedTime(currentTime) : null
|
||||||
|
$: durationText = duration !== null ? secondsToElapsedTime(duration) : null
|
||||||
|
|
||||||
$: updateEntry($entry)
|
$: updateEntry($entry)
|
||||||
$: updatePaused($paused)
|
$: updatePaused($paused)
|
||||||
$: updateMuted($muted)
|
$: updateMuted($muted)
|
||||||
|
@ -111,5 +118,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
14
src/util.js
14
src/util.js
|
@ -4,6 +4,20 @@ import { execPipe, asyncFilter, asyncMap } from 'iter-tools'
|
||||||
const millisecond = 1
|
const millisecond = 1
|
||||||
const second = 1000 * millisecond
|
const second = 1000 * millisecond
|
||||||
const minute = 60 * second
|
const minute = 60 * second
|
||||||
|
const hour = 60 * minute
|
||||||
|
|
||||||
|
export const secondsToElapsedTime = (seconds) => {
|
||||||
|
const parts = [
|
||||||
|
Math.floor(seconds / 3600),
|
||||||
|
Math.floor(seconds / 60) % 60,
|
||||||
|
Math.floor(seconds) % 60
|
||||||
|
]
|
||||||
|
|
||||||
|
return parts
|
||||||
|
.filter((value, index) => value > 0 || index > 0)
|
||||||
|
.map(value => value < 10 ? '0' + value : value)
|
||||||
|
.join(':')
|
||||||
|
}
|
||||||
|
|
||||||
export async function* mkStatusesIterator(initialLink) {
|
export async function* mkStatusesIterator(initialLink) {
|
||||||
let buffer = []
|
let buffer = []
|
||||||
|
|
Loading…
Reference in New Issue