Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda