Web SDK - RainwayStream

Home > rainway-sdk > RainwayStream

RainwayStream class

An incoming Rainway stream.

To ask a host for a stream, use RainwayPeer.requestStream(). You can also listen for unsolicited streams in RainwayConfig.onStreamAnnouncement. To clean up, call RainwayStream.leave().

For more info, see: https://docs.rainway.com/tutorial/streaming

Signature:

export declare class RainwayStream 

Properties

PropertyModifiersTypeDescription
containerHTMLDivElementA DOM node containing the stream. Attach this anywhere on your page to display this stream.
deadbooleanIndicates that this stream has ended, and the RainwayStream object should be discarded.
hostRainwayPeer
inputLevelInputLevelA bitmask indicating the level of interactive control available over the remote stream.
streamIdnumber

Methods

MethodModifiersDescription
disableGestures()Stop gesture processing of touch inputs on the stream container. (It is enabled by default.)A touch input will be simply translated into an absolute-coordinate click-and-drag mouse input.
disableVideoStatsOverlay()Disable the video statistics overlay.
enableGestures()Begin gesture processing of touch inputs on the stream container. This is on by default.- Swipe: move mouse without clicking. - Tap: left click. - Tap then swipe: left click and drag. - Long press: right click. - Two-finger vertical swipe: scroll mouse wheel.
enableVideoStatsOverlay()Enable the video statistics overlay.
leave()Stop consuming the stream. The container is cleared. This also sends a message to the remote end indicating that we are no longer interested in this stream, and it may stop streaming.
pause()Pause the stream. It will stop playing audio and freeze on the current picture until play is called again.
play()Resume playing the stream.
requestFullscreen(options)Ask the browser to fullscreen the Rainway container. The default behavior is to additionally lock the keyboard and mouse pointer, but this can be overridden by providing options.For example:
requestFullScreen();
requestFullScreen({ lockKeyboard: false, lockPointer: false });

|
| resumeAudio() | | Some browsers don't allow pages to play audio unless initiated by a user gesture.This function tries to resume stream audio. You may call it in response to a suitable user gesture (e.g. body onclick). There is automatically an onclick handler like this on the stream container element. |
| setOutgoingInputFilter(filter) | | Set a filter on inputs we send to this stream.This filter is called when this peer wants to send keyboard, mouse, gamepad, etc. input to a remote peer.Only inputs of types enabled by the stream's InputLevel make it into this filter.Returning true will send the input request to the remote peer. The remote peer may have a further filter on incoming inputs.Returning false will prevent the input request from being sent. This should not be used for security-sensitive filtering like Alt-Tab prevention; prefer an incomingInputFilter on the host.This outgoing filter is more useful for replacing certain keys with application logic. For example, to make the "Q" key send a Data Channel message instead:

myStream.setOutgoingInputFilter((input, heldKeys) => {
    if (input.type === "keyboard" && input.key === VirtualKey.Q) {
        // Block the input, but send a message instead.
        if (input.action === KeyboardAction.Down) {
            stream.host.send(makeCoolRequest());
        }
        return false;
    }

    // Pass everything else through unchanged.
    return true;
});

The default behavior is to pass through all inputs, equivalent to (input, heldKeys) => true. |
| setStreamFit(streamFit) | | Control how the stream container fits isolated apps.- IsolatedApps makes the stream fit only the bounding rectangle of all windows belonging to the isolated app. The stream picture might grow and shrink as this rectangle changes. This is the default setting.- FullDesktop makes the entire desktop always be streamed, even in the App Isolation capture mode. This might cause the stream container to have a large border of empty space around the isolated app.The change applies when the next video frame is rendered. |