2017年12月25日 星期一

Get duration of the video by uri

Reference:

https://stackoverflow.com/questions/33770188/how-can-i-get-the-duration-resolution-of-a-video-file-programmatically-in-andro/33770238


Code snippet:

MediaPlayer mp = MediaPlayer.create(this, Uri.parse(uriOfFile));
if(mp == null){
    Log.e(TAG, "The record file is invalid");
     return;
}
int duration = mp.getDuration();

沒有留言: