Salve a tutti non ho nessuna esperienza con Ajax e chiedo a Voi esperti lumi.
Ho un problema, dovrei recuperare una variabile generata da uno script che esegue un collegamento audio/video, la variabile si chiama my-id e viene correttamente visualizzata in una div sul video.
Il mio problema è recuperarla ed inviarla in automatico attraverso email ad un utente, in modo che questo possa utilizzare l'ID generato e connettersi con audio e video con l'interlocutore.
Lo script è questo:
La variabile che si vede nel video viene visualizzata così:
Grazie a tutti per le indicazioni che verrete fornirmi.
Piero
Ho un problema, dovrei recuperare una variabile generata da uno script che esegue un collegamento audio/video, la variabile si chiama my-id e viene correttamente visualizzata in una div sul video.
Il mio problema è recuperarla ed inviarla in automatico attraverso email ad un utente, in modo che questo possa utilizzare l'ID generato e connettersi con audio e video con l'interlocutore.
Lo script è questo:
Codice:
<script>
// Compatibility shim
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
// PeerJS object
var peer = new Peer({ key: '60hwbr3c8vrnewmi', debug: 3, config: {'iceServers': [
{ url: 'stun:stun.l.google.com:19302' } // Pass in optional STUN and TURN server for maximum network compatibility
]}});
peer.on('open', function(){
$('#my-id').text(peer.id);
});
// Receiving a call
peer.on('call', function(call){
// Answer the call automatically (instead of prompting user) for demo purposes
call.answer(window.localStream);
step3(call);
});
peer.on('error', function(err){
alert(err.message);
// Return to step 2 if error occurs
step2();
});
// Click handlers setup
$(function(){
$('#make-call').click(function(){
// Initiate a call!
var call = peer.call($('#callto-id').val(), window.localStream);
step3(call);
});
$('#end-call').click(function(){
window.existingCall.close();
step2();
});
// Retry if getUserMedia fails
$('#step1-retry').click(function(){
$('#step1-error').hide();
step1();
});
// Get things started
step1();
});
function step1 () {
// Get audio/video stream
navigator.getUserMedia({audio: true, video: true}, function(stream){
// Set your video displays
$('#my-video').prop('src', URL.createObjectURL(stream));
window.localStream = stream;
step2();
}, function(){ $('#step1-error').show(); });
}
function step2 () {
$('#step1, #step3').hide();
$('#step2').show();
}
function step3 (call) {
// Hang up on an existing call if present
if (window.existingCall) {
window.existingCall.close();
}
// Wait for stream on the call, then set peer video display
call.on('stream', function(stream){
$('#their-video').prop('src', URL.createObjectURL(stream));
});
// UI stuff
window.existingCall = call;
$('#their-id').text(call.peer);
call.on('close', step2);
$('#step1, #step2').hide();
$('#step3').show();
}
</script>
La variabile che si vede nel video viene visualizzata così:
Codice:
<!-- Make calls to others -->
<div id="step2">
<p>Il tuo id: <span id="my-id">...</span></p>
Grazie a tutti per le indicazioni che verrete fornirmi.
Piero