Wavesurfer.js: isReady() method

Created on 17 Mar 2019  Â·  15Comments  Â·  Source: katspaugh/wavesurfer.js

Hi,

the documented isReady() and getReady() methods don't seem to be working for me.

bug

Most helpful comment

I also vote for the first option. It's just a boolean property.

All 15 comments

getReady() does not exist, where is this documented?

isReady is defined as both a attribute and method, something that seems to be introduced in 2.0.5 by @Guisch (and approved by me :disappointed:), see #1338 and https://github.com/katspaugh/wavesurfer.js/blob/72bdf70a5b3d9f3ea5bb7cb5326f68ce469e2a6d/CHANGES.md#205-26022018

While testing wavesurfer.isReady returns true and wavesurfer.isReady() throws a TypeError because it's not defined (and overwritten by the isReady attribute).

When grepping through the code it looks like isReady is already used in numerous places (and using it as an attribute):

$ grep -Rn 'isReady' src/
src/wavesurfer.js:387:        this.isReady = false;
src/wavesurfer.js:946:     * @example const isReady = wavesurfer.isReady();
src/wavesurfer.js:949:    isReady() {
src/wavesurfer.js:950:        return this.isReady;
src/wavesurfer.js:1192:        this.isReady = true;
src/wavesurfer.js:1329:                this.isReady = true;
src/wavesurfer.js:1509:        this.isReady = false;
src/wavesurfer.js:1539:        this.isReady = false;
src/plugin/regions.js:658:        if (this.wavesurfer.isReady) {
src/plugin/timeline.js:189:        if (this.wavesurfer.isReady) {
src/plugin/minimap.js:177:        if (this.wavesurfer.isReady) {
src/plugin/spectrogram.js:334:        if (this.wavesurfer.isReady) {

so we should either:

  1. get rid of the isReady() method altogether and make the isReady attribute public
  2. or change the existing code and make it use the isReady() method and rename the isReady attribute to something like _isReady so it does not get overwritten.

I favor the first option.

Thoughts? cc @katspaugh

I also vote for the first option. It's just a boolean property.

Hi

I have double checked , and I see only isReady() documented here https://wavesurfer-js.org/api/class/src/wavesurfer.js~WaveSurfer.html https://wavesurfer-js.org/api/class/src/wavesurfer.js~WaveSurfer.html

If its an .isReady attribute I then need to make my own listener.

In line with the other covenience Classes in WS I think it should be a method that returns a Boolean, which is what I was looking for in the first place.

Cristian Vogel : NeverEngineLabs
DK2200 Copenhagen
www.neverenginelabs.com http://www.neverenginelabs.com/
music.cristianvogel.com http://music.cristianvogel.com/
@neverenginelabs

On 18 Mar 2019, at 00.29, Thijs Triemstra notifications@github.com wrote:

getReady() does not exist, where is this documented?

isReady is defined as both a attribute and method, something that seems to be introduced in 2.0.5 by @Guisch https://github.com/Guisch (and approved by me 😞), see #1338 https://github.com/katspaugh/wavesurfer.js/pull/1338 and https://github.com/katspaugh/wavesurfer.js/blob/72bdf70a5b3d9f3ea5bb7cb5326f68ce469e2a6d/CHANGES.md#205-26022018 https://github.com/katspaugh/wavesurfer.js/blob/72bdf70a5b3d9f3ea5bb7cb5326f68ce469e2a6d/CHANGES.md#205-26022018
While testing wavesurfer.isReady returns true and wavesurfer.isReady() throws a TypeError because it's not defined (and overwritten by the isReady attribute).

When grepping through the code it looks like isReady is already used in numerous places (and using it as an attribute):

$ grep -Rn 'isReady' src/
src/wavesurfer.js:387: this.isReady = false;
src/wavesurfer.js:946: * @example const isReady = wavesurfer.isReady();
src/wavesurfer.js:949: isReady() {
src/wavesurfer.js:950: return this.isReady;
src/wavesurfer.js:1192: this.isReady = true;
src/wavesurfer.js:1329: this.isReady = true;
src/wavesurfer.js:1509: this.isReady = false;
src/wavesurfer.js:1539: this.isReady = false;
src/plugin/regions.js:658: if (this.wavesurfer.isReady) {
src/plugin/timeline.js:189: if (this.wavesurfer.isReady) {
src/plugin/minimap.js:177: if (this.wavesurfer.isReady) {
src/plugin/spectrogram.js:334: if (this.wavesurfer.isReady) {
so we should either:

get rid of the isReady() method altogether and make the isReady attribute public
or change the existing code and make it use the isReady() method and rename the isReady attribute to something like _isReady so it does not get overwritten.
I favor the first option.

Thoughts? cc @katspaugh https://github.com/katspaugh
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/katspaugh/wavesurfer.js/issues/1597#issuecomment-473726545, or mute the thread https://github.com/notifications/unsubscribe-auth/AMPBeuTQ5efJ95_Pl8gSpQct-UONB_K2ks5vXs-9gaJpZM4b4UF5.

If its an .isReady attribute I then need to make my own listener.

I don't get this.

Sorry if my participation is annoying you - I am pretty new to this Javascript thing, and I really like how WaveSurfer has helped me create my own player - I just wanted to try and join in....

The behaviour I was needing, was to find out if the WaveSurfer is ready, and flip a load of flags accordingly. Maybe I am just not doing that the right way.

I have now seen there is an Event I can use that does what I need...

ready – When audio is loaded, decoded and the waveform drawn. This fires before the waveform is drawn when using MediaElement, see waveform-ready.

Good luck with the project, I think its brilliant

Cristian

On 19 Mar 2019, at 15.09, Thijs Triemstra notifications@github.com wrote:

If its an .isReady attribute I then need to make my own listener.

I don't get this.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/katspaugh/wavesurfer.js/issues/1597#issuecomment-474386659, or mute the thread https://github.com/notifications/unsubscribe-auth/AMPBem-dWzoYuI7Ys17yKu0neMEil90Eks5vYO-KgaJpZM4b4UF5.

Sorry if my participation is annoying you

Don't be such a baby. It is not annoying at all.

The behaviour I was needing, was to find out if the WaveSurfer is ready, and flip a load of flags accordingly. Maybe I am just not doing that the right way.

Use the ready event.

that works for me , thanks...

There is an item in the https://wavesurfer-js.org/docs/methods.html list, 14th bullet:
"getReady() – Returns the current ready status."
But apparently this method is not defined in the wavesurfer.js.

What is the "official" way to get the current file loading progress? I'd like to display a status in percent so the user knows how long she has to wait for the full audio to load.

But apparently this method is not defined in the wavesurfer.js.

Well, it sure is, what version are you using? Correction: getReady() is not defined, isReady boolean is.

Check event docs for progress events (https://wavesurfer-js.org/docs/events.html)

It says "3.2.0 (2019-10-25)" in the beginning (https://www.lupino.org/script/wavesurfer.js), downloaded last wednesday.

I tried the event "loading" but that didn't work with the WaveSurfer.load-method; and using ready or waveform-ready only gives me a signal when loading is finished, not the desired difference between already-loaded-file (or remaining-file-to-load) to total-file-size.

I tried the event "loading" but that didn't work with the WaveSurfer.load-method;

What didn't work? loading should be correct event.

Well, it sure is, what version are you using?

actually. it's not a method anymore, it's a boolean now, so wavesurfer.isReady should return correct value. The docs there are outdated, I'll fix that (see #1796)

okay then, i'll give the loading event another try. Thanks for your help :)

any other issues, please open a new ticket instead.

Was this page helpful?
0 / 5 - 0 ratings