我想通过我的JSP页面进行视频通话。我有JSP页面的代码。网络摄像头指示灯点亮,但是在JSP页面上没有捕获显示。
我从网上复制了源代码。我找不到该代码的问题。以前该代码可以正常显示,用于显示视频通话,但现在不行。
var my_number;
var number;
var video_out;
var img_out;
var img_self;
var phone;
var chat_in;
var chat_out;
function doLogin(){
//alert("login camera");
$("#videoDiv").show();
alert("login camera");
$("#PrescriptionDiv").show();
$("#my-number").html($("#doctorUsername").val());
alert("login camera"+$("#doctorUsername").val());
// Generate Random Number if Needed
my_number = PUBNUB.$('my-number');
number = $("#doctorUsername").val();
my_number.number = number;
my_number.innerHTML = ''+my_number.number;
// Calling & Answering Service
video_out = PUBNUB.$('video-display');
img_out = PUBNUB.$('video-thumbnail');
img_self = PUBNUB.$('video-self');
phone = window.phone = PHONE({
number : my_number.number, // listen on this line
publish_key : 'pub-c-561a7378-fa06-4c50-a331-5c0056d0163c',
subscribe_key : 'sub-c-17b7db8a-3915-11e4-9868-02ee2ddab7fe',
ssl : true
});
// Ready to Send or Receive Calls
phone.ready(function(){
// Ready To Call
set_icon('facetime-video');
// Hanup Call
PUBNUB.bind( 'mousedown,touchstart', PUBNUB.$('hangup'), function()
{
phone.hangup();
alert("Hang up");
set_icon('facetime-video');
$("#doctorsDiv span").removeClass("doctor-active-
checked").hide();
$("#selectedDoctorUsername").val("");
// $("#chatDiv").hide();
$("#videoDiv").hide();
} );
});
// Receiver for Calls
phone.receive(function(session){
alert("recever for session doctor");
session.message(message);
alert("Patient calling...");
session.thumbnail(thumbnail);
alert("recever for doctor session thumbnail");
session.connected(connected);
//alert("recever for doctor session connected");
// session.messagepresc(messagepresc);
// alert("recever for doctor session messagepresc");
session.ended(ended);
});
// Chat
chat_in = PUBNUB.$('pubnub-chat-input');
//alert("chat_in doctor"+chat_in);
chat_out = PUBNUB.$('pubnub-chat-output');
//alert("chat_out doctor"+chat_out);
var chat_in1 = PUBNUB.$('pubnub-chat-input1');
//alert("chat_in1 doctor"+chat_in1);
var chat_out1 = PUBNUB.$('pubnub-chat-output1');
//alert("chat_out1 doctor"+chat_out1);
// Send Chat MSG and update UI for Sending Messages
PUBNUB.bind( 'keydown', chat_in, function(e) {
alert(" Doctor PUBNUB.bind UI for Sending Messages");
if ((e.keyCode || e.charCode) !== 13) return true;
if (!chat_in.value.replace( /\s+/g, '' )) return true;
// alert("Doctor PUBNUB.bind1 UI for Sending Messages");
phone.send({ text : chat_in.value });
// alert("Doctor PUBNUB.bind2 UI for Sending Messages");
add_chat( my_number.number + " (Me)", chat_in.value );
// alert("Doctor PUBNUB.bind3 UI for Sending Messages");
chat_in.value = '';
} );
// Send Chat MSG and update UI for Sending Messages for prescription
PUBNUB.bind( 'keydown', chat_in1, function(e) {
// alert("Doctor PUBNUB bind Send Chat MSG and update UI for
Sending Messages for prescription");
if ((e.keyCode || e.charCode) !== 13) return true;
if (!chat_in1.value.replace( /\s+/g, '' )) return true;
// alert("Doctor PUBNUB bind Send Chat MSG and update UI for Sending
Messages for prescription1");
phone.send({ text : chat_in1.value });
// alert("Doctor PUBNUB bind Send Chat MSG and update UI for Sending
Messages for prescription2");
add_chatPres ( chat_in1.value );
// alert("Doctor PUBNUB bind Send Chat MSG and update UI for Sending
Messages for prescription3");
chat_in1.value = '';
} );
// Update Local GUI for prescription
function add_chatPres( textpresc ) {
//alert("Doctor PUBNUB bind Update Local GUI for prescription");
if (!textpresc.replace( /\s+/g, '' )) return true;
// alert("Doctor PUBNUB bind Update Local GUI for prescription1");
var newchatpresc = document.createElement('div');
// alert("Doctor PUBNUB bind Update Local GUI for prescription2");
newchatpresc.innerHTML = PUBNUB.supplant(
'</strong> {message}', {
message : safetxt(textpresc),
// number : safetxt(number)
} );
// alert("Doctor PUBNUB bind Update Local GUI for prescription3");
chat_out1.insertBefore( newchatpresc, chat_out1.firstChild );
// alert("Doctor chat_out1 Update Local GUI for prescription");
}
// Problem Occured During Init
phone.unable(function(details){
console.log("Alert! - Reload Page.");
console.log(details);
set_icon('remove');
});
// Debug Output
phone.debug(function(details){
//alert("debug output doctor");
//console.log(details);
}); }
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Video Session Connected
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
function connected(session) {
video_out.innerHTML = '';
video_out.appendChild(session.video);
PUBNUB.$('selectedDoctorUsername').value = ''+session.number;
// alert("PUBNUB.$('selectedDoctorUsername
doclive').value"+$('selectedDoctorUsername').value);
sounds.play('sound/hi');
console.log("Hi!");
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Video Session Ended
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
function ended(session) {
set_icon('facetime-video');
img_out.innerHTML = '';
sounds.play('sound/goodbye');
console.log("Bye!");
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Video Session Ended
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
function set_icon(icon) {
video_out.innerHTML = '<span class="glyphicon glyphicon-' +
icon + '"></span>';
}