Announcement

Collapse
No announcement yet.

HOWTO: Set up an MP3 Playlist

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HOWTO: Set up an MP3 Playlist

    HOWTO: Set up an MP3 Playlist

    HOWTO: Set up an MP3 Playlist

    Document ID: IR04030
    The information in this article applies to:
    • AutoPlay Media Studio 4.0

    SUMMARY

    This article will explain how to set up an MP3 playlist using AutoPlay Media Studio 4.0.

    DISCUSSION

    There are many different ways to create an MP3 Playlist in AutoPlay Media Studio 4.0. The most popular would be to read the information from a file, or let the user choose MP3 files from a list box. This article will explain both methods.

    Reading in a Play List

    The first thing to do if you are using this method is to actually create the playlist using a specific format. In general your playlist should consist of the full path to your MP3 files. Since these paths will be used by AutoPlay it is important that you use the built-in variables %SrcDir% or %SrcDrv%. You will also have to delimit your paths in some manner; it is a good idea to use characters that cannot appear in paths. In this example we will use the comma.

    Our play list will be called "playlist.txt" and it will be located on the root of our CD-ROM. Here are the contents of "playlist.txt":

    %SrcDir%\Music\Dancer.mp3,%SrcDir%\Music\TalkCan.m  p3,%SrcDir%\Music\SoupSpoon.mp3

    Now that we have our playlist defined we will have to store it in AutoPlay Media Studio 4.0, we will store the play list in a Global list. We will create the Global list in the menu under: Project | Global Lists. We will call our Global list "PlayList" and not add any items to it.

    The next step is to read in the contents of "playlist.txt" and store it in a variable; we will use the variable %PlayListFile% in this example. To do this we will use a TextFile.Read() action:

    %PlayListFile% = TextFile.Read ("%SrcDir%\playlist.txt")

    Now we have the contents of our playlist stored in %PlayListFile%, we now have to get the information from our variable to our Global list. To do this we will use a GlobalList.Add() action and add the playlist to our Global list at once.

    GlobalList[PlayList].Add (Beginning, "%PlayListFile%")

    Here are the settings for the GlobalList.Add() action:

    Name: PlayList
    Add at: Beginning
    Text: %PlayListFile%
    Delimiter: ,

    Now our Global list, PlayList, contains our playlist, the only thing left to do is play our MP3 files. First we will set the current position of our Global list to be the first time in the list. Then we will use a GlobalList.GetItem() action to get the current item from our Global list and store it in a variable. We will then load that variable into AutoPlay's MP3 Player and then play it. Here is what those actions will look like:

    GlobalList[PlayList].SetPosition (First)
    %MP3File% = GlobalList[PlayList].GetItem (Current)
    MP3.Load ("%MP3File%")
    MP3.Play

    Now we have the first item in our play list playing in AutoPlay. Here is what the entire action script looks like so far:

    %PlayListFile% =TextFile.Read ("%SrcDir%\playlist.txt")
    GlobalList[PlayList].Add (Beginning, "%PlayListFile%")
    GlobalList[PlayList].SetPosition (First)
    %MP3File% = GlobalList[PlayList].GetItem (Current)
    MP3.Load ("%MP3File%")
    MP3.Play

    These actions can go anywhere in your AutoPlay application, on the "On Click" event of a "Play" button, or on the Page "On Show" event.

    Now we need our AutoPlay application to move to the next song once the first song finished. To do this we will need to add actions to the MP3 Player "On Song End" event. You can get to this event from the menu under: Project | MP3 Player.

    When a song ends all we have to do is move to the next position in our Global list, load that song into the MP3 Player, and then play the song. Here are the actions that will accomplish this:

    GlobalList[PlayList].SetPosition (Next)
    %MP3File% = GlobalList[PlayList].GetItem (Current)
    MP3.Load ("%MP3File%")
    MP3.Play

    The GlobalList.SetPosition() action sets the current position to be the next song that we want to play. The GlobalList.GetItem() action gets the full path to the next MP3 that we are going to play. Finally the MP3.Load() action loads the MP3, and the MP3.Play action plays it.

    List Box Playlist

    In this example we will create a List Box playlist that reads every MP3 file from a directory and display them in a List Box Object. The end user will then be able to double-click on any file in the List Box in order to start the song playing.

    All of our MP3 files will be stored in this directory "%SrcDir%\Music", and we will read the information into a List Box Object named "lstPlayList". The following actions should take place on the Page "On Show" event:

    %MP3Files% = File.Search ("*.MP3", CustomPaths)
    ListBoxObject[lstPlayList].AddFiles (Start, "%MP3Files%")

    The settings for the File.Search() action are:

    Store result in variable: %MP3Files%
    Delimiter: ;;
    Filename: *.MP3
    Display progress dialog: unchecked
    Specific folders/drives: Checked
    Custom folders: %SrcDir%\Music

    The settings for the ListBoxObject.AddFiles() action are:

    Name: lstPlayList
    Add at Position: Start
    Items to add: %MP3Files%
    Delimiter: ;;
    Information to display: Filename only

    The File.Search() action gets a list of all the MP3 files in the %SrcDir%\Music folder, and then the ListBoxObject.AddFiles() adds that information to the List Box Object.

    Now we have to allow the user to double-click on one of the entries in the List Box Object in order to start it playing. To do this we will add actions to the List Box Object "On Double-Click" event. The actions will look like this:

    %SelectedIndex% = ListBoxObject[lstPlayList].GetSelected
    %MP3Path% = ListBoxObject[lstPlayList].GetItemData (%SelectedIndex%)
    MP3.Stop
    MP3.Load ("%MP3Path%")
    MP3.Play

    The ListBoxObject.GetSelected() action gets the index of the List Box entry that the user double-clicked. The ListBoxObject.GetItemData() action gets the data of the List Box Entry that the user clicked on. The data is the full path to the MP3 files, this was stored in the data section of the List Box entry by the ListBoxObject.AddFiles() action. Then the MP3.Stop() action stops any MP3 that might by playing, the MP3.Load() action loads the MP3 that the user double-clicked on, and finally the MP3.Play() action plays MP3.

    MORE INFORMATION

    For more information please see the following topics in the AutoPlay Media Studio 4.0 help file:

  • Command Reference | Global Lists
  • Command Reference | MP3 Player
  • Command Reference | Built-in Variables
  • Command Reference | Actions | Text File | Read
  • Command Reference | Actions | Global List | Add
  • Command Reference | Actions | Global List | Set Position
  • Command Reference | Actions | Global List | Get Item
  • Command Reference | Actions | MP3 | Load
  • Command Reference | Actions | MP3 | Play
  • Command Reference | Actions | File | Search
  • Command Reference | Actions | List Box Object | Add Files
  • Command Reference | Actions | List Box Object | Get Selected
  • Command Reference | Actions | List Box Object | Get Item Data
  • Command Reference | Actions | MP3 | Stop
  • KEYWORDS: AutoPlay Media Studio 4.0, MP3 Play list


    Last reviewed: October 24, 2002
    Copyright © 2002 Indigo Rose Corporation. All rights reserved.
Working...
X
😀
🥰
🤢
😎
😡
👍
👎