playlist importando sample track
Deploy / Deploy (push) Successful in 1m58s Details

This commit is contained in:
JotaChina 2025-12-25 17:31:36 -03:00
parent a4b4157f7e
commit 7ec18a5f02
2 changed files with 10 additions and 8 deletions

View File

@ -122,8 +122,7 @@ export function initializeAudioState() {
}); });
} }
export async function loadAudioForClip(clip) { export async function loadAudioForClip(clip) {
// --- ADIÇÃO ---
// Se já temos um buffer (do bounce ou colagem), não faz fetch // Se já temos um buffer (do bounce ou colagem), não faz fetch
if (clip.buffer) { if (clip.buffer) {
// Garante que as durações estão corretas // Garante que as durações estão corretas
@ -132,8 +131,7 @@ export async function loadAudioForClip(clip) {
if (clip.durationInSeconds === 0) if (clip.durationInSeconds === 0)
clip.durationInSeconds = clip.buffer.duration; clip.durationInSeconds = clip.buffer.duration;
return clip; return clip;
} }
// --- FIM DA ADIÇÃO ---
if (!clip.sourcePath || clip.sourcePath.startsWith("blob:")) { if (!clip.sourcePath || clip.sourcePath.startsWith("blob:")) {
// Se não há caminho ou se é um blob, não há nada para buscar. // Se não há caminho ou se é um blob, não há nada para buscar.
@ -147,7 +145,9 @@ export async function loadAudioForClip(clip) {
} }
try { try {
const response = await fetch(clip.sourcePath); const safeUrl = encodeURI(url).replace(/#/g, "%23");
const response = await fetch(safeUrl);
if (!response.ok) if (!response.ok)
throw new Error(`Falha ao buscar áudio: ${clip.sourcePath}`); throw new Error(`Falha ao buscar áudio: ${clip.sourcePath}`);
const arrayBuffer = await response.arrayBuffer(); const arrayBuffer = await response.arrayBuffer();
@ -155,7 +155,7 @@ export async function loadAudioForClip(clip) {
clip.buffer = audioBuffer; clip.buffer = audioBuffer;
// --- CORREÇÃO: Salva a duração original --- // --- Salva a duração original ---
if (clip.durationInSeconds === 0) { if (clip.durationInSeconds === 0) {
clip.durationInSeconds = audioBuffer.duration; clip.durationInSeconds = audioBuffer.duration;
} }

View File

@ -27,7 +27,8 @@ function buildSamplePathMap(tree, currentPath) {
for (const key in tree) { for (const key in tree) {
if (key === "_isFile") continue; if (key === "_isFile") continue;
const node = tree[key]; const node = tree[key];
const newPath = `${currentPath}/${key}`; const encodedKey = encodeURIComponent(key);
const newPath = `${currentPath}/${encodedKey}`;
if (node._isFile) { if (node._isFile) {
samplePathMap[key] = newPath; samplePathMap[key] = newPath;
} else { } else {
@ -72,7 +73,8 @@ function renderFileTree(tree, parentElement, currentPath) {
const node = tree[key]; const node = tree[key];
const li = document.createElement("li"); const li = document.createElement("li");
const newPath = `${currentPath}/${key}`; const encodedKey = encodeURIComponent(key);
const newPath = `${currentPath}/${encodedKey}`;
if (node._isFile) { if (node._isFile) {
// --- LÓGICA PARA ARQUIVOS --- // --- LÓGICA PARA ARQUIVOS ---