Skip to content
hanzhong.yan edited this page Oct 11, 2016 · 27 revisions

WikiAPI Reference

Everything in PhoneRTC is scoped under the phonertc namespace.

Core

# setVideoView(config)

Create or update the video view based on the config parameters. The config parameter is an object with the following properties:

  • container (DOMElement) - The DOM element of the container. Should be a square with fixed width and height.
  • local (object) - Represents the details of the local video view. Has 2 array properties: position and size. Each array has 2 number items that represents left or width and top or height respectively. Optional.

# hideVideoView()

Hide the video view.

# showVideoView()

Show the video view. Note that the video view is visible by default, you only need to call this method if you want to show the video after hiding it with hideVideoView.

Session

A session represents a connection between 2 users.

# Session(config)

Construct a new Session based on the config parameter. The config parameter is an object with the following properties:

  • isInitiator (boolean) - Determines whether or not this session sends the WebRTC offer.
  • turn (object) - Represents the details of the TURN server. Has 3 string properties: host, username and password.
  • streams (object) - Represents which tracks will be sent. Has 2 boolean properties: audio, video.

# Session.on(eventName, fn)

Attach an event handler function for one or more events to the session. The available events are:

  • sendMessage - When PhoneRTC wants to send a message to the peer
  • answer - When the connection has successfully established
  • disconnect - When one side ends the session

# Session.off(eventName, fn)

Remove an event handler.

# Session.receiveMessage(data)

Handle a message that was sent by the session peer. data must be an object.

# Session.call()

Initialize a call by starting the PhoneRTC handshaking process.

Note that this should be called on the client with config.isInitiator = false before the client with config.isInitiator = true.

# Session.renegotiate()

Remove and add the Media Stream. This method is useful when updating the session streams. For example:

// Mute
session.streams.audio = false;
session.renegotiate();

Note: This method is not supported in the browser platform.

# Session.close()

Close the session. The disconnect event will be called.

Clone this wiki locally