jsantell / dancer.js

high-level audio API, designed to make sweet visualizations
jsantell.github.com/dancer.js
MIT License
2.11k stars 211 forks source link

Fix IndexSizeError by checking if audio is seekable, fix invalidHTMLMediaElement by first checking for source #60

Closed jakemmarsh closed 5 years ago

jakemmarsh commented 9 years ago

Add a check to first verify that the current audio is seekable before attempting to call seekable.end(0). Fixes this error:

screen shot 2014-10-13 at 5 52 24 pm

Also adds a check to ensure that we only call createMediaElementSource if we don't already have a source, preventing the invalid HTMLMediaElement error.

theunknownartisthour commented 9 years ago

In this case it's best not to do look ahead (for / 0 type errors), just use fail-fast exception handling. try{ _this.progress = e.currentTarget.seekable.end( 0 ) / e.currentTarget.duration; } catch (e) { _this.progress = 1; } This is a better implementation ;)