show viewer when loaded

This commit is contained in:
wryk 2020-01-18 05:05:37 +01:00
parent 829225ab22
commit 1c25d10d5d
1 changed files with 8 additions and 3 deletions

View File

@ -1,9 +1,13 @@
<div> <div>
<div class="embed-container" class:hidden={!duration}> <div class="embed-container" class:hidden={!loaded}>
<div bind:this={element}></div> <div bind:this={element}></div>
<div class="embed-overlay" on:click={() => $paused = !$paused}></div> <div class="embed-overlay" on:click={() => $paused = !$paused}></div>
</div> </div>
{#if !loaded}
LOADING TRACK
{/if}
{#if duration} {#if duration}
{currentTimeText} {currentTimeText}
<input <input
@ -15,8 +19,6 @@
on:mousedown={() => { if (player && !$paused) player.pause() }} on:mousedown={() => { if (player && !$paused) player.pause() }}
on:mouseup={() => { if (player && !$paused) player.play() }}> on:mouseup={() => { if (player && !$paused) player.play() }}>
{durationText} {durationText}
{:else}
LOADING TRACK
{/if} {/if}
</div> </div>
@ -32,6 +34,7 @@
let currentTime = null let currentTime = null
let duration = null let duration = null
let loaded = false
let currentTimeText = null let currentTimeText = null
let durationText = null let durationText = null
@ -57,6 +60,7 @@
duration = null duration = null
currentTime = null currentTime = null
$loading = true $loading = true
loaded = false
player.off('playing', updateViewerDurationCallback) player.off('playing', updateViewerDurationCallback)
player.load($current.data.id, !$paused) player.load($current.data.id, !$paused)
@ -97,6 +101,7 @@
updatePlayerVolume($volume) updatePlayerVolume($volume)
player.on('unstarted', () => { player.on('unstarted', () => {
loaded = true
player.once('playing', updateViewerDurationCallback) player.once('playing', updateViewerDurationCallback)
}) })