Scaleform adds functionality to the NetStream class, which allows manipulation with subtitles and additional audio tracks that are embedded into a video file.
onMetaData event handler
onMetaData = function(info:Object) { }
Scaleform version: 3.0.63
The event handler receives information on the video file being played and includes two additional object properties in Scaleform. These properties are used to retrieve information about subtitle and audio tracks encoded into a video file.
The object that is passed to onMetaData event handler has two additional read-only properties.
audioTracks – Array of objects describing audio tracks encoded into the video file Each object in audioTracks array has the following properties:
channelsNumber – Number of channels in the audio track .(1–mono, 2–stereo, 6–5.1 surround sound)
totalSamples – Number of sound samples in this track.
trackIndex – Track index number. This property is used to select an audio track by assigning it to NetStream.audioTrack property (see the example below).
sampleRate – Sound sample rate.
subtitleTracksNumber – Number of subtitle tracks available in the video file.
audioTrack property
audioTrack:Number [read-write]
Scaleform version: 3.0.63
This property is used to set/get the currently playing audio track encoded into a video file.
Example:
var ns:NetStream = new NetStream(nc); var audioTracks; ns.onMetaData = function(info:Object) { audioTracks = info.audioTracks; } if (audioTracks != undefined && audioTracks.length > 0) ns.audioTrack = audioTracks[0].trackIndex;
subtitleTrack property
subtitleTrack:Number [read-write]
Scaleform version: 3.0.63
The property allows the setting and retrieving of the current subtitle track. To turn off the subtitle set this property to 0.
onSubtitle event handler
onSubtitle = function(msg:String) {}
Scaleform version: 3.0.63
This event handler is called when a subtitle message is ready to be shown.
Example:
var ns:NetStream = new NetStream(nc); var subtitlesNumber = 0; ns.onMetaData = function(info:Object) { subtitlesNumber = info. subtitleTracksNumber; } ns.onSubtitle = function(msg:String) { sbTextField.text = msg; } if (subtitlesNumber > 0) ns.subtitleTrack = 1;
setNumberOfFramePools function
public function setNumberOfFramePools(pools : Number) : Void
Scaleform version: 3.0.68
This function sets the number of internal video buffers. Video buffers are used to save video decoding output and are called “frame pools”. When the CPU load of decoding is unstable, having many frame pools helps smooth out playback. The default value is 1.
This method should be called before a video starts playing (i.e., before a NetStream.play() call).
setReloadThresholdTime function
public function setReloadThresholdTime(reloadTime : Number) : Void
Scaleform version: 3.0.68
This function sets the reload timing in seconds. The Scaleform video library submits a next file read request when the data size in the input buffer is less than the reload threshold. This threshold time is automatically determined according to the bitrate of the video file and the reloading time set. The default value of reload timing is 0.8 (seconds).
While reading game data during video playback, the number of seeking requests can be reduced by using this method. For example, when you set the Netstream buffer time (NetStream.setBufferTime() method) to 2 seconds and set the threshold time to 1 second, the game data can be read continuously for about 1 second. But the reading of game data should be completed until/before the reload timing occurs. When the game data is large, it may have to be read by chunks. And if the game data reading is not completed before the reload timing, the movie playback will “stutter,” as the video data buffer is empty.
This method should be called before a video starts playing (i.e., before a NetStream.play() call).