[adoberuntime]Adobe Media Server 3.5.3, Flash Player 10.1[/adoberuntime]

About Smart Seek

Adobe Media Server 3.5.3 and Flash Player 10.1 work together to support smart seeking in VOD streams and in live streams that have a buffer. Smart seeking uses back and forward buffers to seek without requesting data from the server. You can step forward and backward a specified number of frames. (Standard seeking flushes buffered data and asks the server to send new data based on the seek time.) Smart seeking reduces server load and improves seeking performance. Use smart seeking to create:

  • Client-side DVR functionality. Seek a live stream within the client-side buffer instead of going to the server for delivery of new video.

  • Trick modes. Create players that step through frames, fast-forward, fast-rewind, and advance in slow-motion.

For an example of smart seek, see the Stream Reconnect and Smart Seek doc and example hosted by Adobe.

Note:

Smart seeking is not supported in peer-assisted networking applications or with progressive download.

Smart Seek ActionScript API

Note:

The Smart Seek ActionScript API is ActionScript 3.0. These APIs are not supported in ActionScript 2.0.

Flash Player maintains a back buffer and a forward buffer. The back buffer is a cache of data that has been displayed. The forward buffer is a cache of data that hasn’t been displayed. Smart seeking retrieves data from within these buffers.

To turn on Smart Seek set NetStream.inBufferSeek to true.

To control the buffers, use the following APIs:

  • NetStream.backBufferLength

    [read-only] The number of seconds of previously displayed data cached for rewinding and playback. This is the bufferLength property for the back buffer.

  • NetStream.backBufferTime

    Specifies how much previously displayed data is cached for rewinding and playback, in seconds. The default value is 30 on the desktop and 3 on mobile.

  • NetStream.bufferLength

    [read-only] The number of seconds of data currently in the buffer.

  • NetStream.bufferTime

    Specifies how long to buffer messages before starting to display the stream, in seconds. The default value is 0.1.

To seek and step within the buffers, use the following APIs:

  • NetStream.seek()

    Moves the playhead to the time specified in the call.

  • NetStream.step()

    Steps the playhead forward or back the specified number of frames, relative to the currently displayed frame.

To detect a smart seek, use the following events:

  • NetStatusEvent.info.description contains the string "client-inBufferSeek".

    Dispatched when a call to NetStream.seek() is successful.

  • NetStream.Step.Notify

    Dispatched when a call to NetStream.step() is successful.

For detailed information about these APIs, see the ActionScript 3.0 Language Reference.

Using the Smart Seek ActionScript API

Smart Seek is supported in Flash Player 10.1 and greater. Before running code, test for Flash Player version. For example, you could expose step back and forward buttons only to clients with Flash Player 10.1 and greater. The following code tests for Flash Player version and returns true for 10.1 and greater:

public var fp10_1:Boolean; 
public function onStart():void{ 
    debug("Flash Player Version: " + Capabilities.version); 
    fp10_1 = isFP10_1(); 
    debug("fp10.1: "+fp10_1); 
} 
public function isFP10_1():Boolean { 
    var va:Array = Capabilities.version.split(" ")[1].toString().split(","); 
    if(int(va[0]) > 10) { return true; } 
    if(int(va[0]) < 10) { return false; } 
    if(int(va[1]) > 1) { return true; } 
    if(int(va[1]) < 1) { return false; } 
    return true; 
}

The following code sets NetStream.inBufferSeek to true to turn on Smart Seek if the Flash Player version is greater than 10.1:

// Call this function when you catch NetConnection.Connect.Success 
public function createNetStream():void{ 
 
// Write code to create a NetStream object and a Video object... 
//... 
// Set the forward buffer, in seconds. 
ns.bufferTime = 10; 
try { 
    if(fp10_1) { 
// If Flash Player is greater than 10.1, turn on smart seeking 
// and set the size of the back buffer, in seconds. 
        ns.inBufferSeek = true; 
        ns.backBufferTime = 30; 
    } 
} catch(e:Error) {}

When Smart Seek is turned on, calls to NetStream.seek() use the buffer. (Standard seeking flushes the buffer and sends a request for data to the server.) The following function can seek forward or backward to a number specified in a text field called seekText:

public function seekHandler():void { 
    if(ns != null) { 
        ns.seek(Number(seekText.text));     
    } 
}

To create players that step through frames, fast-forward, fast-rewind, and advance in slow-motion, adjust the number you pass to the step() and seek() functions.

To create client-side DVR functionality, set the NetStream.backBufferTime and NetStream.bufferTime properties. These properties specify the amount of data Flash Player stores in the client-side buffer. For example, to allow users to rewind 30 minutes before live, set backBufferTime to 1800 (60 seconds x 30 minutes). The cache is stored in memory. Set the buffer properties to lower values if the content is intended for netbooks or mobile devices.

Testing for a Smart Seek

A Smart Seek is a call to NetStream.seek() or a call to NetStream.step() when NetStream.inBufferSeek is true.

When a call to NetStream.seek() is successful, the NetStatusEvent info.description property contains the string "client-inBufferSeek".

When a call to NetStream.step() is successful, the NetStatusEvent info.code property contains the string "NetStream.Step.Notify". If a step has not completed, another call to step may return without executing. Get the "NetStream.Step.Notify" for the previous call before you call step again.

The following code tests for a call to NetStream.seek() and a call to NetStream.step():private function netStatusHandler(event:NetStatusEvent):void { switch (event.info.code) { case "NetStream.Seek.Notify": var desc:String = new String(event.info.description); if(desc.indexOf("client-inBufferSeek") >= 0) trace("A smart seek occured"); else trace("A standard seek occured"); break; case "NetStream.Step.Notify": trace("Successful NetStream.step() call"); break; } }

Smart Seek requires the following:

private function netStatusHandler(event:NetStatusEvent):void { 
    switch (event.info.code) { 
        case "NetStream.Seek.Notify": 
            var desc:String = new String(event.info.description); 
            if(desc.indexOf("client-inBufferSeek") >= 0) 
                trace("A smart seek occured"); 
            else 
                trace("A standard seek occured"); 
            break; 
        case "NetStream.Step.Notify": 
            trace("Successful NetStream.step() call"); 
            break; 
    } 
}
  • NetStream.inBufferSeek = true

    The default value of inBufferSeek is false.

  • Adobe Media Server 3.5.3

  • Flash Player 10.1

  • ActionScript 3.0

  • The value of the buffers (backBufferLength and bufferLength) must be large enough to fulfill the seek request.

If any of the previous requirements are not met, Flash Player uses standard seeking but throws no compile-time or runtime errors.

Authorization plug-in events and properties

Use Authorization plug-in events and properties to log information about smart seeking and to block clients from sending Smart Seek commands to the server.

Server logging

The following events are written to the Adobe Media Server access.log:

Event

Category

Description

client-seek

stream

The seek position when the client calls NetStream.seek() and NetStream.inBufferSeek = true which sends a seekRaw command to the server.

The client sends a seekRaw command only for seeks inside the buffer. If a client seeks outside the buffer, the client sends a “seek” event.

start-transmit

stream

The server received a startTransmit command. This command asks the server to transmit more data because the buffer is running low.

stop-transmit

stream

The server received a stopTransmit command. This command asks the server to suspend transmission until the client sends a startTransmit event because there is enough data in the buffer.

Note:

If a user interface lets users step through frames, there could be thousands of calls to NetStream.step(). For performance reasons, the server does not write these calls to the log file. These calls do trigger a client-side "NetStream.Step.Notify" NetStatusEvent.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy