Understanding NeoDX Variables
NeoDX allows you to create an unlimited number of media player objects. For example, you could have one media player playing music in the background, and another playing narration in the foreground. Each media player has its own independent volume and balance controls allowing you easily mix and play a variety of media at the same time.
The Media Player ID
To keep track of the different media players, NeoDX assigns each one its own unique identification number. This ID number is stored in the variable that you specify in the dxCreate action's Media Player ID parameter. For example:
dxCreate "Rectangle1" "[Player1]" ""
After creating the media player, dxCreate stores its unique ID number into the [Player1] variable. While the media player is active, you should not modify this variable in any way, because you will need the ID number it contains to control the media player. Other NeoDX actions will use the ID number to distinguish between different media player objects. For example, to load a file:
dxOpenFile "[Player1]" "c:\multimedia\frogs.mpg"
To play the file:
dxPlay "[Player1]" "1"
If you were to create another media player at the same time, that player would need to use a different variable. For example:
dxCreate "Rectangle2" "[Player2]" ""
You could then load a file into the second media player like this:
dxOpenFile "[Player2]" "c:\multimedia\crickets.wav"
Other Media Player Variables
NeoDX also automatically creates several other variables based on the Media Player ID variable. These variables contain information about the media player. These may be inserted wherever normal variables are accepted. For example, after calling dxCreate and dxOpenFile, we can display an alert box to report the length (in hours, minutes and seconds) of the file we've just loaded:
AlertBox "My Media" "Length = [Player1.LengthHMS]"
You could also display the media player's current position (in milliseconds) on screen by adding the [Player1.Position] variable to a VisualNEO for Windows Text object. For example:
Media player variables are read-only, meaning that they can be displayed but not modified using the SetVar or any other action commands. Instead use NeoDX actions like dxSetVolume, dxSetBalance, dxSetPosition, etc. to adjust media player settings.
Here's a list of variables created for each media player by NeoDX. Replace "PlayerID" with the name of your Media Player ID variable.
[PlayerID.State] The current status of the media player. State may contain one of the following values:
Closed The media player is closed. A file has not been loaded.
Open A file has been loaded into the media player.
Playing The media player is playing.
Stopped The media player is stopped.
Paused The media player is paused.
You can use this information to determine if a file has been loaded into the media player. For example:
If "[Player1.State]" "<>" "Closed"
dxPlay "[Player1]" "1"
AlertBox "Error" "You need to open a file first."
[PlayerID.Volume] The media player's current volume level. See dxSetVolume for more information.
[PlayerID.Balance] The audio signal balance between the left and right channels/speakers. See dxSetBalance for more information.
[PlayerID.Rate] The media player's playback rate/speed. See dxSetRate for more information.
[PlayerID.Length] The length of the currently loaded media file in milliseconds.
[PlayerID.LengthHMS] The length of the currently loaded media file formatted as: hours : minutes : seconds : milliseconds.
[PlayerID.Position] The media player's current position in milliseconds.
[PlayerID.PositionHMS] The media player's current position formatted as: hours : minutes : seconds : milliseconds.
[PlayerID.VideoWidth] The default width of the currently loaded video file. For non video files, width will be zero.
You can examine the VideoWidth variable to determine if the file loaded is an audio or video. For example:
If "[Player1.VideoWidth]" ">" "0"
AlertBox "Hello" "This is a video clip."
AlertBox "Hello" "This is an audio clip".
[PlayerID.VideoHeight] The default height of the currently loaded video file. For non video files, height will be zero.
[PlayerID.FileName] The name of the currently loaded media file.
[PlayerID.MarkerPosition] The position of the most recently triggered marker. The time format of this variable will be the same as the one used when defining the marker with dxAddMarker.
[PlayerID.MarkerData] Data associated with the most recently triggered marker. See dxAddMarker.
The following variables are only available when the file loaded into the media player contains tag information. Media formats that contain tags readable by NeoDX are MP3, WMA and OGG. Tags are optional, so files in these formats may not contain some or all of these variables.
[PlayerID.Title] The title of the clip.
[PlayerID.Artist] The person or group that created the clip.
[PlayerID.Album] The album where the clip originated.
[PlayerID.Genre] The category the clip belongs to. For example: Rock, Country, Classical, etc.
[PlayerID.GenreNum] The category expressed as a number from 0 to 147.
[PlayerID.Year] The year the clip was created.
[PlayerID.Track] If the clip is from an album, this is the track number.
[PlayerID.Comment] Comments about the clip.
The following variables are only available when a WAVE format file is loaded into the media player:
[PlayerID.WaveFormat] Wave subformat (PCM, MPEG, etc.)
[PlayerID.Channels] Number of channels (Mono=1, Stereo=2).
[PlayerID.Bits] Resolution (8 or 16 bit).
[PlayerID.SampleRate] Audio sample rate in Hertz.
A millisecond is one thousandth of a second.