Achshar
Achshar

Reputation: 5243

html5 audio 'mediaplayable' event?

my app lets user drag songs to add them. I was wondering how can i make sure that the files user dragged are actually music files and are playable? i can use loadedmetadata event but how would i know when a file does not get loaded so that i can discard it?

i remember readng about an event that would tell if the file is playable. I googled a lot but couldn't find it, maybe my mind is making things up.. so how can i know weather a file is playable? checking file extension is an option but i would like to make it platform independent and different platform plays different files.

Upvotes: 2

Views: 223

Answers (2)

Achshar
Achshar

Reputation: 5243

What i ended up with was the progress event. canplay waits for data to be loaded so that some of it can be played, but progress shows that the media is available and it is now progressing to download its meta.. If given an invalid file, it throws an error event instead of progress hence facilitates the knowledge of weather the file is a valid and playable media file or not.

Upvotes: 0

c69
c69

Reputation: 21497

I believe you ar looking for canplay event: http://www.w3.org/TR/html5/the-iframe-element.html#mediaevents

Upvotes: 1

Related Questions