Skip to content

Af2NetStream.attachVideo

Petro O. Bochan edited this page Sep 2, 2023 · 5 revisions

Usage
myStream.attachVideo(source)

Parameters
source - The source of the video transmission. Valid values are a Af2Camera object (which starts capturing video) and null.

Description
Method; starts capturing video from the specified source, or stops capturing if source is undefined. This method is available only to the publisher of the specified stream. After attaching the video source, you must call Af2NetStream.publish to actually begin transmitting. Subscribers who want to display the video must call the Af2NetStream.play and Af2NetStream.getRenderer methods to display the video.

Example
The following function publishes a stream containing the camera output.

private void pubLive() {
  // Create a new source stream.
  srcStream = new Af2NetStream(this, connection);
  // Attach the camera activity to the source stream. This
  // call causes a warning message to show which service is
  // requesting access. It also gives the user the option of
  // not sending the camera activity to the server.
  srcStream.attachVideo(myCam);
  // Get the stream name from the user input.
  mySubj = subject;
  // Assuming the user named the stream ’webCamStream’,
  // publish the live camera activity as 'webCamStream'.
  srcStream.publish(mySubj);
}

See also
Af2Camera (object), Af2Camera.setMode, Af2NetStream.publish, Af2NetStream.getRenderer

Clone this wiki locally