Json Transform #520
Answered
by
chrisn
cubancodepath
asked this question in
Q&A
Json Transform
#520
-
There is a way to pass the peaks data from a json got from the server but firts this json need to be parse as it is comming wiht this type WaveData {
time: number,
value: number,
} where value is the peak value to create the array of number needed for peaks.js |
Beta Was this translation helpful? Give feedback.
Answered by
chrisn
Jan 11, 2024
Replies: 1 comment
-
You can use the function transform(waveform) {
// Transform your data to the format Peaks.js needs here
return data;
}
const response = await fetch(waveformUrl);
const waveform = await response.json();
const options = {
zoomview: { container: ... },
overview: { container: ... },
mediaElement: document.getElementById('audio'),
waveformData: {
json: transform(waveform)
},
// Other options as needed
};
Peaks.init(options, (err, peaks) => {
// etc
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
cubancodepath
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the
waveformData
option to pass the data in, after fetching and transforming it: