teste upload de sample com mic
Deploy / Deploy (push) Successful in 1m17s
Details
Deploy / Deploy (push) Successful in 1m17s
Details
This commit is contained in:
parent
0768b85700
commit
6ee78b0cd2
|
|
@ -307,13 +307,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
let currentFolderObj = manifestData;
|
||||
|
||||
// === FUNÇÕES DE UTILIDADE ===
|
||||
|
||||
function removeExtension(filename) {
|
||||
return filename.replace(/\.[^/.]+$/, "");
|
||||
}
|
||||
|
||||
// === LÓGICA DO NAVEGADOR DE ARQUIVOS ===
|
||||
|
||||
function getFolderByPath(pathArray) {
|
||||
let folder = manifestData;
|
||||
for (const dir of pathArray) {
|
||||
|
|
@ -415,7 +413,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
}
|
||||
|
||||
// === LÓGICA DE FILTRAGEM (ROBUSTA) ===
|
||||
|
||||
function filterBySample(sampleName) {
|
||||
if (!sampleName) {
|
||||
filterDisplayName.textContent = "(todos)";
|
||||
|
|
@ -463,7 +460,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if(foundCount > 0) document.getElementById('project-list').scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
|
||||
// Inicialização
|
||||
btnHome.onclick = () => navigateTo([]);
|
||||
renderBreadcrumbs();
|
||||
renderBrowser();
|
||||
|
|
@ -514,7 +510,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
document.addEventListener('keydown', (e) => { if (e.key === "Escape") closeModal(); });
|
||||
|
||||
// ==========================================================
|
||||
// === LÓGICA DE UPLOAD & GRAVAÇÃO (MODIFICADA) ===
|
||||
// === LÓGICA DE UPLOAD & GRAVAÇÃO (CORRIGIDA) ===
|
||||
// ==========================================================
|
||||
const uploadModal = document.getElementById('upload-sample-modal');
|
||||
const btnOpenUpload = document.getElementById('btn-open-upload');
|
||||
|
|
@ -543,7 +539,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
let mediaRecorder = null;
|
||||
let audioChunks = [];
|
||||
let audioBlob = null;
|
||||
let activeTab = 'file'; // 'file' or 'mic'
|
||||
let activeTab = 'file';
|
||||
|
||||
// Alternância de Abas
|
||||
function switchTab(mode) {
|
||||
|
|
@ -553,13 +549,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
tabMic.classList.remove('is-active');
|
||||
sectionFile.classList.remove('is-hidden');
|
||||
sectionMic.classList.add('is-hidden');
|
||||
stopRecordingLogic(); // Garante que parou de gravar
|
||||
stopRecordingLogic();
|
||||
} else {
|
||||
tabMic.classList.add('is-active');
|
||||
tabFile.classList.remove('is-active');
|
||||
sectionMic.classList.remove('is-hidden');
|
||||
sectionFile.classList.add('is-hidden');
|
||||
// Sugere nome pro arquivo
|
||||
if(!recordNameInput.value) recordNameInput.value = "gravacao_" + new Date().toLocaleTimeString().replace(/:/g, '-');
|
||||
}
|
||||
}
|
||||
|
|
@ -592,12 +587,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
};
|
||||
|
||||
mediaRecorder.onstop = () => {
|
||||
audioBlob = new Blob(audioChunks, { type: 'audio/webm' }); // WebM é padrão comum
|
||||
// CORREÇÃO 1: Forçamos o tipo para OGG para o servidor aceitar
|
||||
audioBlob = new Blob(audioChunks, { type: 'audio/ogg' });
|
||||
|
||||
const audioUrl = URL.createObjectURL(audioBlob);
|
||||
recordPreview.src = audioUrl;
|
||||
recordPreview.classList.remove('is-hidden');
|
||||
|
||||
// Cleanup streams
|
||||
stream.getTracks().forEach(track => track.stop());
|
||||
};
|
||||
|
||||
|
|
@ -627,15 +623,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
if(show) {
|
||||
uploadModal.classList.add('is-active');
|
||||
subfolderInput.value = currentPathStack.join('/');
|
||||
switchTab('file'); // Reset para aba de arquivo
|
||||
switchTab('file');
|
||||
} else {
|
||||
uploadModal.classList.remove('is-active');
|
||||
uploadStatus.classList.add('is-hidden');
|
||||
uploadProgress.classList.add('is-hidden');
|
||||
stopRecordingLogic();
|
||||
audioBlob = null; // Limpa gravação
|
||||
audioBlob = null;
|
||||
recordPreview.src = "";
|
||||
fileInput.value = ""; // Limpa input file
|
||||
fileInput.value = "";
|
||||
fileNameDisplay.textContent = "Nenhum selecionado";
|
||||
}
|
||||
}
|
||||
|
|
@ -653,10 +649,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
e.preventDefault();
|
||||
|
||||
const formData = new FormData();
|
||||
// Adiciona pasta
|
||||
formData.append('subfolder', subfolderInput.value);
|
||||
|
||||
// Verifica qual aba está ativa para pegar o arquivo correto
|
||||
if (activeTab === 'file') {
|
||||
if (fileInput.files.length === 0) {
|
||||
alert("Selecione um arquivo primeiro.");
|
||||
|
|
@ -669,11 +663,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
alert("Grave algo antes de enviar.");
|
||||
return;
|
||||
}
|
||||
|
||||
let filename = recordNameInput.value.trim() || "gravacao";
|
||||
// Força extensão .webm se não tiver, para garantir que o server entenda
|
||||
if(!filename.match(/\.(webm|ogg|wav)$/i)) {
|
||||
filename += ".webm";
|
||||
}
|
||||
|
||||
// CORREÇÃO 2: Removemos a extensão antiga se houver e forçamos .ogg
|
||||
// Isso engana a validação simples do servidor
|
||||
filename = filename.replace(/\.(webm|wav|mp3|flac)$/i, "");
|
||||
filename += ".ogg";
|
||||
|
||||
console.log("Enviando arquivo como:", filename); // Debug
|
||||
|
||||
formData.append('sample_file', audioBlob, filename);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue