Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
OpenTok.js getImgData() is not defined

Hi I am updating a project made with Laravel and uses OpenTok.js Code uses the latest version as official docs says

To use the new features available in the latest version, set the src attribute of the script tag to load the new library: <script src="https://static.opentok.com/v2/js/opentok.min.js"></script>

It used to work fine but now it fails on the following line: subscriber.getImgData(); and says it is undefined Any way I can fix that? Maybe older versions of OpenTok somewhere

Also, this is my code snippet:

var publisher = '';
var subscriber = '';
function startSession() {
  session = OT.initSession(apiKey, sessionId);

  // Subscribe to a newly created stream
  session.on('streamCreated', function(event) {
    subscriber = session.subscribe(event.stream, 'subscriber', {
        insertMode: 'append',
        width: '100%',
        height: '100%',
        preferredResolution: {
          width: 1280,
          height: 720
        },
        style: {buttonDisplayMode: 'off'}
    }, handleError);
  });

  // Create a publisher
  publisher = OT.initPublisher('publisher', {
    insertMode: 'append',
    width: '100%',
    height: '100%',
    resolution: '1280x720',
    mirror: false,
    style: {buttonDisplayMode: 'off'}
  }, handleError);

  // Connect to the session
  session.connect(token, function(error) {
    // If the connection is successful, initialize a publisher and publish to the session
    if (error) {
      handleError(error);
    } else {
      session.publish(publisher, handleError);
    }
  });

  $.ajax({
      url: '/video/' + video_id + '/start', 
      type: "POST",
      cache: false,
      dataType: 'json',
      data: {
        '_token': csrf_token,
      }
  }).done(
      function(data){
        
      }
  );

  $('#start-session-btn').hide();
  showSessionControls();

  activityWatcher();
}
 $('#take-photo').click(function() {
    var video = subscriber.getImgData();
    var blob = base64ToBlob(video);
    var formData = new FormData();

    formData.append('image', blob);
    formData.append("_token", csrf_token);

    $.ajax({
        url: '/video/' + video_id, 
        type: "POST",
        cache: false,
        contentType: false,
        processData: false,
        data: formData}).done(
            function(data){
                VideoScreenGallery.addImg(data.id, data.path);
            }
        );
    });

The error return on line: var video = subscriber.getImgData(); and this is the error itself:

Uncaught TypeError: subscriber.getImgData is not a function

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!