ADOBE
®
ACTIONSCRIPT
®
3.0
Dynamic Stream API
Copyright
© 2009 Adobe Systems Incorporated. All rights reserved.
Adobe® ActionScript® 3.0 Dynamic Stream API
If this guide is distributed with software that includes an end user agreement, this guide, as well as the software described in it, is furnished under license and
may be used or copied only in accordance with the terms of such license. Except as permitted by any such license, no part of this guide may be reproduced, stored
in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, recording, or otherwise, without the prior written permission of Adobe
Systems Incorporated. Please note that the content in this guide is protected under copyright law even if it is not distributed with software that includes an end
user license agreement.
The content of this guide is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by Adobe
Systems Incorporated. Adobe Systems Incorporated assumes no responsibility or liability for any errors or inaccuracies that may appear in the informational
content contained in this guide.
Please remember that existing artwork or images that you may want to include in your project may be protected under copyright law. The unauthorized
incorporation of such material into your new work could be a violation of the rights of the copyright owner. Please be sure to obtain any permission required
from the copyright owner.
Any references to company names in sample templates are for demonstration purposes only and are not intended to refer to any actual organization.
Adobe, the Adobe logo, Adobe AIR, ActionScript, Flash, and Flex are either registered trademarks or trademarks of Adobe Systems Incorporated in the United
States and/or other countries. All other trademarks are the property of their respective owners.
This work is licensed under the Creative Commons Attribution Non-Commercial 3.0 License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc/3.0/us/
This product includes software developed by the Apache Software Foundation (http://www.apache.org/).
MPEG Layer-3 audio compression technology licensed by Fraunhofer IIS and Thomson Multimedia (http://www.mp3licensing.com).
Speech compression and decompression technology licensed from Nellymoser, Inc. (www.nellymoser.com).
Video compression and decompression is powered by On2 TrueMotion video technology. © 1992-2005 On2 Technologies, Inc. All Rights Reserved.
http://www.on2.com.
This product includes software developed by the OpenSymphony Group (http://www.opensymphony.com/).
This product contains either BSAFE and/or TIPEM software by RSA Security, Inc.
Sorenson Spark™ video compression and decompression technology licensed from Sorenson Media, Inc.
Adobe Systems Incorporated, 345 Park Avenue, San Jose, California 95110, USA.
Notice to U.S. Government End Users. The Software and Documentation are “Commercial Items,” as that term is defined at 48 C.F.R. §2.101, consisting of
“Commercial Computer Software” and “Commercial Computer Software Documentation,” as such terms are used in 48 C.F.R. §12.212 or 48 C.F.R. §227.7202,
as applicable. Consistent with 48 C.F.R. §12.212 or 48 C.F.R. §§227.7202-1 through 227.7202-4, as applicable, the Commercial Computer Software and
Commercial Computer Software Documentation are being licensed to U.S. Government end users (a) only as Commercial Items and (b) with only those rights
as are granted to all other end users pursuant to the terms and conditions herein. Unpublished-rights reserved under the copyright laws of the United States.
Adobe Systems Incorporated, 345 Park Avenue, San Jose, CA 95110-2704, USA. For U.S. Government End Users, Adobe agrees to comply with all applicable
equal opportunity laws including, if appropriate, the provisions of Executive Order 11246, as amended, Section 402 of the Vietnam Era Veterans Readjustment
Assistance Act of 1974 (38 USC 4212), and Section 503 of the Rehabilitation Act of 1973, as amended, and the regulations at 41 CFR Parts 60-1 through 60-60,
60-250, and 60-741. The affirmative action clause and regulations contained in the preceding sentence shall be incorporated by reference.
iii
Contents
Adobe ActionScript 3.0 Dynamic Stream API
DynamicStream class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
DynamicStreamItem class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1
Adobe ActionScript 3.0 Dynamic Stream
API
The Dynamic Stream API includes two classes: DynamicStream and DynamicStreamItem. Use these classes to develop
applications that switch between media streams encoded at different bit rates when network conditions change.
Adobe® Flash® Media Server switches between streams seamlessly. Dynamic streaming provides a continuous playback
experience for all viewers, regardless of their computing power or internet connection speed.
You can develop dynamic streaming applications in Adobe Flash and Adobe Flex™ for the Adobe Flash Player 10 and
Adobe AIR™ 1.5 runtimes. Dynamic streaming applications require any edition of Adobe Flash Media Server 3.5.
For more information on dynamic streaming, see the following articles:
• “Understanding the Adobe ActionScript 3.0 Dynamic Stream API” at
www.adobe.com/go/fms_dynstream_advanced
• “Encoding Best Practices for Dynamic Streaming” at www.adobe.com/go/fms_dynstream_bestpractices
• “Dynamic Streaming” in the Adobe Flash Media Server 3.5 Developer Guide at
www.adobe.com/go/learn_fms_dynstream_en
DynamicStream class
Class public class DynamicStream
Inheritance DynamicStream -> NetStream -> EventDispatcher -> Object
Language version ActionScript 3.0
Runtime versions AIR 1.5, Flash Player 10
Server version Flash Media Server 3.5
Use the DynamicStream class to manage a set of content streams. The typical use case is to switch between streams
encoded at different bit rates when network conditions change. Dynamic stream switching provides clients the best
viewing experience seamlessly.
The DynamicStream class inherits from the NetStream class. It adds a startPlay() method that you use to pass in an
array of streams encoded at different bit rates. The class contains algorithms that use the Quality of Service data
available in Flash Player 10 to determine when to switch streams.
To use dynamic streaming with live streams, set the DynamicStreamItem.start property to -1. To use dynamic
streaming with recorded (vod) streams, use the default value of
-2 or a value greater than or equal to 0.
Workflow
Use the following workflow to add dynamic streaming to an existing application. The workflow assumes that the
application has a class file that contains NetConnection code for connecting to Flash Media Server. It also assumes that
you have several streams of the same content encoded at various bit rates.
1 Place the DynamicStream.as and DynamicStreamItem.as class files in the same directory as your application class
file.
2
DYNAMIC STREAM API
Adobe ActionScript 3.0 Dynamic Stream API
2 In your application class file, create a DynamicStream object and pass it the NetConnection object for this
connection:
var ds:DynamicStream = new DynamicStream(nc);
3 Create a DynamicStreamItem object:
var dsi:DynamicStreamItem = new DynamicStreamItem();
4 Call the addStream() method to add streams encoded at various bit rates to the DynamicStreamItem object:
dsi.addStream("mp4:test_800k.mov", 800);
dsi.addStream("mp4:test_1000k.mov", 1000);
dsi.addStream("mp4:test_2000k.mov", 2000);
5 Call the startPlay() method and pass it the DynamicStreamItem object:
ds.startPlay(dsi);
The complete code sample is as follows:
var ds:DynamicStream = new DynamicStream(nc);
var dsi:DynamicStreamItem = new DynamicStreamItem();
// add a new stream/bitrate pair
dsi.addStream("mp4:test_800k.mov", 800);
dsi.addStream("mp4:test_1000k.mov", 1000);
dsi.addStream("mp4:test_2000k.mov", 2000);
// start playing
ds.startPlay(dsi);
DynamicStream()
public function DynamicStream(nc:NetConnection)
Runtime versions AIR 1.5, Flash Player 10
Server version Flash Media Server 3.5
Constructor function. Creates a stream that you can use to switch between media files encoded at various bit rates.
Parameters
nc:NetConnection The NetConnection object for this connection.
Example
var ns:NetConnection = new NetConnection();
nc.connect("rtmp://fmsexamples.adobe.com/sampleapp");
var ds:DynamicStream = new DynamicStream(nc);
aggressiveModeBufferLength
aggressiveModeBufferLength:Number [read/write]
Runtime versions AIR 1.5, Flash Player 10
Server version Flash Media Server 3.5
The lowest acceptable buffer length, in seconds. The default value is 4.
- 1
- 2
前往页