java - Check if Android Media Player can play a file -
in android, there way check if given file legitimate file media player? current method of testing if file playable or not in media player.
public boolean isplayable(file file){ try { uri uri = uri.fromfile(file); player.setaudiostreamtype(audiomanager.stream_music); player.setdatasource(this, uri); player.reset(); return true; } catch (exception e){ toast.maketext(this, "invalid file: " + file.getname(), toast.length_short).show(); return false; } }
i'm using exception test, if throws exception , shouldn't play file. me, doesn't seem clean though seems job fine. there better way should looking @ problem? want know if file going throw exception before try plug media player.
Comments
Post a Comment