katspaugh / wavesurfer.js

Audio waveform player
https://wavesurfer.xyz
BSD 3-Clause "New" or "Revised" License
8.75k stars 1.62k forks source link

Stereo Mp3 files don't work on Safari 11 #1562

Closed websolab closed 5 years ago

websolab commented 5 years ago

Wavesurfer.js version(s):

wavesurfer.js 2.1.3 (2019-01-21)

Browser version(s):

Safari 11.1.2 (11605.3.8.1)

Code needed to reproduce the issue:

I took the code from the original site https://wavesurfer-js.org The fact is that the code is works with .wav files in all browsers. But .mp3 doesn't work in Safari. You can check everything here.

https://laravel57.websolab.com/

Thanks a lot for help!

websolab commented 5 years ago

I found that STEREO mp3 not working. But MONO is working. Is it possible to do something for stereo files in Safari?

thijstriemstra commented 5 years ago

See https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats#Browser_compatibility.

There's this though: https://github.com/katspaugh/wavesurfer.js/blob/master/src/webaudio.js#L405

Can you comment that out and see if that makes a difference?

ronhornbaker commented 5 years ago

See https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats#Browser_compatibility.

There's this though: https://github.com/katspaugh/wavesurfer.js/blob/master/src/webaudio.js#L405

Can you comment that out and see if that makes a difference?

I tried commenting out lines 412-415 (assuming that was the snippet to which you were referring), and it didn't help. In fact, Safari wouldn't load either a wav or mp3 at all.

I'm seeing this mp3 wave rendering bug with Safari on Mac and iOS, too: mp3 results in no waveform being generated, while wav of same content works fine. My only workaround is to use only WAV files, which is unfortunate due to their size. Not sure it has anything to do with stereo, but the mp3 file I'm currently testing is in stereo.

thijstriemstra commented 5 years ago

@ronhornbaker that code creates a single channel buffer, can you try and change it to 2 channels, e.g.

const newBuffer = this.createBuffer(2, 4096, this.sampleRate);

and adjust the buffer size if necessary.

websolab commented 5 years ago

The problem was in mp3 files. Something with render options. I tried different mp3 files downloaded from network and it's works now.