PDA

View Full Version : More elegant mp3


gabrielfenwich
12-12-2004, 01:29 AM
This is my quick and dirty effort at an mp3 player loosely based on a slideshow example from somewhere on the forums
__________________________________________________ _______________






Page properties code:
---> on open tab:
------------------------------------------------
-- Thanks TJ for the original code example
------------------------------------------------
--Disable listbox Updating

ListBox.SetUpdate("ListBox1", false);
-- commented out the browse function below and just made it so that it lists the folder contents
-- folder = Dialog.FolderBrowse("Open the images Folder for a list of pictures. Just click OPEN", "AutoPlay\\docs\\music");

Folder.SetCurrent("AutoPlay\\Docs\\music");
folder = Folder.GetCurrent();

--populate tables with all the .mp3 and .wma files
file_mp3 = File.Find(folder, "*.mp3", false, false, nil);
file_wma = File.Find(folder, "*.wma", false, false, nil);
audio = {file_mp3, file_wma};

--do the following for each file:
for k in audio do --loops through the different audio types
for j,file_path in audio[k] do --loops through each audio file

--dump data to listbox
ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path);
end
end

--hopefully reenable update of the listbox
ListBox.SetUpdate("ListBox1", true);
__________________________________________________ ________






--->On close tab

--- hopefully this clears the listbox
ListBox.DeleteItem("ListBox1", LB_ALLITEMS);
__________________________________________________ _________





List box
L-----> action / select

selected = ListBox.GetSelected("ListBox1");


for j,k in selected do

-- this is the original load routine
Image.Load("picture", ListBox.GetItemData("ListBox1", k));


-- we dump " ListBox.GetItemData("ListBox1", k) " in instead of the filepath
Audio.Load(CHANNEL_NARRATION, ListBox.GetItemData("ListBox1", k), true, false);

end




If anyone knows of a more elegant way to do this could they please let me know

Thanks Gabby

darknis
12-13-2004, 09:49 AM
Read this
http://www.indigorose.com/forums/showthread.php?t=2860

TJ_Tigger
12-13-2004, 06:48 PM
If anyone knows of a more elegant way to do this could they please let me know


If it isn't broke then don't try and fix it.