2020 API AWARDS WINNER - BEST IN MEDIA APIs LEARN MORE

Presenting

Follow these instructions to share a screen, file, or a video.

Share screen

Check how to share a screen with other conference participants.

Start sharing screen

Use the startScreenShare command associated with the ConferenceService to start sharing the screen:

  • JavaScript
  • Swift
  • Java

VoxeetSDK.conference
  .startScreenShare()
  .then(() => {})
  .catch(e => {})

Then, the StreamAdded event is automatically sent to other participants. Check the stream.type inside it to see if the type of the associated associated stream is the ScreenShare.

VoxeetSDK.conference.on("streamAdded", (participant, stream) => {
  if (stream.type == "ScreenShare") {
    /* The ScreenShare stream has been added. */
  }
})

Use the startScreenShare with broadcast parameter to specify if you want to use screen share inside (false), or outside (true) app.
An article has been created to help you setting up screen share outside app.

if #available(iOS 11.0, *) {
    VoxeetSDK.shared.conference.startScreenShare(broadcast: broadcast) { error in }
}

Then, the StreamAdded event is automatically sent to other participants. Check the stream.type inside it to see if the type of the associated associated stream is the ScreenShare.

extension YourClass: VTConferenceDelegate {
    func streamAdded(participant: VTParticipant, stream: MediaStream) {
        switch stream.type {
        case .Camera: break
        case .ScreenShare: break
        default: break
    }
}

Note: This functionality is only available on Android 5.0 and later versions.

Send a request to receive the ScreenShare permission.

VoxeetSDK.screenShare().sendRequestStartScreenShare()

Then, the RequestScreenSharePermissionEvent event is emitted.

Call the sendUserPermissionRequest(@NonNull Activity activity).

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(@NonNull RequestScreenSharePermissionEvent event) {
        VoxeetSDK.screenShare().sendUserPermissionRequest(currentActivity);
        //in the context of the current activity: currentActivity = this
    }

The permission results from the system are forwarded to the ScreenShareService.

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        boolean managed = false;

        if (null != VoxeetSDK.screenShare()) {
            managed = VoxeetSDK.screenShare().onActivityResult(requestCode, resultCode, data);
        }

        if (!managed) {
            super.onActivityResult(requestCode, resultCode, data);
        }
    }

Consume the ScreenShare Bundle using the consumeRightsToScreenShare:

    @Override
    protected void onResume() {
        super.onResume();

        if (null != VoxeetSDK.screenShare()) {
            VoxeetSDK.screenShare().consumeRightsToScreenShare();
        }
    }

After these steps, the system emits the StreamAddedEvent event.

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEvent(@NonNull StreamAddedEvent event) {
        /* Event related to any MediaStream, check whether its type is the MediaStreamType.ScreenShare. */
    }

Stop sharing screen

Use the stopScreenShare command associated with the ConferenceService to stop sharing the screen:

  • JavaScript
  • Swift
  • Java

VoxeetSDK.conference.stopScreenShare()

Then, the streamRemoved event is automatically sent to other participants. Check the stream.type inside it to see if the type of the associated stream is the ScreenShare.

VoxeetSDK.conference.on("streamRemoved", (participant, stream) => {
  if (stream.type == "ScreenShare") {
    /* The ScreenShare stream has been removed. */
  }
})

if #available(iOS 11.0, *) {
    VoxeetSDK.shared.conference.stopScreenShare(completion: { error in })
}

Then, the streamRemoved event is automatically sent to other participants. Check the stream.type inside it to see if the type of the associated stream is the ScreenShare.

extension YourClass: VTConferenceDelegate {
    func streamRemoved(participant: VTParticipant, stream: MediaStream) {
        switch stream.type {
        case .Camera: break
        case .ScreenShare: break
        default: break
    }
}

Promise<Boolean> promise = VoxeetSDK.screenShare().stopScreenShare();

Then, the VideoPresentationStopped event is sent to the conference participants. Check the stream.type inside it to see if the type of the associated stream is the ScreenShare.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(@NonNull VideoPresentationStopped event) {
    MediaStream mediaStream = event.mediaStream;
    MediaStreamType type = mediaStream.type;
}

File Presentation

Check how to share a file with other conference participants.

Convert the file

Before the file presentation, convert a file into multiple images to use them during the conference.

Use the convertFile command to upload and convert the file before the presentation:

  • JavaScript
  • Swift
  • Java

voxeet.convertFile(...)

Then, the system emits the conversionProgress and the converted events:

VoxeetSDK.filePresentation.on(
  "conversionProgress",
  (e: FileConversionProgress) => {
    /* The file conversion is in progress.  */
  }
)

VoxeetSDK.filePresentation.on("converted", (e: FilePresentation) => {
  /* The file has been converted. */
})

VoxeetSDK.shared.filePresentation.convert(path: filePath, progress: { progress in
}, success: { response in
}, fail: { error in
})

Promise<FilePresentation> promise = VoxeetSDK.filePresentation().convertFile(File file);

After the conversion, the FilePresentationConverted event is emitted.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(@NonNull FilePresentationConverted event) {
  /* Emitted when the file is converted. */
}

Start file presentation

Use the start method with the previously received FilePresentation object to start presenting the file:

  • JavaScript
  • Swift
  • Java

VoxeetSDK.filePresentation.start((file: FilePresentation))

VoxeetSDK.shared.filePresentation.start(file: FilePresentation, completion: { error in  })

Promise<FilePresentation> promise = VoxeetSDK.filePresentation().start(@NonNull FilePresentationConverted filePresentation);

Update file presentation

The application coordinates the page flip between the local and presented file. Call the update method to send the updated page number to the conference participants. Include in it your current position inside the file (for example 3 in case of sharing the third page of the file).

  • JavaScript
  • Swift
  • Java

VoxeetSDK.filePresentation.update((file: FilePresentation), (position: number))

Then, the updated event is sent to all participants. The getImage method allows getting the URL of the image that corresponds to the current file position.

VoxeetSDK.filePresentation.on("updated", (e: FilePresentation) => {
  /* The shared page of the presented file has been changed. */
  VoxeetSDK.filePresentation.getImage(e.fileId, e.position).then(image => {
    /* The URL of the current file page is ready and can be shared. */
  })
})

VoxeetSDK.shared.filePresentation.update(file: FilePresentation, page: Int, completion: { error in })

Promise<FilePresentation> promise = VoxeetSDK.filePresentation().update(@NonNull String fileId, int position);

Then, the FilePresentationUpdated event is sent to the conference participants. The getImage method allows getting the URL of the image that corresponds to the current file position.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(@NonNull FilePresentationUpdated event) {
  /* Emitted when the shared page of the presented file has been changed. */
  String imageUrl = VoxeetSDK.filePresentation().getImage(event.fileId, event.position);
}

Stop file presentation

Use the stop method related to the FilePresentationService to stop presenting the file:

  • JavaScript
  • Swift
  • Java

VoxeetSDK.filePresentation.stop((file: FilePresentation))

Then, the stopped event is sent to all participants.

VoxeetSDK.filePresentation.on("stopped", (e: FilePresentation) => {
  /* The file presentation has been stopped. */
})

VoxeetSDK.shared.filePresentation.stop(completion: { error in })

Promise<FilePresentation> promise = VoxeetSDK.filePresentation().stop(@NonNull String fileId);

Then, the FilePresentationStopped event is sent to the conference participants.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(@NonNull FilePresentationStopped event) {
  /* The file presentation has been stopped. */
}

Video Presentation

Check how to share a video with other conference participants.

Start a video presentation

Use the start command including the URL of the video to start sharing the video file:

  • JavaScript
  • Swift
  • Java

VoxeetSDK.videoPresentation.start((url: string))

Then, the started event is sent to all participants.

VoxeetSDK.filePresentation.on("started", (e: FilePresentation) => {
  /* The video presentation has started. */
})

VoxeetSDK.shared.videoPresentation.start(url: URL, completion: { error in })

Promise<VideoPresentation> promise = VoxeetSDK.videoPresentation().start(@NonNull String url);

Then, the VideoPresentationStarted event is sent to the conference participants.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(@NonNull VideoPresentationStarted event) {
  /* The video presentation has started. */
}

Pause video presentation

Use the pause command to pause the video presentation:

  • JavaScript
  • Swift
  • Java

VoxeetSDK.videoPresentation.pause((timestamp: number))

Then, the paused event is sent to the conference participants.

VoxeetSDK.videoPresentation.on("paused", (e: VideoPresentation) => {
  /* The video presentation has been paused. */
})

VoxeetSDK.shared.videoPresentation.pause(completion: { error in })

Promise<VideoPresentation> promise = VoxeetSDK.videoPresentation().pause(long timestamp);

Then, the VideoPresentationPaused event is sent to the conference participants.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(@NonNull VideoPresentationPaused event) {
  /* The video presentation has been paused. */
}

Play video presentation

Use the play command to play or resume the video:

  • JavaScript
  • Swift
  • Java

VoxeetSDK.videoPresentation.play()

Then, the played event is sent to the conference participants.

VoxeetSDK.videoPresentation.on("played", (e: VideoPresentation) => {
  /* The video presentation has been resumed. */
})

VoxeetSDK.shared.videoPresentation.play(completion: { error in })

Promise<VideoPresentation> promise = VoxeetSDK.videoPresentation().play();

Then, the VideoPresentationPlayed event is sent to the conference participants.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(@NonNull VideoPresentationPlayed event) {
  /* The video presentation has been resumed. */
}

Seek position

While sharing the video with other conference participants, the application coordinates the timestamp related to the local and the presented video file. Use the seek method to inform other participants about the current video position.

  • JavaScript
  • Swift
  • Java

VoxeetSDK.videoPresentation.seek((timestamp: number))

Then, the sought event is sent to all participants.

VoxeetSDK.videoPresentation.on("sought", (e: VideoPresentation) => {
  /* Informs about the timestamp of the current position. */
})

VoxeetSDK.shared.videoPresentation.seek(time: Int, completion: { error in })

Promise<VideoPresentation> promise = VoxeetSDK.videoPresentation().seek(long timestamp);

Then, the VideoPresentationSought event is sent to the conference participants.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(@NonNull VideoPresentationSought event) {
  /* Informs about the timestamp of the current position. */
}

Stop video presentation

Use the stop method from the FilePresentationService to stop a video presentation.

  • JavaScript
  • Swift
  • Java

VoxeetSDK.videoPresentation.stop()

Then, the stopped event is sent to all participants.

VoxeetSDK.videoPresentation.on("stopped", () => {
  /* The video presentation has been stopped. */
})

VoxeetSDK.shared.videoPresentation.stop(completion: { error in })

Promise < VideoPresentation > promise = VoxeetSDK.videoPresentation().stop()

Then, the VideoPresentationStopped event is sent to the conference participants.

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(@NonNull VideoPresentationStopped event) {
  /* The video presentation has been stopped. */
}