Skip to content

Commit

Permalink
Display file select button if torrent isn't loading
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-asriyan committed Apr 17, 2024
1 parent 1f29c0b commit cdf170c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 0 additions & 4 deletions src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ html {
background-color: #000;
}

.block {
display: block;
}

.tile {
border: 1px solid rgb(255 255 255 / .1);
background-color: #1c1c1c;
Expand Down
5 changes: 4 additions & 1 deletion src/components/video-player/player-magnet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import Loader from '../loader.svelte';
import { getStreamUrl } from '../../stores/web-torrent';
import VideoPlayerNative from './video-player-native.svelte';
import VideoSelectorBtn from '../video-selector-btn.svelte';
export let link: Link;
export let currentTime: number;
Expand All @@ -22,8 +23,10 @@
<Loader />
{#await sleep(10000)}
{:then}
<div class="uk-margin-top">
<div class="uk-margin-top uk-text-center">
{ $_('player.isHostActive') }
<br class="uk-margin"/>
<VideoSelectorBtn forceLocal={true} />
</div>
{/await}
{:then streamUrl}
Expand Down
12 changes: 6 additions & 6 deletions src/components/video-selector-btn.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
import { sendFile } from '../stores/web-torrent';
import normalizeLink, { SourceType } from '../normalize-link';
export let url: string;
export let url: string = '';
export let forceLocal: boolean = false;
let input: HTMLInputElement;
let sharingPending = false;
const loadSource = async function (file: any): Promise<void> {
if (navigator.serviceWorker && confirm($_('selectVideo.file.streamingConfirmation'))) {
if (!forceLocal && navigator.serviceWorker && confirm($_('selectVideo.file.streamingConfirmation'))) {
sharingPending = true;
try {
url = await sendFile(file);
Expand All @@ -30,13 +30,13 @@
</script>

<input bind:this={input} type="file" on:change={e => loadSource(e.target.files[0])}/>
<button disabled={sharingPending} on:click={() => input.click()} class="uk-button uk-button-default block">
<button disabled={sharingPending} on:click={() => input.click()} class="uk-button uk-button-default">
{#if sharingPending}
{ $_('selectVideo.file.streamingPending') }
{:else if normalizeLink(url)?.type === SourceType.magnet}
{ $_('selectVideo.file.selectAnotherStream') }
{:else if $blobUrl}
{ $_('selectVideo.file.selectAnother') }
{:else if normalizeLink(url)?.type === SourceType.magnet}
{ $_('selectVideo.file.selectAnotherStream') }
{:else}
{ $_('selectVideo.file.select') }
{/if}
Expand Down

0 comments on commit cdf170c

Please sign in to comment.