Indigo Rose Software
  #1  
Old 06-15-2006
mrjoz mrjoz is offline
Forum Member
 
Join Date: Jun 2006
Location: Chesterfield, UK
Posts: 7
Lightbulb Example: OGG Audio Player with Tag Updates

Hi all, i hope this will be of use to a few ppl. What ive done is add/doctor examples to get what i believe is a dynamic audio player. but what i really want is to be able to call funtions from the Global Events so i dont have to put all this code on each and every page. As my project has multiple pages i feel that im wasting code and therefore resouces. So if anyone can workout how to make it Global it'll be even more productive to us all.

At Preload:
Code:
-- this gets the OGG files in the below folder and loads them into the listbox
atbFiles = File.Find("AutoPlay\\Audio\\music", "*.ogg", false, false, nil, nil);
TextFile.WriteFromTable("AutoPlay\\Audio\\music\\playlist.ini", atbFiles, false);
if atbFiles then
	for i,v in atbFiles do
		ListBox.AddItem("Music list", String.SplitPath(v).Filename, v);
	end
end
audio = File.Find("AutoPlay\\Audio\\music", "*.ogg", false, false, nil, nil);



ListBox.SetVisible("Music list", false);
this gets the OGG Audio files from a folder and stores them in a table, while also writing the table to "playlist.ini" (this is because i am using multiple pages and it seems easier to call/clear a file). the last line of code also hides the listbox that the table is stored in (wasn't needed for me).

On show:
Code:
-- this gets the selected song and loads it.
ListBox.SelectItem("Music list", 1)
tbSelected = ListBox.GetSelected("Music list")
for index, item in tbSelected do
        output = item;
    end
if tbSelected then
	strScript = ListBox.GetItemData("Music list", tbSelected[1]);
	Audio.Load(CHANNEL_BACKGROUND, strScript, true, false)
end

-- Make sure the Load action was successful
if (Application.GetLastError() == 0) then

	-- Check for file description tags
	tags = Audio.GetOggTags(CHANNEL_BACKGROUND);
	if (tags ~= nil) then
	    albumtitle = tags.TITLE;
	    artist = tags.ARTIST;
	    album = tags.ALBUM;
	    track = tags.TRACKNUMBER;
	end
end

-- Update the status text display
	Paragraph.SetText("track_title", albumtitle);
	Paragraph.SetText("artist", artist);
	Paragraph.SetText("current_ablum", album);
	Paragraph.SetText("track_number", track);
this code selects the first Ogg track and starts playing it, while the latter code collects the OggTags and stores them in variables to be called on the paragraph objects displaying the Tag data

On audio:
Code:
-- This is to set up the next song when the one playing finishes.
--if you want more than 4 songs, just continue the code as below.
if e_State == "Finish" then
   if output == 1 then
	ListBox.SelectItem("Music list", 2)
	strScript = ListBox.GetItemData("Music list", 2);
	elseif output == 2 then
		ListBox.SelectItem("Music list", 3)
		strScript = ListBox.GetItemData("Music list", 3);
		elseif output == 3 then
			ListBox.SelectItem("Music list", 4)
			strScript = ListBox.GetItemData("Music list", 4);
			elseif output == 4 then
				ListBox.SelectItem("Music list", 1)
				strScript = ListBox.GetItemData("Music list", 1);
				end

--this just gets the selected song and loads it.
tbSelected = ListBox.GetSelected("Music list")
for index, item in tbSelected do
        output = item;
    end
if tbSelected then
	Audio.Load(CHANNEL_BACKGROUND, strScript, true, false)
end
end

tags = Audio.GetOggTags(CHANNEL_BACKGROUND);
	if (tags ~= nil) then
	    albumtitle = tags.TITLE;
	    artist = tags.ARTIST;
	    album = tags.ALBUM;
	    track = tags.TRACKNUMBER;
	end
	
-- Update the status text display
	Paragraph.SetText("track_title", albumtitle);
	Paragraph.SetText("artist", artist);
	Paragraph.SetText("current_ablum", album);
	Paragraph.SetText("track_number", track);
all the on audio code does is select the next track and play it after the current track finishes playing. oh, and it also updates the OggTags data which is displayed along side the listbox

On key:
Code:
-- e_Key is a built in variable that gets generated by the On Key event.
-- 13 is the virtual key code value for the [Enter] key.

if e_Key == 222 then
    ListBox.SetVisible("Music list", true);
else
end
sets the listbox "music list" to visible on ---> # <--- key press

i have only been using this to troubleshoot and make sure the code is doing what i want it to do when i have no visial signs to work from.

On close
Code:
ListBox.DeleteItem("Music list", -1);
Code for listbox named "Music list"
Code:
tbSelected = ListBox.GetSelected("Music list")
for index, item in tbSelected do
        output = item;
    end
if tbSelected then
	strScript = ListBox.GetItemData("Music list", tbSelected[1]);
	Audio.Load(CHANNEL_BACKGROUND, strScript, true, false)
end
as i said, i use multiple pages. this code clears the listbox so when i jump page i dont get repeat items (tracks) in my now newly populated playlist
Attached Files
File Type: apz dynamic ogg player.apz (10.9 KB, 461 views)
Reply With Quote
  #2  
Old 09-04-2006
spunicher spunicher is offline
Forum Member
 
Join Date: Sep 2006
Posts: 7
ok

-- Update the status text display
Paragraph.SetText("track_title", albumtitle);
Paragraph.SetText("artist", artist);
Paragraph.SetText("current_ablum", album);
Paragraph.SetText("track_number", track);


not working Audio.GetOggTags please mp3 track?

please select all track play automatic??

Last edited by spunicher; 09-04-2006 at 10:33 AM.
Reply With Quote
  #3  
Old 09-10-2006
Josué Alba's Avatar
Josué Alba Josué Alba is offline
Forum Member
 
Join Date: Mar 2005
Posts: 134
Nice example you have there. I'm using it right now.
Reply With Quote
  #4  
Old 09-10-2006
mrjoz mrjoz is offline
Forum Member
 
Join Date: Jun 2006
Location: Chesterfield, UK
Posts: 7
thanx josue, u've got mail
Reply With Quote
  #5  
Old 12-28-2006
Jonas DK's Avatar
Jonas DK Jonas DK is offline
Forum Member
 
Join Date: Jul 2004
Location: Denmark
Posts: 282
Changed the code to be a little bit more dynamicly.

instead of limiting your playlist to 4 songs I made it loop continuasly so that every time a song ends it just loads the next song on the list and when it hits the last song it starts over from 1.

you can also now add song will playing from the list. They are just added to the end because every time a song ends it checks the listbox to see how many items are in it.

anyway here is the code, maybe someone can fin tune it.

On Audio:
Code:
nPlaylist = ListBox.GetCount("liPlaylist");
if e_State == "Finish" then
   if output >= nPlaylist then
   	output = 1
	ListBox.SelectItem("liPlaylist", output)
	strScript = ListBox.GetItemData("liPlaylist", output);
	else output = output+1
		ListBox.SelectItem("liPlaylist", output)
		strScript = ListBox.GetItemData("liPlaylist", output);
		end
	
--this just gets the selected song and loads it.
tbSelected = ListBox.GetSelected("liPlaylist")
for index, item in tbSelected do
        output = item;
    end
if tbSelected then
	Audio.Load(CHANNEL_BACKGROUND, strScript, true, false)
end
end
By the way, the aydio player works fine with mp3 files as well they are just not officially supported by AMS.
cheers,
Jonas

Last edited by Jonas DK; 12-28-2006 at 08:20 PM. Reason: forgot something
Reply With Quote
  #6  
Old 03-30-2007
SiNisTer's Avatar
SiNisTer SiNisTer is offline
Forum Member
 
Join Date: Mar 2007
Posts: 186
Grin

nice piece of coding u got there!!
but i was wondering if u could help me out for an audio player i designed. I need a slider to keep track of the audio length as it plays like all other audio players...
wondering if u or anyone else can lend a hand..please!!

Thanks n,
keep it rockin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Audio Stuttering with ogg and all other audio in ams goukilord10 AutoPlay Media Studio 6.0 12 05-26-2006 05:15 PM
Build failure because of errors Ed Stanley AutoPlay Media Studio 6.0 2 02-07-2006 04:51 PM
INFO: Difference between the Media Player Object and the AVI Object Support AutoPlay Media Studio 4.0 Examples 0 10-29-2002 03:15 PM
HOWTO: Make a Media Player Object Go Full Screen Support AutoPlay Media Studio 4.0 Examples 0 10-23-2002 12:23 PM
Menu in session2 to play audio tracks in session 1, cd player? MartinUK AutoPlay Menu Studio 3.0 1 03-20-2002 06:35 PM


All times are GMT -6. The time now is 06:24 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software