Calculate audio playtime

Discuss and share scripts and script files...
highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Calculate audio playtime

Post by highend »

This script calculates the total audio playtime of:
- All selected items
- Or if none is selected, all items in the current folder

It does only work on items that have a codec installed. Out of the box
this should be true for .mp3 and .wav files and probably .ogg / .flac.

It should work on all Windows systems / languages and it should also work
on any number of audio files (it calculates the values in batches)

Increase the $splitOnNumOfDurations = 500; variable if you want (the higher the less
loops are required). It should be rather safe up to a value of 1000. If you get an error, reduce
it...

The original idea is taken from here: viewtopic.php?f=3&t=12177

Thanks to TheQwerty for the duration conversion part!

Current version:
Calculate audio playtime_v0.4.xys
(5 KiB) Downloaded 65 times
Old versions:
Calculate audio playtime_v0.3.xys
(4.96 KiB) Downloaded 159 times
Calculate audio playtime_v0.2.xys
(5.53 KiB) Downloaded 267 times
Calculate audio playtime.xys
(4.29 KiB) Downloaded 206 times
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

JLoftus
Posts: 577
Joined: 22 Jan 2014 14:58

Re: Adding up the Length column

Post by JLoftus »

Thanks... hee heee, running Win 10 x64, throws error "Win 2000 is not supported"

"ver" outputs:
Microsoft Windows [Version 10.0.16299.192]

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Adding up the Length column

Post by highend »

Changed the version comparison system, redownload the file
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

JLoftus
Posts: 577
Joined: 22 Jan 2014 14:58

Re: Adding up the Length column

Post by JLoftus »

Yup, working fine now, thanks

Papoulka
Posts: 455
Joined: 13 Jul 2013 23:41

Re: Calculate audio playtime

Post by Papoulka »

Are folders "items"? It doesn't work when I select a folder or group of folders. It only works within a folder.

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Calculate audio playtime

Post by highend »

No, folders weren't treated as "items".

This has now been changed:

Code: Select all

/*
******************************************************************************
@Changelog:
v0.2
  + Now allows to process all items, even inside subfolders (recursively!)

v0.1
   Initial release

******************************************************************************
*/

One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Shahin
Posts: 1
Joined: 15 Jun 2020 10:43

Re: Calculate audio playtime

Post by Shahin »

Please advise how to use the shared file .xys?
should i copy and paste it into the xyplorer files folder?

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Calculate audio playtime

Post by highend »

viewtopic.php?f=7&t=6560
B
B.) How to execute an script by loading it from an file
and the following paragraphs
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Calculate audio playtime

Post by highend »

v0.3 added. If your playtimes don't exceed 24 hours you don't need to replace your old version.

Code: Select all


/*
******************************************************************************
@Changelog:
v0.3
  * If FormatDuration() is invoked with $type = "new", output is now formatted
    to <hours>:<minutes>:<seconds> even if hours >= 24
  ! Fixed a format output bug if hours >= 24
******************************************************************************
*/

Thanks @jupe for reporting the bug
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Malarki
Posts: 109
Joined: 03 Dec 2019 02:51

Re: Calculate audio playtime

Post by Malarki »

I originally downloaded and ran v0.2, which still works. In Dec 2020 replaced it with v.03 but I'm not sure I ever tried this new one.

Symptom with v0.3: With one 7min 13 sec MP3 file selected, stepping through the script seems to show that everything is fine right through the final FormatDuration function which calculates "433" (sec) but APPARENTLY isn't reporting it correctly back to the main program in $result. So the Echo window just shows "Total playtime: " ie. no actual time value displayed.

This must have worked originally so I wonder if Function syntax has changed in the meantime. That's one difference between v0.2 and v0.3.

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Calculate audio playtime

Post by highend »

Yeah, it's a bug. Fixed with v0.4

Code: Select all

v0.4
  ! Fixed a bug if hours < 24
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

suslo
Posts: 178
Joined: 02 Feb 2015 05:02

Re: Calculate audio playtime

Post by suslo »

this script never worked for me:
- in the 'echo' sub-window: it just displays zeroes
- there were at least 3-4 attempts (in 2018-2023), including the fresh v0.4

i mainly interested in the simple wav-format, it has 99,9% in my priorities (among audio-formats)

is there something that i may try to alter (in the script)?
so that it began working

i have:
xy-19.40.0100
win-server-03, 32-bit, r2 sp2
8 gb ram

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Calculate audio playtime

Post by highend »

Select one audio file, execute this script and post the result:

Code: Select all

text "#21: " . property("#21", <curitem>) . " | #27: " . property("#27", <curitem>);
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

suslo
Posts: 178
Joined: 02 Feb 2015 05:02

Re: Calculate audio playtime

Post by suslo »

Code: Select all

#21:  | #27: 

highend
Posts: 13260
Joined: 06 Feb 2011 00:33

Re: Calculate audio playtime

Post by highend »

Get this script: viewtopic.php?p=150223#p150223

Select an audio file and execute the script, post the FULL result of the output window
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Post Reply