Java tutorial
//package com.java2s; public class Main { /** * Convert a time in ms in a percentage of the total duration time * * @param currentDuration, long - time passed from the start of playing (ms) * @param totalDuration, long - total duration of the reproduction (ms) * @return int, percentage of the file played */ public static int getProgressPercentage(long currentDuration, long totalDuration) { Double percentage = (double) 0; long currentSeconds = (int) (currentDuration / 1000); long totalSeconds = (int) (totalDuration / 1000); // calculating percentage percentage = (((double) currentSeconds) / totalSeconds) * 100; // return percentage return percentage.intValue(); } }