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