GetTrackLength

The following example will list all the length of all the audio tracks on a CD. CD_INFO is a variable that should be created and inserted into a text box to show the output of this script.

var CD = CreateCDPlayer();

CD_INFO = "";

for (var iTrackNum = 1; iTrackNum <= 99; iTrackNum++)
{
 var TL = CD.GetTrackLength(iTrackNum);
 if (TL > -1)
 {
  // Convert the time in seconds into minutes & seconds
  var M = Math.floor( (TL / 60) );
  var S = TL - (M * 60);
  CD_INFO += "Track " + iTrackNum + ": " + TL + "s (" + M + ":";
  // Add a leading zero to the output for small seconds
  if (S < 10)
  { CD_INFO += "0" + S + ")\n"; }
  else
  { CD_INFO += S + ")\n"; }
 }
 else
 {
  break;
 }
}

Close