I’m trying to inspire my kid to play music instead of silly games. So I did a complete download of this page text and it works offline, but without sound. So I changed all NOTE3: 'http://..../piano/piano/NOTE3.mp3'
to NOTE3: 'piano/NOTE3.mp3'
.
document.addEventListener('DOMContentLoaded', () => {
sampler = new Tone.Sampler({
urls: {
A3: 'piano/A3.mp3',
B3: 'piano/B3.mp3',
C3: 'piano/C3.mp3',
D3: 'piano/D3.mp3',
E3: 'piano/E3.mp3',
F3: 'piano/F3.mp3',
G3: 'piano/G3.mp3',
},
release: 0.5,
baseUrl: '/samples/',
}).toDestination();
});
I also have these sounds of notes in mp3 files from the original page, also created folder samples and piano outside the sorce folder, inside, within and in every other combination with these samples inside outside in all combinations. Also tried all combinations with single ‘ and double ” around NOTE3, path NOTE3: ‘piano/NOTE3.mp3′ and baseUrl. Also tried ./samples, ../samples, /sample, all combinations, etc. Even thou I did copy mp3s all around the project inside, outside, in samples and in piano folders – all combinations as i said. But yet no sound … The piano works perfectly: buttons change colors when pressed, piano keys change to rainbow when slider checked, etc… Is there something inside JS, CSS files that redirects path to the original http:// ? And since I’d like it to work offline, yet it doesn’t play mp3 from local path, how can fix?
Thanks for Your’ help.
So I changed all NOTE3: 'http://..../piano/piano/NOTE3.mp3'
to NOTE3: 'piano/NOTE3.mp3'
.
document.addEventListener('DOMContentLoaded', () => {
sampler = new Tone.Sampler({
urls: {
A3: 'piano/A3.mp3',
B3: 'piano/B3.mp3',
C3: 'piano/C3.mp3',
D3: 'piano/D3.mp3',
E3: 'piano/E3.mp3',
F3: 'piano/F3.mp3',
G3: 'piano/G3.mp3',
},
release: 0.5,
baseUrl: '/samples/',
}).toDestination();
});
I also have these sounds of notes in mp3 files from the original page, also created folder samples and piano outside the sorce folder, inside, within and in every other combination with these samples inside outside in all combinations. Also tried all combinations with single ‘ and double ” around NOTE3, path NOTE3: ‘piano/NOTE3.mp3’ and baseUrl. Also tried ./samples, ../samples, /sample, all combinations, etc. Even thou I did copy mp3s all around the project inside, outside, in samples and in piano folders – all combinations as i said. But yet no sound …
user25366484 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.