Twilio ios Video Call issue - ios

I have created a video call using Twilio JS 2.x Version. And using this in my both mobile app Android & iOS. On Android it is working perfectly.
But on iOS, there is an issue, when users reach the video call page, it's showing preview but as the user clicks on the Join Room button, then his/her video stops and just showing a black screen. But Audio option alone work's fine in ios APP.
Actual thing is we are converting web view in to Mobile sdk using React Native APP. But the twilio logic's has been written using Javascript. Can anyone help on this?
I am using the following logic:
$.ajax({
url: callInitiate + "?userSTAuthToken=" + token,
type: "POST",
data: {
callType: "video",
subType: "wb-video",
},
error: function () {},
success: function (data) {
identity = "user_" + userId;
roomName = meetingId;
videoToken = data.token;
console.log("Joining room '" + roomName + "'...");
if (previewTracks) {
connectOptions.tracks = previewTracks;
}
// Join the Room with the token from the server and the LocalParticipant's Tracks.
console.log("Test token : " + data.token);
Twilio.Video.connect(videoToken, connectOptions).then(
roomJoined,
function (error) {
console.log("Unable to connect to Room: " + error.name);
TV.Util.DialogIntimation(
"Notification",
"Unable to connect to Room " + error.name
);
logTwilioerror(10);
$("#maskDiv").hide();
}
);
},
});
function roomJoined(room) {
window.room = activeRoom = room;
console.log("Joined as '" + identity + "'");
addIcons();
logSessionDetails(videoToken, room.sid, room.localParticipant.sid, room.name);
// Attach LocalParticipant's Tracks, if not already attached.
var previewContainer = document.getElementById("local-media");
if (!previewContainer.querySelector("video")) {
attachTracks(getTracks(room.localParticipant), previewContainer);
}
// Attach the Tracks of the Room's Participants.
var remoteMediaContainer = document.getElementById("remote-media");
room.participants.forEach(function (participant) {
console.log("Already in Room: '" + participant.identity + "'");
participantConnected(participant, remoteMediaContainer);
});
// When a Participant joins the Room, log the event.
room.on("participantConnected", function (participant) {
console.log("Joining: '" + participant.identity + "'");
participantConnected(participant, remoteMediaContainer);
});
// When a Participant leaves the Room, detach its Tracks.
room.on("participantDisconnected", function (participant) {
console.log(
"RemoteParticipant '" + participant.identity + "' left the room"
);
detachParticipantTracks(participant);
removeName(participant);
});
// Once the LocalParticipant leaves the room, detach the Tracks of all Participants, including that of the LocalParticipant.
room.on("disconnected", function () {
console.log("Left---disconnected");
logVideoActivity(
"10841",
"Tutor side disconnected the video Successfully."
);
if (previewTracks) {
previewTracks.forEach(function (track) {
track.stop();
});
previewTracks = null;
}
detachParticipantTracks(room.localParticipant);
room.participants.forEach(detachParticipantTracks);
room.participants.forEach(removeName);
activeRoom = null;
});
}

Related

Muting local tracks on Twilio Video?

Following guides, I'm attempting to disable and enable localAudioTracks.
Within the roomJoined function, I have these two functions:
document.getElementById("audio-toggle-off").onclick = function() {
console.log("muting this users audio");
room.localParticipant.audioTracks.forEach(function(trackId, track) {
track.disable();
});
};
document.getElementById("audio-toggle-on").onclick = function() {
console.log("enabling this users audio");
room.localParticipant.audioTracks.forEach(function(trackId, track) {
track.enable();
});
};
But on clicking these, I get the error that:
VideoChat.js:241 Uncaught TypeError: track.enable is not a function
at VideoChat.js:241
at Map.forEach (<anonymous>)
at HTMLButtonElement.document.getElementById.onclick (VideoChat.js:240)
Any ideas? For reference, I'm including the full roomJoined function below:
function roomJoined(room) {
window.room = activeRoom = room;
log("Joined as '" + identity + "'");
if (hide) {
return;
}
// document.getElementById("button-join").style.display = "none";
// document.getElementById("button-leave").style.display = "inline";
// Attach LocalParticipant's Tracks, if not already attached.
var previewContainer = document.getElementById("local-media");
if (previewContainer && !previewContainer.querySelector("video")) {
attachParticipantTracks(room.localParticipant, previewContainer);
}
// Attach the Tracks of the Room's Participants.
room.participants.forEach(function(participant) {
log("Already in Room: '" + participant.identity + "'");
var previewContainer = document.getElementById("remote-media");
attachParticipantTracks(participant, previewContainer);
});
// When a Participant joins the Room, log the event.
room.on("participantConnected", function(participant) {
log("Joining: '" + participant.identity + "'");
});
// When a Participant adds a Track, attach it to the DOM.
room.on("trackAdded", function(track, participant) {
log(participant.identity + " added track: " + track.kind);
var previewContainer = document.getElementById("remote-media");
attachTracks([track], previewContainer);
});
// When a Participant removes a Track, detach it from the DOM.
room.on("trackRemoved", function(track, participant) {
log(participant.identity + " removed track: " + track.kind);
detachTracks([track]);
});
// When a Participant leaves the Room, detach its Tracks.
room.on("participantDisconnected", function(participant) {
log("Participant '" + participant.identity + "' left the room");
detachParticipantTracks(participant);
});
// Once the LocalParticipant leaves the room, detach the Tracks
// of all Participants, including that of the LocalParticipant.
room.on("disconnected", function() {
log("Left");
if (previewTracks) {
previewTracks.forEach(function(track) {
track.stop();
});
}
detachParticipantTracks(room.localParticipant);
room.participants.forEach(detachParticipantTracks);
activeRoom = null;
document.getElementById("button-join").style.display = "inline";
document.getElementById("button-leave").style.display = "none";
});
document.getElementById("audio-toggle-off").onclick = function() {
console.log("muting this users audio");
room.localParticipant.audioTracks.forEach(function(trackId, track) {
track.disable();
});
};
document.getElementById("audio-toggle-on").onclick = function() {
console.log("enabling this users audio");
room.localParticipant.audioTracks.forEach(function(trackId, track) {
track.enable();
});
};
}
So it looks like this was able to work:
document.getElementById("audio-toggle-off").onclick = function() {
room.localParticipant.audioTracks.forEach(function(
audioTrack,
key,
map
) {
console.log("muting this users audio");
audioTrack.disable();
});

Can't play local videos in IOS 9 with Phonegap app

I made an IOS 9 app using Phonegap 6.2.0. I need to play videos with no connection, so I download it using cordova FileTransfer plugin:
var uri = encodeURI(file.url);
var fileTransfer = new FileTransfer();
// var fileLocation = cordova.file.applicationStorageDirectory +
// '/Documents/' + file.folder + '/' + file.fileName;
var fileLocation = cordova.file.dataDirectory + file.fileName;
var deferred = $q.defer();
fileTransfer.headers = {
Connection: "close"
};
fileTransfer.download(uri, fileLocation, function(result) {
console.log("Fichero descargado: " + JSON.stringify(result));
deferred.resolve(result);
}, function(error) {
deferred.reject(error);
});
return deferred.promise;
I've tried different file locations to download it (https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-file/)
Then, I return the file path using resolveLocalFileSystemURL:
var deferred = $q.defer();
var nativePath = cordova.file.dataDirectory + nombreFichero + "." + extension;
resolveLocalFileSystemURL(nativePath, function(entry) {
//deferred.resolve(entry.nativeURL);
console.log("Fichero native: " + entry.toNativeURL());
console.log("Fichero fullPath: " + entry.fullPath);
console.log("Fichero toUrl: " + entry.toURL());
console.log("Fichero toInternalURL: " + entry.toInternalURL());
deferred.resolve(entry.toURL());
}, function(error) {
console.log("Error al leer el fichero: " + JSON.stringify(error));
deferred.reject(error);
});
return deferred.promise;
I've tried all file formats but none of them worked:
cdvfile://localhost/library-nosync/97a7d50f-05d1-4642-96e9-b0b26ea41897.mp4
file:///var/mobile/Containers/Data/Application/6CD24D7A-7A39-4AFE-A43B-788FCDFCEB5A/Library/NoCloud/a88d38b8-85e8-4b9b-b57e-a8eb2731eb0d.mp4
http://localhost/library-nosync/97a7d50f-05d1-4642-96e9-b0b26ea41897.mp4 and using port 12344
Some formats do nothing, some show the button play strikethrough...
In all answers I had read they recommend to use .toNativeUrl() but it doesn't work for me...
I also tried cordova-plugin-streaming-media (I can't post more links), but it does not work (no play video, no errors...)
Any idea?
Solved.
My code works good and play videos. The problem was in the URL to download the video, it gets a string with the url and not the video (therefore download and open file method didin't throw error)
Summarizing, toUrl() works.
Thanks #Gandhi for your replies.

How to upload powerpoint file to server phonegap?

Hello I Want to upload a powerpoint file using phonegap file transfer protocol to my local java server thru ios simulator, the location of the file on the phone is passed to the handleOpenURL function when the user selects to open a powerpoint with my app. The problem is that nothing is happening although im sure this method is executing??!! can anyone help please?
function handleOpenURL(url)
{
setTimeout(function() {
alert(url);
jQuery.get( "http://192.168.1.100:8080/PpServer/getnumberofslides" , function( data ) {
numberofslides=data;
alert( "Load was performed." + data );
});
fileURL = url;
function win(r) {
console.log("Code = " + r.responseCode);
console.log("Response = " + r.response);
console.log("Sent = " + r.bytesSent);
// processapplication();
}
function fail(error) {
alert("An error has occurred: Code = " + error.code);
console.log("upload error source " + error.source);
console.log("upload error target " + error.target);
}
var uri = encodeURI("http://192.168.1.100:8080/NewServerlet");
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1);
options.mimeType="multipart/form-data";
options.httpMethod="Post"
// options.params = {"file"};
var headers={'headerParam':'file'};
// options.headers = headers;
var ft = new FileTransfer();
ft.onprogress = function(progressEvent) {
if (progressEvent.lengthComputable) {
loadingStatus.setPercentage(progressEvent.loaded / progressEvent.total);
} else {
loadingStatus.increment();
}
};
ft.upload(fileURL, uri, win, fail, options);
}, 0);
//
}

Is there support to Capture Video with Sound in phonegap (cordova)?

Is there support to Capture Video with Sound in phonegap (cordova)?
I checked on my iPad a phonegap 3.1 app whit Video Capture and no sound recording with the video
appreciate help
Thanks
function uploadFile(mediaFile) {
var ft = new FileTransfer(),
path = mediaFile.fullPath,
name = mediaFile.name;
ft.upload(path,
"http://www/api/up_video",
function(result) {
cordova.logger.log('Upload success: ' + result.responseCode);
cordova.logger.log(result.bytesSent + ' bytes sent');
},
function(error) {
cordova.logger.log('Error uploading file ' + path + ': ' + error.code);
},
{ fileName: name });
}
// capture callback
var captureSuccess = function(mediaFiles) {
var i, path, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
path = mediaFiles[i].fullPath;
name = mediaFiles[i].name;
// do something interesting with the file
alert(name);
//alert(mediaFiles[i].size);
//alert(mediaFiles[i].type);
uploadFile(mediaFiles[i]);
}
};
// capture error callback
var captureError = function(error) {
navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
cordova.logger.log( error);
};
navigator.device.capture.captureVideo(captureSuccess, captureError, {duration:6});
Absolutely. Both video and sound can be captured using Phonegap's "Capture" API. See documentation here.
Edit based on comments:
You are never telling the device to capture audio. The capture of Video and Audio are different operations. You need to also call the navigator.device.capture.captureAudio function. See here.

Geo Location not works in BlackBerry

I have developed an application using phonegap to retrieve Geo Location.
function getLoc() {
navigator.geolocation.getCurrentPosition(onSuccess, onError, { enableHighAccuracy: true });
}
// onSuccess Geolocation
function onSuccess(position) {
var locInfo = new Object();
locInfo.Latitude = position.coords.latitude;
locInfo.Longitude = position.coords.longitude;
locInfo.Altitude = position.coords.altitude;
locInfo.Accuracy = position.coords.accuracy;
locInfo.AltitudeAccuracy = position.coords.altitudeAccuracy;
locInfo.Heading = position.coords.heading;
locInfo.Speed = position.coords.speed;
alert(locInfo.Latitude + " " + locInfo.Longitude);
}
// onError Callback receives a PositionError object
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
above code is working fine in Android, iPhone and BlackBerry Simulator, but not in BlackBerry device. I'm using BlackBerry Torch for testing.
what could be the issue. pls reply.
Thanks :)
Try to set timeout for getCurrentPosition.

Resources