fix audio playing

This commit is contained in:
geoffrey45
2021-12-19 14:40:27 +03:00
parent 643aab1ad9
commit 847dabb9a4
3 changed files with 10 additions and 7 deletions
+3 -3
View File
@@ -7,12 +7,12 @@ const getData = async (path, last_id) => {
const songs = ref(null);
const folders = ref(null);
path = encodeURIComponent(path.replaceAll("/", "|"));
const encoded_path = encodeURIComponent(path.replaceAll("/", "|"));
if (last_id) {
url = `${folders_uri}/f/${path}::${last_id}`;
url = `${folders_uri}/f/${encoded_path}::${last_id}`;
} else {
url = url = `${folders_uri}/f/${path}`;
url = url = `${folders_uri}/f/${encoded_path}`;
}
const res = await fetch(url);
+7 -2
View File
@@ -1,6 +1,11 @@
const playAudio = (path) => {
const audio = new Audio("http://127.0.0.1:8901" + path);
import { ref } from "@vue/reactivity";
const audio = ref(new Audio()).value;
const playAudio = (path) => {
const full_path = "http://127.0.0.1:8901/" + encodeURIComponent(path);
audio.src = full_path;
audio.addEventListener("canplaythrough", () => {
audio.play();
});