how would i get the length of a source? i need it because im making a music player
i have all my music in a folder, how would i make a source for each and everyone of them without actually knowing the name of the file?
and how would i get the extension of a file, ex .mp3?
getting the length of a source and some more questions
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: getting the length of a source and some more questions
AFAIK, you can only get the length of [wiki]SoundData[/wiki], so you would do something like this:Doctory wrote:how would i get the length of a source?
Code: Select all
local sd = love.sound.newSoundData(sound_filename)
local length = sd:getSampleCount() / sd:getSampleRate()
local source = love.audio.newSource(sd)
With [wiki]love.filesystem.getDirectoryItems[/wiki].Doctory wrote:how would i make a source for each and everyone of them without actually knowing the name of the file?
Something like:Doctory wrote:and how would i get the extension of a file, ex .mp3?
Code: Select all
local extension = filename:sub((filename:find(".", 1, true))) -- parentheses important
Help us help you: attach a .love.
Re: getting the length of a source and some more questions
thanks robinRobin wrote:-snip-
Who is online
Users browsing this forum: No registered users and 191 guests