2019-03-18 android获取本地视频时长

...
/**
* get Local video duration
*
* @return
*/
public static int getLocalVideoDuration(String videoPath) {
int duration;
try {
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(videoPath);
duration = Integer.parseInt(mmr.extractMetadata
(MediaMetadataRetriever.METADATA_KEY_DURATION));
} catch (Exception e) {
e.printStackTrace();
return 0;
}
return duration;
}
...

你可能感兴趣的:(2019-03-18 android获取本地视频时长)