Player APIs (BrightScript & Ja...
...
Object Reference
Presentation and Widget Object...

roAudioPlayer

27min
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 ifmessageport setport(port as romessageport) as void posts messages of type roaudioevent to the attached message port ifuserdata setuserdata(user data as object) sets the user data that will be returned when events are raised getuserdata() as object returns the user data that has previously been set via setuserdata() it will return invalid if no data has been set ifidentity getidentity() as integer the ifidentity interface has been deprecated we recommend using the ifuserdata interface instead ifmediatransport see rovideoplayer docid\ ztuz0ldazcml2kqmdbkcn for a description of ifmediatransport methods ifaudiocontrol setpcmaudiooutputs(outputs as dynamic) as boolean specifies which audio connectors should output pcm audio this method accepts an roaudiooutput instance or an array of roaudiooutput instances setcompressedaudiooutputs(outputs as dynamic) as boolean 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() setmultichannelaudiooutputs(array as object) as boolean setaudiomode(audio mode as integer) as boolean 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 setvolume(volume as dynamic) as boolean 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 setchannelvolumes(channel mask as integer, volume as integer) as boolean 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 setpreferredaudio(description as string) as boolean selects which audio track to use if there are multiple audio tracks in the stream see rovideoplayer docid\ ztuz0ldazcml2kqmdbkcn for more details configureaudioresources() as boolean setaudiodelay(delay in milliseconds as integer) as boolean 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 setvideodelay(delay in milliseconds as integer) as boolean 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 storeencryptionkey(a as string, b as string) as boolean storeobfuscatedencryptionkey(a as string, b as string) as boolean deprecated methods setaudiooutput(audio output as integer) as boolean mapstereooutput(mapping as integer) as boolean mapdigitaloutput(mapping as integer) as boolean setstereomappingspan(a as integer) as boolean setaudiostream(stream index as integer) as boolean setspdifmute(a as boolean) as boolean setusbaudioport(a as integer) as boolean setaudiooutputaux(audio output as integer) as boolean setaudiomodeaux(audio mode as integer) as boolean mapstereooutputaux(mapping as integer) as boolean setvolumeaux(volume as integer) as boolean setchannelvolumesaux(channel mask as integer, volume as integer) as boolean setaudiostreamaux(stream index as integer) as boolean configuring audio outputs 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) 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% playing multiple audio files simultaneously 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")