Skip to content
This repository has been archived by the owner on May 18, 2022. It is now read-only.

Latest commit

 

History

History
99 lines (71 loc) · 2.92 KB

subscriber.md

File metadata and controls

99 lines (71 loc) · 2.92 KB

Subscriber

A Subscriber object is used to stream audio and video from a Stream in an OpenTok Session to this device. A Subscriber is constructed by calling Session.subscribe(stream, props). The Subscriber only represents the control of streaming that data, not the UI. In order to present a view of this data, use a VideoView which can be constructed using the createView(props) method of a Subscriber.

Methods Properties Events
[createView(_props_)](#createviewprops) [stream](#stream) ["subscriberStarted"](#subscriberstarted)
[close()](#close) [subscribeToAudio](#subscribetoaudio) ["subscriberConnected"](#subscriberconnected)
[subscribeToVideo](#subscribetovideo) ["subscriberFailed"](#subscriberfailed)
[session](#session)
[view](#view)

Methods

createView(props)

A Subscriber can subscribe to data without being displayed in the UI. In order to display the video of the subscriber, you must create a view from it. This method creates that view. It is a subtype of Titanium.UI.View.

Parameters:

  • props (Dictionary) optional - Properties to be set on the view when it is created. You can set any properties you would on any instance of Titanium.UI.View

Returns: (VideoView)

close()

Disconnects the Subscriber from the Session. The Subscriber's view will now be invalid and should be removed from the UI.

Properties

stream

(Stream) The Stream that this Subscriber is created from. Read Only

subscribeToAudio

(Boolean) Whether or not the Subscriber is subscribing to audio data in the Stream. Read Only

subscribeToVideo

(Boolean) Whether or not the Subscriber is subscribing to video data in the Stream. Read Only

session

(Session) The Session that this Subscriber is streaming data from. Read Only

view

(VideoView) If createView(props) has been called on this Subscriber, this property will return a reference to that same VideoView. Otherwise it returns null.

Events

"subscriberStarted"

This event is fired when the first frame of video or audio data has been recieved and decoded.

"subscriberConnected"

This event is fired when the Subscriber sucessfully connects to the Stream.

"subscriberFailed"

This event is fired when an error is encountered.

Event Properties:

  • error (Dictionary):
  • message (String) - The reason for the Subscriber failing.