An error occurred in the renderTracks(vite-vue3) #1567
-
I use the alphaTabSamplesWeb/vite-vue3 sample and try to render another track.But an error occurred in the renderTracks Method。 Uncaught DOMException: Failed to execute 'postMessage' on 'Worker': [object Array] could not be cloned. <script setup lang="ts">
import {ref, onMounted, onUnmounted,toRaw } from 'vue';
import { AlphaTabApi, Settings } from '@coderline/alphatab'
const element = ref();
const api = ref<AlphaTabApi|null>(null)
const tracks = ref();
onMounted(()=>{
api.value = new AlphaTabApi(element.value, {
core: {
file: 'https://www.alphatab.net/files/canon.gp',
fontDirectory: '/font/'
},
player: {
enablePlayer: true,
enableCursor: true,
enableUserInteraction: true,
soundFont: '/soundfont/sonivox.sf2'
}
} as Settings);
// fill track list when the score is loaded
api.value?.scoreLoaded.on((score) => {
// generate a track item for all tracks of the score
tracks.value = score.tracks;
});
})
onUnmounted(()=>{
api.value?.destroy();
api.value = null;
})
function playPause() {
api.value?.playPause();
}
function changeTrack(track:any) {
api.value?.renderTracks([toRaw(track)]);
}
</script>
<template>
<div>
Hello AlphaTab!
<button @click="playPause()">Play/Pause</button>
<template v-for="track in tracks">
<button @click="changeTrack(track)">{{ track.name }}</button>
</template>
<div ref="element"></div>
</div>
</template> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Seems something special to Vue, similar to this problem: https://stackoverflow.com/questions/77319774/vue-3-here-maps-failed-to-execute-postmessage-on-worker-object-array-co It seems the alphaTab API object is also a proxy. can you try getting the real object with something like |
Beta Was this translation helpful? Give feedback.
Seems something special to Vue, similar to this problem: https://stackoverflow.com/questions/77319774/vue-3-here-maps-failed-to-execute-postmessage-on-worker-object-array-co
It seems the alphaTab API object is also a proxy. can you try getting the real object with something like
toRaw(api.value)
to interact with the real alphaTab object?