ID:133679
 
Some sort of way to pre-compute the length of a file, for purposes of queuing music and/or sound effects over significant periods of time, would be very welcome.

Using the sound.wait = 1 variable works for short term purposes, but to fulfill music for a very long period of time, you must either queue up several songs on a periodic, arbitrary basis, or manually determine the song length and do the work yourself.

Since I was hoping to include a feature which allowed people to simply copy and paste all of the music they wanted to hear into their ./music/ folder, the manual option wouldn't work unless I required users to hand-edit a file to specify their songs. Fan of intuitive design that I am, I'd rather do it automatically for their sake. ;-)
[link]

-- Data
In response to Android Data
Your suggestion isn't at all the same, although it would be useful for synching users. ;-)

My suggestion doesn't care about synchronisation, ignoring the fact that my game is single player: each player would have their own jukebox and the code would just need to know when to transmit a new song to the player. Presently, it's not possible, at least not without specifying a file that contains song lengths, for the reasons I cited earlier.
I don't know if this helps any, but: [link]
In response to CaptFalcon33035
Shadowdarke is actually in the same situation which I mentioned in my last post on this thread: he's assuming that the song would be played globally instead of locally on a per-player basis.

Also, he fails to bring up the fact that a playlist doesn't work, which is what I said earlier. Either you send songs arbitrarily and hope you don't exceed an arbitrary limit on the maximum number of queued songs, or you have to specify all lengths manually. A playlist might work for a few hours, but if you anticipate running a game in the background for half a day (entirely possible in a game which allows some automation), you'll have to keep refilling it, and there's no way to detect which songs are waiting in the queue.

If we can get a way of tracking whether a /sound has been played by a client and getting a signal transmitted to the server when the client commences playing it, on the other hand, that would solve the problem without requiring a length variable... but that would be more difficult than a length variable. =)
In response to Jtgibson
I have taken the time to write some code that may or may not be used in the future for this very thing. Note that I haven't compiled or checked it, so don't bash me for any mistakes I've made.

#define <Deadron/TextHandling>

var/playlist/playlist=new
playlist
var/list/songs = list()
New()
.=..()
generateList()
proc
generateList()
if(fexists("music.cfg")) //configuration file containing music titles & filenames
var/list/L = dd_file2list("music.cfg","\n")
for(var/entry in L)
if(dd_hasprefix(entry,"//")) continue
if(dd_hasprefix(entry,"/*"))
comment=1
continue
if(comment)
if(dd_hassuffix(entry,"*/")) comment=0
continue
var
pos
char
list/possibilities = list(" - ",":","|")
while(!pos && possibilites.len)
char = possibilities[1]
pos = findtext(entry,char)
possibilities -= char
if(!pos) continue
var
filename = copytext(entry,1,pos)
title = copytext(entry,pos+length(char))
songs += new/sound/playlist(title,filename)
else
var
list/L = flist("music/")
extensions = list("mid","mod","it","s3m","xm","oxm","wav","ogg","raw","wma","aiff")
for(var/X in L)
var/extension = copytext(X,length(X) - 2)
if(!(extension in extensions)) continue
songs += new/sound/playlist(filename = X)
NextSong(client/C,sound/S)
var/sound/X = pick(songs) - S
C << X
sound/playlist
//special playlist sound
var/title
volume = 75
New(title,filename)
src.file = file("music/[filename]")
src.title = title

/*
Started and Stopped are called when the song has started or stopped playing on the client.
As you can see Stopped is VERY useful and can allow you to switch to the next song in the queue.
Started may be useful in some situations, such as for visual effects (an indicator on the interface
that a song is currently playing, perhaps?)
*/

Stopped(client/C)
playlist.NextSong(C,src)
Started(client/C)
C << "<b>Now playing: [src.title ? "[src.title] ([src.file])" : (src.file)]</b>"

/*
Play is called when the song is about to get played by a client.
The "resource" argument is 1 if the player has the song in their resource file, 0 if not.
return 1 to send the song (if the player doesn't have it) and play it, 0 to abort.
*/

Play(client/C,resource) return 1


-- Data
In response to Android Data
Interesting code, but that's in entrenched in the "requires manual specification of file lengths" field.

All I'm asking for is the ability to read an audio file and determine its length programmatically. For wave files, it's very easy: determine the number of bits in the file and divide by the bit rate (e.g., something that is 22.5 kB at 22,500 Hz is 1 second long). For OGG files, I'd be shocked if libvorbis didn't include a way of determining maximum length. For module files, FMODex probably has a routine in there somewhere, and even if it doesn't, it can be found through brute force in the same method that Open Modplug Tracker uses.

I could write a DLL, but I'd hate to force people to run my game in Trusted mode. =P