moay / afterglow

HTML5 video player made easy.
http://afterglowplayer.com
MIT License
234 stars 47 forks source link

unsuscribe events (afterglow.off(...)) dont't work #93

Closed lscofield closed 5 years ago

lscofield commented 5 years ago

"afterglow could not unbind your event because the _callback was not bound"

moay commented 5 years ago

Did you bind a callback first?

lscofield commented 5 years ago

Did you bind a callback first?

Yep

moay commented 5 years ago

Show me your code. :-) It's hard to determine where your problem lies without seeing the code. Link preferred, feel free to send things to mv@moay.de in case you have non-public links.

lscofield commented 5 years ago

Muéstrame tu código :-) Es difícil determinar dónde se encuentra su problema sin ver el código. Enlace preferido, no dude en enviar cosas a mv@moay.de en caso de que tenga enlaces no públicos.

https://pastebin.com/1YHTxwKt

moay commented 5 years ago

Sorry, completely forgot this one. What do you want to achieve? The ready event is fired only once, so you basically cannot unsubscribe when its fired. Well you can, but it doesnt make sense.

Generally speaking, you normally would pack stuff into a function and then bind or unbind the function.

var test = function(e) {
  alert('triggered');
}

afterglow.on('id', 'ready', test);
// or
afterglow.off('id', 'ready', test);

"afterglow could not unbind your event because the _callback was not bound"

This makes me believe, that the callbacks passed into on and off weren't identical. Is that the case? If so, pack your stuff into a function and bind or unbind the function, makes it easier to keep track.