Audio added to firmware, Website File handling
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
CheckCircleIcon,
|
||||
WarningIcon,
|
||||
WarningCircleIcon,
|
||||
CloudArrowDownIcon,
|
||||
} from "phosphor-svelte";
|
||||
import {
|
||||
isTransferingRemote,
|
||||
@@ -28,7 +29,7 @@
|
||||
import { tagEditorState } from "../lib/store";
|
||||
import { tooltip } from "../lib/actions/tooltip";
|
||||
import { deleteRemoteFile } from "../lib/transport";
|
||||
import { deleteLocalFile, playLocalFile } from "../lib/db";
|
||||
import { deleteLocalFile, playLocalFile, downloadLocalFile } from "../lib/db";
|
||||
import { refreshRemote, refreshLocal } from "../lib/sync";
|
||||
import { addToast } from "../lib/toast";
|
||||
|
||||
@@ -265,6 +266,16 @@
|
||||
<button class="menu-btn danger" title="Löschen" on:click|stopPropagation={handleDeleteClick}>
|
||||
<TrashIcon class="list-menu-icon" />
|
||||
</button>
|
||||
<button
|
||||
class="menu-btn"
|
||||
title="Abspielen"
|
||||
on:click|stopPropagation={() => {
|
||||
downloadLocalFile(file.name);
|
||||
menuOpen = false;
|
||||
}}
|
||||
>
|
||||
<CloudArrowDownIcon class="list-menu-icon" />
|
||||
</button>
|
||||
<button
|
||||
class="menu-btn"
|
||||
title="Abspielen"
|
||||
|
||||
@@ -130,4 +130,18 @@ export async function playLocalFile(name: string): Promise<void> {
|
||||
};
|
||||
|
||||
source.start();
|
||||
}
|
||||
|
||||
export async function downloadLocalFile(name: string): Promise<void> {
|
||||
const fileEntry = await getLocalFile(name);
|
||||
if (!fileEntry) throw new Error('Datei nicht gefunden');
|
||||
|
||||
const url = URL.createObjectURL(fileEntry.blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = name + ".buzz";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
Reference in New Issue
Block a user