From c2d36d790c79877c54c02daa1105bde1807248ec Mon Sep 17 00:00:00 2001 From: infojunkie Date: Wed, 9 Oct 2024 23:00:03 -0700 Subject: [PATCH] Fix demo for custom MIDI+timemap --- demo/demo.mjs | 12 ++++++++---- demo/index.html | 2 -- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/demo/demo.mjs b/demo/demo.mjs index 66c6641..976da3c 100644 --- a/demo/demo.mjs +++ b/demo/demo.mjs @@ -89,7 +89,6 @@ async function createPlayer() { 'vrv': true, 'mma': async () => MusicXMLPlayer.fetish(window.location.href + 'mma/', { method: 'HEAD' }), 'midi': '.mid', - 'timemap': '.timemap.json', 'mscore': '.mscore.json', })) { const input = document.getElementById(`converter-${k}`); @@ -188,9 +187,14 @@ async function createConverter(converter, sheet, groove) { const base = sheet.startsWith('http') || sheet.startsWith('data/') ? sheet : `data/${sheet}`; switch (converter) { case 'midi': - return new MusicXMLPlayer.FetchConverter(base.replace(/\.musicxml$|\.mxl$/, '.mid')); - case 'timemap': - return new MusicXMLPlayer.FetchConverter(base.replace(/\.musicxml$|\.mxl$/, '.mid'), base.replace(/\.musicxml$|\.mxl$/, '.timemap.json')); + try { + const timemap = base.replace(/\.musicxml$|\.mxl$/, '.timemap.json'); + await MusicXMLPlayer.fetish(timemap, { method: 'HEAD' }); + return new MusicXMLPlayer.FetchConverter(base.replace(/\.musicxml$|\.mxl$/, '.mid'), timemap); + } + catch { + return new MusicXMLPlayer.FetchConverter(base.replace(/\.musicxml$|\.mxl$/, '.mid')); + } case 'vrv': return new MusicXMLPlayer.VerovioConverter(); case 'mma': diff --git a/demo/index.html b/demo/index.html index 7df5333..f2b9385 100644 --- a/demo/index.html +++ b/demo/index.html @@ -103,8 +103,6 @@

MusicXML Player Demo

Converter - -