Skip to content

Json Transform #520

Answered by chrisn
cubancodepath asked this question in Q&A
Discussion options

You must be logged in to vote

You can use the waveformData option to pass the data in, after fetching and transforming it:

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
});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cubancodepath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants