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 playab开发者_如何学Pythonle? checking file extension is an option but i would like to make it platform independent and different platform plays different files.
I believe you ar looking for canplay
event:
http://www.w3.org/TR/html5/the-iframe-element.html#mediaevents
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.
精彩评论