Packageorg.openvideoplayer.net
Classpublic class OvpConnection
InheritanceOvpConnection Inheritance flash.events.EventDispatcher
Implements INetConnection
Subclasses AkamaiConnection

The OvpConnection class manages the complexity of establishing a robust NetConnection with a streaming service. The OvpConnection class works with on-demand FLV and H.264 MP4 (both streaming and progressive) and MP3 playback (streaming only), as well as live FLV streams.



Public Properties
 PropertyDefined By
  actualPort : String
[read-only] The port on which the class has connected.
OvpConnection
  actualProtocol : String
[read-only] The protocol over which the class has connected.
OvpConnection
  appNameInstanceName : String
[read-only] The last appName/instanceName used by the class.
OvpConnection
  attemptInterval : uint
The connection attempt interval when trying multiple ports and protocols.
OvpConnection
  cacheable : Boolean
True if connections can be cached and re-used, false otherwise.
OvpConnection
  connected : Boolean
[read-only] Indicates whether the application is connected to a server through a persistent RTMP connection (true) or not (false).
OvpConnection
  connectedProxyType : String
[read-only] If a successful connection is made, indicates the method that was used to make it: a direct connection, the CONNECT method, or HTTP tunneling.
OvpConnection
  defaultObjectEncoding : uint
The default object encoding for NetConnection objects.
OvpConnection
  hostName : String
[read-only] The last hostName used by the class.
OvpConnection
  isProgressive : Boolean
[read-only] Informs whether the current connection is progressive or not.
OvpConnection
  netConnection : NetConnection
[read-only] Returns a reference to the active NetConnection object.
OvpConnection
  objectEncoding : uint
The object encoding for this NetConnection instance.
OvpConnection
  proxyType : String
A reference to the prototype object of a class or function object.
OvpConnection
  requestedPort : String
The port(s) over which the class may attempt to connect.
OvpConnection
  requestedProtocol : String
The protocol(s) over which the class was originally requested to connect via the requestedProtocol property.
OvpConnection
  timeout : Number
The server connection timeout in milliseconds.
OvpConnection
  uri : String
[read-only] The URI passed to the NetConnection.connect() method.
OvpConnection
  usingTLS : Boolean
[read-only] Indicates whether a secure connection was made using native Transport Layer Security (TLS) rather than HTTPS.
OvpConnection
Public Methods
 MethodDefined By
  
Constructor
OvpConnection
  
addHeader(operation:String, mustUnderstand:Boolean = false, param:Object = null):void
Adds a context header to the Action Message Format (AMF) packet structure.
OvpConnection
  
call(command:String, responder:Responder, ... arguments):void
Invokes a command or method on Flash Media Server or on an application server running Flash Remoting.
OvpConnection
  
close():void
Closes the connection that was opened locally or to the server and dispatches a netStatus event with a code property of NetConnection.Connect.Closed.
OvpConnection
  
connect(command:String, ... arguments):void
The connect method initiates a connection to either a streaming service or a progressive link to a HTTP server.
OvpConnection
  
detectBandwidth():Boolean
Initiates a new bandwidth measurement.
OvpConnection
  
reconnect():void
Attempts to establish a connection based on the arguments passed to the connect method.
OvpConnection
  
requestStreamLength(filename:String):Boolean
Initiates the server request to measure the stream length of a file.
OvpConnection
  
serverVersion(info:Object):String
Returns the server version if detectable.
OvpConnection
  
streamLengthAsTimeCode(value:Number):String
Returns the given stream length (duration) in timecode HH:MM:SS format.
OvpConnection
Events
 Event Summary Defined By
  See the INetConnection interface for information on this event.OvpConnection
  Dispatched when a bandwidth estimate is complete.OvpConnection
  Dispatched when an OVP error condition has occurred.OvpConnection
  See the INetConnection interface for information on this event.OvpConnection
  See the INetConnection interface for information on this event.OvpConnection
  See the INetConnection interface for information on this event.OvpConnection
  Dispatched when a stream length request is complete.OvpConnection
Property Detail
actualPortproperty
actualPort:String  [read-only]

The port on which the class has connected. This parameter will only be returned if the class has managed to successfully connect to the server. Possible port values are "1935", "443", and "80". This property differs from requestedPort since it returns the port that was actually used and not the port combination that was requested.

This property is not available with progressive playback.


Implementation
    public function get actualPort():String

See also

actualProtocolproperty 
actualProtocol:String  [read-only]

The protocol over which the class has connected. This parameter will only be returned if the class has managed to successfully connect to the server. Possible protocol values are "rtmp","rtmpt","rtmpe" or "rtmpte". This property will differ from requestedProtocol if the requestedProtocol value was "any", in which case this property will return the protocol that was actually used.

This property is not available with progressive playback.


Implementation
    public function get actualProtocol():String

See also

appNameInstanceNameproperty 
appNameInstanceName:String  [read-only]

The last appName/instanceName used by the class.


Implementation
    public function get appNameInstanceName():String
attemptIntervalproperty 
attemptInterval:uint

The connection attempt interval when trying multiple ports and protocols. If connection authentication parameters are set from a derived class instance, 150 milliseconds will be added to ensure the server has enough time to process the auth information.


Implementation
    public function get attemptInterval():uint
    public function set attemptInterval(value:uint):void
cacheableproperty 
cacheable:Boolean

True if connections can be cached and re-used, false otherwise.


Implementation
    public function get cacheable():Boolean
    public function set cacheable(value:Boolean):void
connectedproperty 
connected:Boolean  [read-only]

Indicates whether the application is connected to a server through a persistent RTMP connection (true) or not (false).


Implementation
    public function get connected():Boolean
connectedProxyTypeproperty 
connectedProxyType:String  [read-only]

If a successful connection is made, indicates the method that was used to make it: a direct connection, the CONNECT method, or HTTP tunneling.


Implementation
    public function get connectedProxyType():String
defaultObjectEncodingproperty 
defaultObjectEncoding:uint

The default object encoding for NetConnection objects.


Implementation
    public function get defaultObjectEncoding():uint
    public function set defaultObjectEncoding(value:uint):void
hostNameproperty 
hostName:String  [read-only]

The last hostName used by the class. If the hostName was sent in the connect method concatenated with the application name (for example connect("cpxxxx.edgefcs.net/myappalias")) then this method will only return "cpxxxx.edgefcs.net". Use the appNameInstanceName property to retrieve the application name.


Implementation
    public function get hostName():String

See also

isProgressiveproperty 
isProgressive:Boolean  [read-only]

Informs whether the current connection is progressive or not.


Implementation
    public function get isProgressive():Boolean

See also

netConnectionproperty 
netConnection:NetConnection  [read-only]

Returns a reference to the active NetConnection object. This property will only return a valid reference if the connection was successful.


Implementation
    public function get netConnection():NetConnection
objectEncodingproperty 
objectEncoding:uint

The object encoding for this NetConnection instance.


Implementation
    public function get objectEncoding():uint
    public function set objectEncoding(value:uint):void
proxyTypeproperty 
proxyType:String

A reference to the prototype object of a class or function object.


Implementation
    public function get proxyType():String
    public function set proxyType(value:String):void
requestedPortproperty 
requestedPort:String

The port(s) over which the class may attempt to connect. These combinations are specified as a single string of ports separated by a delimiter. Possible requested port values are "any", "1935", "443" and "80", or any combination of these values, separated by the ',' delimiter. "any" is a reserved word meaning that the class should attempt all of the ports which the target network supports. Valid examples include "1935,80", "443,80" etc. The order in which the ports are specified is the order in which the connection attempts are made. All the ports for the first protocol (as specified by requestedProtocol) are attempted, followed by all the ports for the second protocol etc. For example, if requestedPort was set to "1935,80" and requestedProtocol to "rtmpt,rtmpe", then the connection attempt sequence would be:

If requestedPort is set to "any" (the default), then the port order is set to "1935,443,80". If both requestedPort and requestedProtocol are set to "any" then the following optimized sequence is used:

This property is not available with progressive playback.

The default value is "any".


Implementation
    public function get requestedPort():String
    public function set requestedPort(value:String):void

See also

requestedProtocolproperty 
requestedProtocol:String

The protocol(s) over which the class was originally requested to connect via the requestedProtocol property. These combinations are specified as a single string of protocols separated by a delimiter. Possible requested protocol values are "any", "rtmp","rtmpt","rtmpe" or "rtmpte", or any combination of these values, separated by the ',' delimiter. "any" is a reserved word meaning that the class should attempt all of the protocols which the target network supports. Valid examples include "rtmpt,rtmp", "rtmpe,rtmpte" etc. The order in which the protocols are specified is the order in which the connection attempts are made. This property will differ from actualProtocol if the requestedProtocol value was "any", in which case actualProtocol will return the protocol that was actually used. The order in which the protocols are specified is the order in which the connection attempts are made. All the ports (as specified by requestedPort) for the first protocol are attempted, followed by all the ports for the second protocol etc. For example, if requestedPort was set to "1935,80" and requestedProtocol to "rtmpt,rtmpe", then the connection attempt sequence would be:

If requestedProtocol is set to "any" (the default), then the protocol order is set to "rtmp,rtmpt,rtmpe,rtmpte". If both requestedPort and requestedProtocol are set to "any" then the following optimized sequence is used:

This property is not available with progressive playback.

The default value is "any".


Implementation
    public function get requestedProtocol():String
    public function set requestedProtocol(value:String):void

See also

timeoutproperty 
timeout:Number

The server connection timeout in milliseconds. If a successful connection has not been established within this time period, an OvpEvent.TIMEOUT will be dispatched.


Implementation
    public function get timeout():Number
    public function set timeout(value:Number):void
uriproperty 
uri:String  [read-only]

The URI passed to the NetConnection.connect() method.


Implementation
    public function get uri():String
usingTLSproperty 
usingTLS:Boolean  [read-only]

Indicates whether a secure connection was made using native Transport Layer Security (TLS) rather than HTTPS.


Implementation
    public function get usingTLS():Boolean
Constructor Detail
OvpConnection()Constructor
public function OvpConnection()

Constructor

Method Detail
addHeader()method
public function addHeader(operation:String, mustUnderstand:Boolean = false, param:Object = null):void

Adds a context header to the Action Message Format (AMF) packet structure.

Parameters

operation:String
 
mustUnderstand:Boolean (default = false)
 
param:Object (default = null)

call()method 
public function call(command:String, responder:Responder, ... arguments):void

Invokes a command or method on Flash Media Server or on an application server running Flash Remoting.

Parameters

command:String
 
responder:Responder
 
... arguments

close()method 
public function close():void

Closes the connection that was opened locally or to the server and dispatches a netStatus event with a code property of NetConnection.Connect.Closed.

connect()method 
public function connect(command:String, ... arguments):void

The connect method initiates a connection to either a streaming service or a progressive link to a HTTP server. A progressive connection is requested by passing the null object, or the string "null". All other strings are treated as requests for a streaming connection.

Parameters

command:String — A string containing hostname/appname/instance
 
... arguments

detectBandwidth()method 
public function detectBandwidth():Boolean

Initiates a new bandwidth measurement. To recover the estimated bandwidth value, wait for the OvpEvent.BANDWIDTH event and then inspect the data.bandwidth property.

This method is not available with progressive playback. To estimate bandwidth with progressive connections, use the HTTPBandwidthEstimate class.

Returns
Boolean — true if the connection has been established, otherwise false.

See also

reconnect()method 
public function reconnect():void

Attempts to establish a connection based on the arguments passed to the connect method.

requestStreamLength()method 
public function requestStreamLength(filename:String):Boolean

Initiates the server request to measure the stream length of a file. Since this measurement is an asynchronous process, the stream length value can retrieved using the data property of the OvpEvent object, i.e., event.data.streamLength. Note the name of the file being measured is decoupled from the file being played, meaning you can request the length of one file while playing another.

Parameters

filename:String — The name of the streaming file for which length is to be requested.

Returns
Boolean — true if the connection has been established, otherwise false.

See also

serverVersion()method 
public function serverVersion(info:Object):String

Returns the server version if detectable.

Parameters

info:Object — An object that, upon return, will contain the major, minor, sub-minor and build information as integers for ease of making comparisons. If the server version is not available, these values will be zero.

Returns
String — the server version as a string "major, minor, sub-minor, build", i.e., "3,5,0,1234"
streamLengthAsTimeCode()method 
public function streamLengthAsTimeCode(value:Number):String

Returns the given stream length (duration) in timecode HH:MM:SS format.

Parameters

value:Number

Returns
String — the length as timecode HH:MM:SS
Event Detail
asyncError Event
Event Object Type: flash.events.AsyncErrorEvent.ASYNC_ERROR

See the INetConnection interface for information on this event.

See also

bandwidth Event  
Event Object Type: org.openvideoplayer.events.OpvEvent.BANDWIDTH

Dispatched when a bandwidth estimate is complete.

See also

error Event  
Event Object Type: org.openvideoplayer.events.OpvEvent.ERROR

Dispatched when an OVP error condition has occurred. The OvpEvent object contains a data property. The contents of the data property will contain the error number and a description.

See also

ioError Event  
Event Object Type: flash.events.IOErrorEvent.IO_ERROR

See the INetConnection interface for information on this event.

See also

netStatus Event  
Event Object Type: flash.events.NetStatusEvent.NET_STATUS

See the INetConnection interface for information on this event.

See also

securityError Event  
Event Object Type: flash.events.SecurityErrorEvent.SECURITY_ERROR

See the INetConnection interface for information on this event.

See also

streamlength Event  
Event Object Type: org.openvideoplayer.events.OpvEvent.STREAMLENGTH

Dispatched when a stream length request is complete.

See also