Forum > General

Accessing File Properties

(1/3) > >>

stephanos:
Dear All

I am developing further features to my MP3 playlist writing programme using Lazarus 2.0.8.  The programme lives on the player.  So far I can select a number of files (that are on the player) and write them into a Memo, do a little bit of editing, and save the Memo content to the M3U file that is also on the player.

I will also write a feature to perform validation on the path/filenames as the Play List feature of the MP3 player only reads file names with characters of 1 Byte and between ALT+32-255, 256-275, 278-287.  An interesting limitation of the Player.

I am thinking ahead and will need to add another feature.  I want to add up the play time of each MP3 file that is in the Memo.  That way I will know if I have enough music to last the journey.

I have done some searches but cannot find anything that I understand.  What do I enter in Uses?  If someone can give the names of functions I can go looking.  So far, and with the help of this forum, I have been capturing multiple names of files using FileNameEdit1Change, and writing all the selected paths/file names to a string:
     
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TheFileName := FileNameEdit1.DialogFiles.Text;
But I am sure that is not the way to go as I now want system information in the form of file properties, namely “Length”.

So here I am again, any help welcomed, but remember I do not know much

Thanks

Stephanos
Using Windows 10

jamie:
use "FileSize" or "FindFirst" for each name string in the list.

if using findfirst make sure you close the search record before starting the next file name to search..

The FindFirst has information about the file, size, date etc.

stephanos:
Dear Jamie

Thanks.  I went here:
https://www.freepascal.org/docs-html/rtl/sysutils/findfirst.html
to research FindFirst.  The properties this function can detect are read-only, a system file, a directory, and hidden.  Moreover, I will not need to search a TsearchRec as I want to selected a file using FileNameEdit1Change.  Having selected it the path/filename is written to a string. At that stage I want to extract the data for the files property: Length, add that to a total etc.

If I can do this for one file I am sure I can then teach myself how to do it for multiple files selected at the same time.

Any further help appreciated

Stephanos

trev:
See FpFstat for file properties.

Zvoni:
Since he wants the playing time:
https://stackoverflow.com/questions/1065086/duration-of-an-mp3-wav-audio-file

The "hard" way would be to use the ffmpeg-libs and read the duration directly

Navigation

[0] Message Index

[#] Next page

Go to full version