scottschiller / SoundManager2

A JavaScript Sound API supporting MP3, MPEG4 and HTML5 audio + RTMP, providing reliable cross-browser/platform audio control in as little as 12 KB. BSD licensed.
http://www.schillmania.com/projects/soundmanager2/
Other
4.99k stars 768 forks source link

There is no way to differentiate one type of error from another #230

Open polteennick opened 6 years ago

polteennick commented 6 years ago

onerror method is called when any error happened. I can't handle different errors differently

scottschiller commented 6 years ago

@polteennick Sorry for the slow reply. I'll review this for the next SM2 release. Right now, you should get the same error event passed to your handler that I'm given from HTML5.

Codes are typically as follows:

/**
 * HTML5 error codes, per W3C
 * Error code 1, MEDIA_ERR_ABORTED: Client aborted download at user's request.
 * Error code 2, MEDIA_ERR_NETWORK: A network error of some description caused the user agent to stop fetching the media resource, after the resource was established to be usable.
 * Error code 3, MEDIA_ERR_DECODE: An error of some description occurred while decoding the media resource, after the resource was established to be usable.
 * Error code 4, MEDIA_ERR_SRC_NOT_SUPPORTED: Media (audio file) not supported ("not usable.")
 * Reference: https://html.spec.whatwg.org/multipage/embedded-content.html#error-codes
 */