UNPKG

@flashport/flashport

Version:

FlashPort is a TypeScript 2D graphics library that largely replicates the Flash ActionScript 3.0 library

538 lines (537 loc) 18.3 kB
import { EventDispatcher } from "../events/EventDispatcher"; import { NetStreamInfo } from "./NetStreamInfo"; import { NetConnection } from "./NetConnection"; import { Microphone } from "../media/Microphone"; import { Camera } from "../media/Camera"; import { NetStreamPlayOptions } from "./NetStreamPlayOptions"; import { SoundTransform } from "../media/SoundTransform"; import { ByteArray } from "../utils/ByteArray"; import { VideoStreamSettings } from "../media/VideoStreamSettings"; import { NetStreamMulticastInfo } from "./NetStreamMulticastInfo"; /** * Dispatched when playing video content and certain type of messages are processed. * @eventType flash.events.NetDataEvent */ /** * Called synchronously from appendBytes() when the append bytes parser encounters a point that it believes is a seekable * point (for example, a video key frame). */ /** * Dispatched when the digital rights management (DRM) encrypted content * begins playing (when the user is authenticated and authorized to play the content). * @eventType flash.events.DRMStatusEvent.DRM_STATUS */ /** * Dispatched when a NetStream object, trying to play a digital rights management (DRM) encrypted * file, encounters a DRM-related error. * @eventType flash.events.DRMErrorEvent.DRM_ERROR */ /** * Dispatched when a NetStream object tries to play a digital rights management (DRM) encrypted * content that requires a user credential for authentication before playing. * @eventType flash.events.DRMAuthenticateEvent.DRM_AUTHENTICATE */ /** * Establishes a listener to respond when Flash Player receives image data as a byte array embedded in a media file that is * playing. */ /** * Establishes a listener to respond when Flash Player receives information specific to Adobe * Extensible Metadata Platform (XMP) embedded in the video being played. */ /** * Dispatched when a NetStream object is reporting its status or error condition. * @eventType flash.events.NetStatusEvent.NET_STATUS */ /** * Dispatched when an input or output error occurs that causes a network operation to fail. * @eventType flash.events.IOErrorEvent.IO_ERROR */ /** * Dispatched when an exception is thrown asynchronously — that is, * from native asynchronous code. * @eventType flash.events.AsyncErrorEvent.ASYNC_ERROR */ /** * Dispatched when the application attempts to play content encrypted with digital rights management (DRM), * by invoking the NetStream.play() method. * @eventType flash.events.StatusEvent.STATUS */ /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ export declare class NetStream extends EventDispatcher { /** * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ static CONNECT_TO_FMS: string; /** * Creates a peer-to-peer publisher connection. Pass this string for the second (optional) parameter to * the constructor for a NetStream instance. With this string, an application can create * a NetStream connection for the purposes of publishing audio and video to clients. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ static DIRECT_CONNECTIONS: string; private _netConnection; private _url; private _bytes; private _sourceBuffer; private _mimeCodec; private _mediaSource; private _duration; private _currentFPS; private _inBufferSeek; private _time; private _videoCodec; private _loop; private _looped; private _playing; private _paused; private _seeking; private _playbackTarget; private _clientObject; private _bytesQueue; private _isNewBytes; private _camera; get audioCodec(): number; /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get audioReliable(): boolean; set audioReliable(reliable: boolean); /** * For RTMFP connections, specifies whether peer-to-peer subscribers on this NetStream are allowed to capture the audio stream. * When FALSE, subscriber attempts to capture the audio stream show permission errors. * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get audioSampleAccess(): boolean; set audioSampleAccess(reliable: boolean); /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get backBufferLength(): number; /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get backBufferTime(): number; set backBufferTime(backBufferTime: number); /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ get bufferLength(): number; /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ get bufferTime(): number; set bufferTime(bufferTime: number); /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get bufferTimeMax(): number; set bufferTimeMax(bufferTimeMax: number); /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ get bytesLoaded(): number; /** * The total size in bytes of the file being loaded into the application. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ get bytesTotal(): number; /** * @langversion 3.0 * @playerversion Flash 9 */ get checkPolicyFile(): boolean; set checkPolicyFile(state: boolean); /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 * @throws TypeError The client property must be set to a non-null object. */ get client(): Object; set client(object: Object); /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ get currentFPS(): number; /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get dataReliable(): boolean; set dataReliable(reliable: boolean); get decodedFrames(): number; /** * For RTMFP connections, the identifier of the far end that is connected to this NetStream instance. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 */ get farID(): string; /** * For RTMFP and RTMPE connections, a value chosen substantially by the other end of this stream, unique to this connection. * This value appears to the other end of the stream as its nearNonce value. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 */ get farNonce(): string; /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get inBufferSeek(): boolean; set inBufferSeek(value: boolean); /** * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ get info(): NetStreamInfo; /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 * @category Property */ get liveDelay(): number; /** * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ get maxPauseBufferTime(): number; set maxPauseBufferTime(pauseBufferTime: number); /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get multicastAvailabilitySendToAll(): boolean; set multicastAvailabilitySendToAll(value: boolean); /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get multicastAvailabilityUpdatePeriod(): number; set multicastAvailabilityUpdatePeriod(seconds: number); /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get multicastFetchPeriod(): number; set multicastFetchPeriod(seconds: number); /** * For RTMFP connections, returns a NetStreamMulticastInfo object whose properties contain statistics about the quality of service. * The object is a snapshot of the current state. * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get multicastInfo(): NetStreamMulticastInfo; /** * For RTMFP connections, specifies the maximum number of peers to which to proactively push * multicast media. * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get multicastPushNeighborLimit(): number; set multicastPushNeighborLimit(neighbors: number); /** * For RTMFP connections, specifies the duration in seconds that peer-to-peer multicast data remains * available to send to peers that request it beyond a specified duration. The duration is specified * by the multicastWindowDuration property. * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get multicastRelayMarginDuration(): number; set multicastRelayMarginDuration(seconds: number); /** * For RTMFP connections, specifies the duration in seconds of the peer-to-peer multicast reassembly * window. Shorter values reduce latency but may reduce quality by not * allowing enough time to obtain all of the fragments. Conversely, larger values may increase * quality by providing more time to obtain all of the fragments, with a corresponding * increase in latency. * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get multicastWindowDuration(): number; set multicastWindowDuration(seconds: number); /** * For RTMFP and RTMPE connections, a value chosen substantially by this end of the stream, unique to this connection. * This value appears to the other end of the stream as its farNonce value. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ get nearNonce(): string; /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ get objectEncoding(): number; /** * An object that holds all of the subscribing NetStream instances that are listening to this publishing NetStream instance. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 */ get peerStreams(): any[]; /** * Controls sound in this NetStream object. For more information, see the SoundTransform class. * @langversion 3.0 * @playerversion Flash 9 */ get soundTransform(): SoundTransform; set soundTransform(sndTransform: SoundTransform); /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ get time(): number; get useHardwareDecoder(): boolean; set useHardwareDecoder(v: boolean); get useJitterBuffer(): boolean; set useJitterBuffer(value: boolean); get videoCodec(): number; /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get videoReliable(): boolean; set videoReliable(reliable: boolean); /** * For RTMFP connections, specifies whether peer-to-peer subscribers on this NetStream are allowed to capture the video stream. * When FALSE, subscriber attempts to capture the video stream show permission errors. * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ get videoSampleAccess(): boolean; set videoSampleAccess(reliable: boolean); get videoStreamSettings(): VideoStreamSettings; set videoStreamSettings(settings: VideoStreamSettings); /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ appendBytes: (bytes: ByteArray) => void; /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ appendBytesAction: (netStreamAppendBytesAction: string) => void; /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ attach: (connection: NetConnection) => void; /** * @param microphone The source of the audio stream to be transmitted. * @langversion 3.0 * @playerversion Flash 9 */ attachAudio: (microphone: Microphone) => void; /** * @param theCamera The source of the video transmission. Valid values are a Camera object * (which starts capturing video) and null. If you pass null, * the application stops capturing video, and any additional parameters you send are ignored. * @param snapshotMilliseconds Specifies whether the video stream is continuous, * a single frame, or a series of single frames used to create time-lapse photography. * @langversion 3.0 * @playerversion Flash 9 */ attachCamera: (theCamera: Camera, snapshotMilliseconds?: number) => void; /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ close: () => void; dispose: () => void; /** * Creates a stream that you can use to play media files and send data over a NetConnection object. * @param connection A NetConnection object. * @param peerID This optional parameter is available in Flash Player 10 and later, for use with RTMFP connections. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 * @throws ArgumentError The NetConnection instance is not connected. */ constructor(connection: NetConnection, peerID?: string); /** * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ onPeerConnect: (subscriber: NetStream) => boolean; /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ pause: () => void; /** * @param arguments Play a local file * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 * @throws SecurityError Local untrusted SWF files cannot communicate with * the Internet. You can work around this restriction by reclassifying this SWF file * as local-with-networking or trusted. * @throws ArgumentError At least one parameter must be specified. * @throws Error The NetStream Object is invalid. This may be due to a failed NetConnection. */ play: (...rest: any[]) => void; /** * Switches seamlessly between files with multiple bit rates and allows a NetStream to resume when a connection is dropped and reconnected. * @langversion 3.0 * @playerversion Flash 10 * @playerversion AIR 1.5 * @playerversion Lite 4 */ play2: (param: NetStreamPlayOptions) => void; /** * @param name A string that identifies the stream. Clients that subscribe to this stream pass * this name when they call NetStream.play(). Don't follow the stream name with a "/". For example, don't use * the stream name "bolero/". * @param type A string that specifies how to publish the stream. * @langversion 3.0 * @playerversion Flash 9 */ publish: (name?: string, type?: string) => void; /** * @param flag Specifies whether incoming audio plays on the stream (true) or not (false). The default value is true. * If the specified stream contains only audio data, NetStream.time stops incrementing when you pass false. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ receiveAudio: (flag: boolean) => void; /** * @param flag Specifies whether incoming video plays on this stream (true) or not (false). The default value is true. * If the specified stream contains only video data, NetStream.time stops incrementing when you pass false. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ receiveVideo: (flag: boolean) => void; /** * @param FPS Specifies the frame rate per second at which the incoming video plays. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ receiveVideoFPS: (FPS: number) => void; /** * @langversion 3.0 * @playerversion AIR 1.0 * @playerversion Lite 4 * @throws IOError The voucher data cannot be deleted. */ static resetDRMVouchers: () => void; /** * Resumes playback of a video stream that is paused. If the video is already playing, calling this method * does nothing. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ resume: () => void; /** * @param offset The approximate time value, in seconds, to move to in a video file. * @param fastSeek if true, seeking is faster, but less accurate. * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ seek: (offset: number) => void; /** * @langversion 3.0 * @playerversion Flash 9 */ send: (handlerName: string, ...rest: any[]) => void; /** * @langversion 3.0 * @playerversion Flash 10.1 * @playerversion AIR 2 */ step: (frames: number) => void; /** * @langversion 3.0 * @playerversion Flash 9 * @playerversion Lite 4 */ togglePause: () => void; /** * Path to local file for playback. */ get url(): string; /** * Object such as Video to set source for playback. */ set playbackTarget(value: Object); /** * The codec used in the supplied file. VideoCodec.H264AVC (.mp4) and VideoCodec.VP8 (.webm) accepted only. */ get mimeCodec(): string; set mimeCodec(value: string); /** * loops the playback continuously. not supported in flash player or AIR. */ get loop(): boolean; set loop(value: boolean); private netStatusEvents; private setupBuffer; private handleMediaSourceError; private handleSourceOpened; private handleUpdateEnd; private handleSeeked; private handleTime; }