Command Reference - Action Examples
|
Actions used: |
In this example, we'll let the user browse for an MP3 file, and then we'll play the MP3 that the user selected.
Here's what the action list looks like:

First, we use a "Dialog - File Browse" action to let the user browse for an MP3 on their system. To help make their search a bit easier, we use a file filter in the File filters field so the browse dialog will only show folders and MP3 files. Enabling the File must exist option will make sure the user selects a file that exists.
We could set a default folder for the dialog in the Default directory field, which is a good idea if we always want the browse dialog to open to the same folder, but for this example we'll leave it blank. That way, if this action script is performed more than once, the browse dialog should open to the same place that the user browsed to the last time.

Once the user selects a file, the full path to the MP3 file that the user selects will be stored in a variable called %FullPath%.
If the user doesn't select a file, though, and just cancels out of the browse dialog, the word "CANCEL" will be stored in %FullPath% instead.
So, we use a "Control Structure - IF" action to start an IF block, so our MP3 loading and playing will only occur if the user actually selected an MP3. The conditional expression will only be true if the word "CANCEL" was not stored in our %FullPath% variable.

Note that although we normally would put quotes around a string, this time we didn't have to, since CANCEL doesn't have spaces or any other value-delimiting characters in it. Usually we put quotes around even single words like CANCEL, just to make it obvious that they are strings...but for this example, we wanted to prove that in some cases it will work fine without the quotes.
Next, we use an "MP3 - Load" action to load the file that the user selected into the global MP3 player.

Then, we use an "MP3 - Play" action to tell the global MP3 player to start playing that file.
Finally, we use a "Control Structure - END IF" action to mark the end our IF block.
Here's a link to the finished example, as an AutoPlay Media Studio 4.0 actions XML file that you can import into an action list:
Browsing_for_and_playing_an_MP3.zip
(Note: save this file to your hard drive and use a tool like WinZip to extract the XML file)