Android examples for Media:Media Player
get Media Duration
//package com.java2s; import android.media.MediaPlayer; import java.io.File; import java.io.IOException; public class Main { public static int getDuration(File f) throws IOException { MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setDataSource(f.getAbsolutePath()); mediaPlayer.prepare();/*from w w w.ja va 2 s .c o m*/ int duration = mediaPlayer.getDuration(); mediaPlayer.release(); return duration; } }