ActionScript® 3.0 Reference for the Adobe® Flash® Platform
Home  |  Show Packages and Classes List |  Packages  |  Classes  |  What's New  |  Index  |  Appendixes
org.osmf.net 

NetLoader  - AS3 OSMF

Packageorg.osmf.net
Classpublic class NetLoader
InheritanceNetLoader Inheritance LoaderBase Inheritance EventDispatcher Inheritance Object
Subclasses HTTPStreamingNetLoader, MulticastNetLoader, RTMPDynamicStreamingNetLoader

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

The NetLoader class extends LoaderBase to provide loading support to the AudioElement and VideoElement classes.

Supports both streaming and progressive media resources. If the resource URL is RTMP, connects to an RTMP server by invoking a NetConnectionFactoryBase. NetConnections may be shared between LoadTrait instances. If the resource URL is HTTP, performs a connect(null) for progressive downloads.

The NetLoader supports Flash Media Token Authentication, for passing authentication tokens through the NetConnection.

View the examples



Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  reconnectTimeout : Number
The stream reconnect timeout in milliseconds.
NetLoader
Public Methods
 MethodDefined By
  
Constructor.
NetLoader
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
 Inherited
Indicates whether this loader is capable of handling (loading) the given MediaResourceBase.
LoaderBase
 Inherited
Dispatches an event into the event flow.
EventDispatcher
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Loads the specified LoadTrait.
LoaderBase
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Unloads the specified LoadTrait.
LoaderBase
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Protected Methods
 MethodDefined By
  
The factory function for creating a NetStream.
NetLoader
  
The factory function for creating a NetStreamSwitchManagerBase.
NetLoader
 Inherited
Executes the load of the given LoadTrait.
LoaderBase
 Inherited
Executes the unload of the given LoadTrait.
LoaderBase
  
reconnect(netConnection:NetConnection, resource:URLResource):void
Attempts to reconnect the specified NetConnection to the specified URL.
NetLoader
 Inherited
Updates the given LoadTrait with the given info, and dispatches the state change event if necessary.
LoaderBase
Events
 Event Summary Defined By
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
 Inherited[broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
 InheritedDispatched when the state of a LoadTrait being loaded or unloaded by the LoaderBase has changed.LoaderBase
Property Detail

reconnectTimeout

property
reconnectTimeout:Number

The stream reconnect timeout in milliseconds.

The NetLoader will give up trying to reconnect the stream if a successful reconnect does not occur within this time period. The default is 120 seconds. For unpaused streams, the timeout period begins when the buffer empties and therefore a value of zero seconds is valid, meaning after the buffer empties, don't try to reconnect. For paused streams, the timeout period begins immediately.



Implementation
    public function get reconnectTimeout():Number
    public function set reconnectTimeout(value:Number):void

Throws
ArgumentError — If value param is less than zero.
Constructor Detail

NetLoader

()Constructor
public function NetLoader(factory:NetConnectionFactoryBase = null)

Language Version: ActionScript 3.0
Product Version: OSMF 1.0
Runtime Versions: Flash Player 10, AIR 1.5

Constructor.

Parameters
factory:NetConnectionFactoryBase (default = null) — The NetConnectionFactoryBase instance to use for managing NetConnections. If factory is null, a NetConnectionFactory will be created and used. Since the NetConnectionFactory class facilitates connection sharing, this is an easy way of enabling global sharing, by creating a single NetConnectionFactory instance within the player and then handing it to all NetLoader instances.
Method Detail

createNetStream

()method
protected function createNetStream(connection:NetConnection, resource:URLResource):NetStream

The factory function for creating a NetStream.

Parameters

connection:NetConnection — The NetConnection to associate with the new NetStream.
 
resource:URLResource — The resource whose content will be played in the NetStream.

Returns
NetStream — A new NetStream associated with the NetConnection.

createNetStreamSwitchManager

()method 
protected function createNetStreamSwitchManager(connection:NetConnection, netStream:NetStream, dsResource:DynamicStreamingResource):NetStreamSwitchManagerBase

The factory function for creating a NetStreamSwitchManagerBase.

Parameters

connection:NetConnection — The NetConnection that's associated with the NetStreamSwitchManagerBase.
 
netStream:NetStream — The NetStream upon which the NetStreamSwitchManagerBase will operate.
 
dsResource:DynamicStreamingResource — The resource upon which the NetStreamSwitchManagerBase will operate.

Returns
NetStreamSwitchManagerBase — The NetStreamSwitchManagerBase for the NetStream, null if multi-bitrate switching is not enabled for the NetStream.

reconnect

()method 
protected function reconnect(netConnection:NetConnection, resource:URLResource):void

Attempts to reconnect the specified NetConnection to the specified URL.

Clients can override this method to provide custom NetConnection behavior when using the stream reconnect feature. For example, if you wanted to provide client-side load balancing in your player, you could create a custom NetLoader class and override this method to use an alternate URI.

Parameters

netConnection:NetConnection — The new NetConnection created by the stream reconnect logic.
 
resource:URLResource — The URLResource that was originally used to play the media.
NetLoaderExample.as

package
{
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    
    import org.osmf.elements.VideoElement;
    import org.osmf.media.MediaPlayerSprite;
    import org.osmf.media.URLResource;
    import org.osmf.net.NetLoader;
    
    public class NetLoaderExample extends Sprite
    {
        public function NetLoaderExample()
        {
            super();
            
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            
            var mediaPlayerSprite:MediaPlayerSprite = new MediaPlayerSprite();
            var netLoader:NetLoader = new NetLoader();
            var urlResource:URLResource = new URLResource("rtmp://cp67126.edgefcs.net/ondemand/mediapm/strobe/content/test/SpaceAloneHD_sounas_640_500_short");
            var videoElement:VideoElement = new VideoElement(urlResource, netLoader);
            
            addChild(mediaPlayerSprite);
            mediaPlayerSprite.media = videoElement;    
        }    
    }
}