Checklist for when cycleVideo is not working in JavaScript Checklist for when cycleVideo is not working in JavaScript

Checklist for when cycleVideo is not working in JavaScript

Yukari Dumburs

Question

What should I check if cycleVideo isn't working in my JavaScript application?

Applies To

  • Vonage Video API
  • Browsers
  • JavaScript
  • JS SDK

Answer

  1. Start by checking for any error messages and ensure that camera permissions are granted correctly.
  2. Verify that your implementation is correct. Here's the developer's guide explains how to switch the publisher's camera: https://tokbox.com/developer/guides/audio-video/js/#switch_camera
  3. You can use this sample to test the basic camera-switching functionality: https://opentok.github.io/opentok-web-samples/Publish-Devices/. Try switching the video source to see if the camera you're having trouble with works.

If the sample works, the issue might be within your application's implementation.

Check if navigator.mediaDevices.getUserMedia() is being called in multiple places.
Calling getUserMedia multiple times creates new streams with each call, which can cause conflicts with device resources.

Make sure to call getUserMedia only when necessary.

Alternatively, you can use track.stop() to stop the tracks of an existing stream and free up resources that aren't needed.

Releasing unused resources helps reset device components like the camera and microphone, ensuring that cycleVideo function works properly.