peaks.js icon indicating copy to clipboard operation
peaks.js copied to clipboard

RangeError: options.width should be a strictly positive integer value. [0]

Open yanbeixiang opened this issue 7 years ago • 7 comments

I throw the following exception when I use it. Do you know what the reason is?

image

yanbeixiang avatar Jul 09 '18 06:07 yanbeixiang

This happens because the width of the container element for the overview waveform view is zero.

Take a look here and here. Are you passing your own template?

chrisn avatar Jul 09 '18 13:07 chrisn

@chrisn thanks.

still have a question

image

yanbeixiang avatar Jul 16 '18 07:07 yanbeixiang

This happens because the width of the container element for the overview waveform view is zero.

Take a look here and here. Are you passing your own template?

I get the same error, and the waveform container definitely has width (set to 100%). When I use the document inspector the canvas element clearly has space.

zachsa avatar Oct 18 '18 15:10 zachsa

Hi @zachsa, I'd like to track down what's causing this. Are there any more details, or maybe a minimal example you can share?

chrisn avatar Oct 18 '18 16:10 chrisn

Hi @zachsa, I'd like to track down what's causing this. Are there any more details, or maybe a minimal example you can share?

Hi @chrisn. I'm using it in a react component like this:

class PeaksJs extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      myAudioContext: new window.AudioContext(),
      peaks: null
    }
  }

  componentDidMount() {
    this.state.peaks = Peaks.init({
      container: document.querySelector('#peaks-js-container'),
      mediaElement: document.querySelector('audio'),
      audioContext: this.state.myAudioContext,
      logger: console.error.bind(console),
      height: 125,
      ...
    })
  }

  render() {
    return <div style={{width: '100%'}}>
            <Cell size={12}>
              <Card>
                <div id="peaks-js-container">
                  <audio controls id="audio">
                    <source src="/141.mp3" />
                    This browser does not support audio. Please use a recent version of Chrome
                  </audio>
                </div>
              </Card>            
            </Cell>
        </div>
  }
}

The Grid/Cells come from a 'react-md' - this is a component library: https://react-md.mlaursen.com/getting-started/prerequisites. I think that the grid is achieved via flex-box.

Hope this is helpful - let me know if you would like more information.

zachsa avatar Oct 19 '18 11:10 zachsa

I get the same error

peaks.min.js:1 Uncaught RangeError: options.width should be a strictly positive integer value. [0]
    at module.exports.resample (peaks.min.js:1)
    at Peaks.<anonymous> (peaks.min.js:1)
    at Peaks.EventEmitter.emit (peaks.min.js:1)
    at peaks.min.js:1

I'm running a HTML audio tag, and using range query when scrubbing, but the problem comes out at load time, so before any scrubbing.

loretoparisi avatar May 13 '19 14:05 loretoparisi

hey guys,

Is that possible that this error is related to the data input? I create a 'peaks.json' via audiowaveform with a 61Mo mp3 file, it's ok. But with a 64Mo mp3 file or higher, I got the same error.

slowpiou avatar May 25 '19 12:05 slowpiou