learn how to read and display information from imported mp3′s swishmax 4 tutorial.
First Of All:
Open Swishmax 4 set your stage size and width. for this tutorial i have used the following settings, width = 349 x height = 116 25 frame rate #FFFFFF background colour.
Introduction:
this tutorial uses the loadSound(); function, so first of all create a folder name it mp3s and place an mp3 inside it and rename it to 1.mp3.
and use the following script to load the sound into swishmax 4.
1 2 3 4 5 | onFrame (1) { var mYsound:Sound = new Sound(); mYsound.loadSound("mp3s/1.mp3", true); _soundbuftime = 10; } |
now save your movie as loadsound.swi inside the folder that contains the mp3s folder you have just created, now export the swf into the same folder.
press Ctrl+T and your song should now be playing.
here is a list of tags that can be used with swishmax
COMM mYsound.id3.comment
TALB mYsound.id3.album
TCON mYsound.id3.genre
TIT2 mYsound.id3.songname
TPE1 mYsound.id3.artist
TRCK mYsound.id3.track
TYER mYsound.id3.year
Step.2
now for getting the information from the mp3 and displaying it in swishmax 4, create a dynamic text box and name it output_txt. you would then use the following script on Scene_1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | onFrame (1) { output_txt.autoSize = "left"; output_txt.multiline = true; var mYsound:Sound = new Sound(); mYsound.onLoad = function() { mYsound.start(); _soundbuftime = 10; }; mYsound.onID3 = function():Void { output_txt.text += "Artist:\t" + mYsound.id3.TPE1 + "\n"; // artist instead of TPE1 output_txt.text += "Song:\t" + mYsound.id3.TIT2 + "\n"; // songname instead of TIT2 output_txt.text += "Album:\t" + mYsound.id3.TALB + "\n"; // album instead TIT2 output_txt.text += "Year:\t" + mYsound.id3.TYER + "\n"; // year instead of TYER }; mYsound.loadSound("mp3s/1.mp3"); } onFrame (2) { stop(); } |
save export and press Ctrl+T your should have something looking like the example at the top of the page, minus the two buttons.
![]() | download: ID3 Mp3 Player (17.72KB) added: 28/12/2010 clicks: 76 description: swishmax 4 mp3 player that reads the info from the id3 tags from within the mp3 file. |
0 التعليقات:
Post a Comment