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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -