If you have tracks where their length is invalid or displayed at -00:00, this script will resolve this by loading each track into an Aux Player, grabbing the actual track length and updating the database entry. This can take a long time depending upon the number of tracks in your library and you would need the AUX1 Player available.
var myQ : TDataSet;
var filLoc : String;
var Song1 : TSongInfo;
//SQL if duration is less than .1 seconds
myQ := Query('SELECT * FROM songlist WHERE duration < :value',[100], False);
//SQL for all songs
//myQ := Query('SELECT * FROM songlist WHERE songtype = :type',['S'], False);
myQ.First;
Song1 := TSongInfo.Create;
while not myQ.EOF do
begin
filLoc := myQ['filename'];
Song1['filename'] := filLoc;
Song1['artist'] := myQ['artist'];
Song1['title'] := myQ['title'];
Aux1.QueueSong(Song1);
ExecSQL('UPDATE songlist SET duration = :newduration where id = :songid',[Aux1.duration, myQ['ID']]);
//to ensure that the duration field isn't carried over to the next song
Aux1.Eject;
myQ.Next;
end;
myQ.Free;
Song1.Free;
Comments