An audio player is used to play back audio files using the generic ifMediaTransport interface. If the message port is set, the object will send events of the type roAudioEvent. All object calls are asynchronous. In other words, audio playback is handled in a different thread from the script. The script may continue to run while audio is playing. The JavaScript equivalent is to use the HTML audio tag.
Posts messages of type roAudioEvent to the attached message port.
Sets the user data that will be returned when events are raised.
Returns the user data that has previously been set via SetUserData(). It will return Invalid if no data has been set.
The ifIdentity interface has been deprecated. We recommend using the ifUserData interface instead.
The ifIdentity interface has been deprecated. We recommend using the ifUserData interface instead.
See roVideoPlayer for a description of ifMediaTransport methods.
Specifies which audio connectors should output PCM audio. This method accepts an roAudioOutput instance or an array of roAudioOutput instances.
Specifies which audio connectors should output compressed audio (e.g. Dolby AC3 encoded audio). This method accepts an roAudioOutput instance or an array of roAudioOutput instances.
When the SetPcmAudioOutputs()
or SetCompressedAudioOutputs()
method is called, it will override the settings of the following ifAudioControl methods: SetAudioOutput(), MapStereoOutput(), SetUsbAudioPort(), MapDigitalOutput()
.
When the SetPcmAudioOutputs()
or SetCompressedAudioOutputs()
method is called, it will override the settings of the following ifAudioControl methods: SetAudioOutput(), MapStereoOutput(), SetUsbAudioPort(), MapDigitalOutput()
.
Sets the audio mode of the roAudioPlayer object. This method accepts the following values:
0
: AC3 Surround
1
: AC3 mixed down to stereo
2
: No audio
3
: Left
4
: Right
Options 0 and 1 only apply to video files, while options 2, 3, and 4 apply to all audio sources.
Specifies the volume of the audio output as either a percentage or decibel amount. To use a percentage measurement, pass an integer value between 0 and 100. To use a decibel measurement, pass an roAssociativeArray containing a single {db:<value As Float>
} parameter. The decibel measurement is an absolute value: passing 0 specifies no change to the audio output, and the effective range of measurements is from approximately -80 to 20 decibels.
The volume value is clipped prior to use (i.e. SetVoume(101)
will set the volume to 100 and return True). The volume is the same for all mapped outputs and USB/SPDIF/analog.
Separate volume levels are stored for roAudioPlayer and roVideoPlayer.
Separate volume levels are stored for roAudioPlayer and roVideoPlayer.
You can control the volume of individual audio channels. This volume command takes a hex channel mask, which determines the channels to apply the volume to, and a level, which is a percentage of the full scale. The volume control works according to audio channel rather than the output. The channel mask is a bit mask with the following bits for MP3 output:
&H01
: Left
&H02
: Right
&H03
: Both left and right
Selects which audio track to use if there are multiple audio tracks in the stream. See the Preferred Streams section on the roVideoPlayer page for more details.
Adds a presentation time stamp (PTS) offset to the audio. This makes it possible to adjust for file multiplexing differences. Delays are limited to 150ms or less. Currently, the system software only supports positive delays; therefore, if you need to set the audio ahead of the video, you will need to use SetVideoDelay()
instead.
Adds a presentation time stamp (PTS) offset to the video. This makes it possible to adjust for file multiplexing differences. Delays are limited to 150ms or less.
If a audio/video file is playing or has played, you need to call Stop()
before changing the audio output.
The following script shows how to use the SetPcmAudioOutputs()
and SetCompressedAudioOutputs()
methods in conjunction with roAudioOutput. The audio/video player is configured to output decoded audio to the analog output or compressed audio to the HDMI® and SPDIF outputs.
ao1=CreateObject("roAudioOutput", "Analog") ao2=CreateObject("roAudioOutput", "HDMI") ao3=CreateObject("roAudioOutput", "SPDIF") a1=CreateObject("roAudioPlayer") a1.SetPcmAudioOutputs(ao1) ar = CreateObject("roArray", 2, true) ar[0] = ao2 ar[1] = ao3 a1.SetCompressedAudioOutputs(ar) |
Important In most cases, rerouting audio outputs during audio/video playback will cause playback to stop. The system software will still be responsive, so you can use commands to exit playback during or after an audio output modification. |
This script sets audio output to the third analog audio port:
analog3 = CreateObject("roAudioOutput", "analog:3") video = CreateObject("roVideoPlayer") video.SetPcmAudioOutputs(analog3) |
This script configures multiple outputs for an audio player:
analogOut = CreateObject("roAudioOutput", "analog") hdmiOut = CreateObject("roAudioOutput", "hdmi") audio = CreateObject("roAudioPlayer") audio.SetPcmAudioOutputs([analogOut, hdmiOut]) |
This script sets the volume level for individual channels:
audio = CreateObject("roAudioPlayer") audio.SetChannelVolumes(&H01, 60) 'left channel to 60% audio.SetChannelVolumes(&H02, 75) 'right channel to 75% audio.SetChannelVolumes(&H03, 65) 'all channels to 65% |
Multiple MP3 files, as well as the audio track of a video file, can be played to any combination of the following:
Analog outputs
SPDIF / HDMI
USB
Only a single file can be sent to an output at any given time. For example, two roAudioPlayers cannot simultaneously play to the SPDIF output. The second one to attempt a PlayFile will get an error. To free an output, the audio or video stream must be stopped (using the ifMediaTransport Stop
or StopClear
calls).
Note the following about multiple audio-file functionality:
The onboard analog audio output and HDMI output are clocked by the same sample-rate clock. Therefore, if different content is being played out of each, the content must have the same sample rate.
Currently, only a single set of USB speakers is supported.
Each audio and video stream played consumes some of the finite CPU resources. The amount consumed depends on the bitrates of the streams. Testing is the only way to determine whether a given set of audio files can be played at the same time as a video. The maximum recommended usage is a 16Mbps video file with three simultaneous MP3 160kbps streams.
This script plays a video with audio over HDMI and an MP3 file to the onboard analog port:
hdmiOut = CreateObject("roAudioOutput", "hdmi") analogOut = CreateObject("roAudioOutput", "analog") video = CreateObject("roVideoPlayer") video.SetPcmAudioOutputs(hdmiOut) audio = CreateObject("roAudioPlayer") audio.SetPcmAudioOutputs(analogOut) video.PlayFile("video.mpg") audio.PlayFile("audio.mp3") |
ON THIS PAGE |