Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

Class: OpenTok::Broadcasts

Inherits:
Object
Defined in:
lib/opentok/broadcasts.rb

Overview

A class for working with OpenTok live streaming broadcasts. See / Live streaming broadcasts.

Instance Method Summary

Instance Method Details

#create(session_id, options = {}) ⇒ Broadcast

Starts a live streaming broadcast of an OpenTok session.

Clients must be actively connected to the OpenTok session for you to successfully start a broadcast.

This broadcasts the session to an HLS (HTTP live streaming) or to RTMP streams.

Parameters:

  • session_id (String)

    The session ID of the OpenTok session to broadcast.

  • options (Hash) (defaults to: {})

    A hash defining options for the broadcast.

Options Hash (options):

  • :layout (Hash)

    Specify this to assign the initial layout for the broadcast. Valid values for the layout (:type) property are “bestFit” (best fit), “custom” (custom), “horizontalPresentation” (horizontal presentation), “pip” (picture-in-picture), and “verticalPresentation” (vertical presentation)). If you specify a (:custom) layout type, set the (:stylesheet) property of the layout object to the stylesheet. (For other layout types, do not set a stylesheet property.) If you do not specify an initial layout type, the broadcast stream uses the Best Fit layout type.

  • maxDuration (int)

    The maximum duration for the broadcast, in seconds. The broadcast will automatically stop when the maximum duration is reached. You can set the maximum duration to a value from 60 (60 seconds) to 36000 (10 hours). The default maximum duration is 4 hours (14,400 seconds).

  • outputs (Hash)

    This object defines the types of broadcast streams you want to start (both HLS and RTMP). You can include HLS, RTMP, or both as broadcast streams. If you include RTMP streaming, you can specify up to five target RTMP streams (or just one). The (:hls) property is set to an empty [Hash] object. The HLS URL is returned in the response. The (:rtmp) property is set to an [Array] of Rtmp [Hash] properties. For each RTMP , specify (:serverUrl) for the RTMP server URL, (:streamName) such as the YouTube Live stream name or the Facebook stream key), and (optionally) (:id), a unique ID for the stream.

  • resolution (string)

    The resolution of the broadcast: either “640x480” (SD, the default) or “1280x720” (HD).

Returns:

  • (Broadcast)

    The broadcast object, which includes properties defining the broadcast, including the broadcast ID.

Raises:

#find(broadcast_id) ⇒ Broadcast

Gets a Broadcast object for the given broadcast ID.

Parameters:

  • broadcast_id (String)

    The broadcast ID.

Returns:

  • (Broadcast)

    The broadcast object, which includes properties defining the broadcast.

Raises:

#layout(broadcast_id, options = {}) ⇒ Object

Dynamically alters the layout an OpenTok broadcast. For more information, see For more information, see Configuring video layout for OpenTok live streaming broadcasts.

Parameters:

  • broadcast_id (String)

    The broadcast ID.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :type (String)

    The layout type. Set this to “bestFit”, “pip”, “verticalPresentation”, “horizontalPresentation”, “focus”, or “custom”.

  • :stylesheet (String)

    The stylesheet for a custom layout. Set this parameter if you set type to "custom". Otherwise, leave it undefined.

Raises:

  • (OpenTokBroadcastError)

    The broadcast layout could not be updated.

  • (OpenTokAuthenticationError)

    Authentication failed. Invalid API key or secret.

  • (OpenTokError)

    OpenTok server error.

  • (ArgumentError)

    The broadcast_id or options parameter is empty.

  • (ArgumentError)

    The “custom” type was specified without a stylesheet option.

  • (ArgumentError)

    A stylesheet was passed in for a type other than custom. Or an invalid type was passed in.

  • (ArgumentError)

    An invalid layout type was passed in.

#stop(broadcast_id) ⇒ Broadcast

Stops an OpenTok broadcast

Note that broadcasts automatically stop after 120 minute

Parameters:

  • broadcast_id (String)

    The broadcast ID.

Returns:

  • (Broadcast)

    The broadcast object, which includes properties defining the broadcast.

Raises: