I'm writing an asp.net site in VB, and am trying to integrate in webcam functionality via javascript. I'm using webcam.js (found here: https://github.com/jhuckaby/webcamjs). When I created a new project for testing this out and working out the kinks, it worked fine. However, when I attempted to integrate it into my main project, the video does not load and I'm left with a blank screen. I can confirm that it does work in the side project in IE, firefox, and chrome, yet works in none of them after integrating it in my main project. The integration process was not complicated, it was mainly just copy and paste and adding the requisite references. I at first was getting problems of it not recognizing 'Webcam' but that went away after I coded in the exact location of the webcam.js file (I understand that this will be a problem later, but I'm more worried about getting it working in debug mode for now so it's fine). My code is as follows:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebcamPart.aspx.vb" Inherits="IMHmfgb_VerJon.WebCamPart" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager EnablePageMethods="true" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<script src="location of webcam.js"></script>
<div id="my_camera" style="width:640px; height:480px"></div>
<asp:Label ID="Label1" runat="server" Font-Size="12"></asp:Label>
<script type="text/javascript">
function showCam() {
Webcam.attach('my_camera');
}
</script>
<asp:Button ID="Button2" runat="server" OnClientClick="showCam();return false" Text="Show Cam" /><asp:Button ID="Button1" runat="server" OnClientClick="take_snapshot();return false" Text="Scan" />
<script type="text/javascript">
function take_snapshot() {
Webcam.snap(function (data_uri) {
PageMethods.BarcodeScan(data_uri, onSuccess, onFailure);
})
};
function onSuccess(result) {
document.getElementById('<%=Label1.ClientID%>').innerHTML = result;
};
function onFailure(result) {
document.getElementById('<%=Label1.ClientID%>').innerHTML = result;
};
</script>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="500">
<ProgressTemplate>
<asp:Image ImageUrl="~\Pictures\Loading.gif" runat="server" ImageAlign="Middle" />
</ProgressTemplate>
</asp:UpdateProgress>
</form>
</body>
</html>
I don't believe that the code above is the problem because, as stated above, it all works fine by itself. This leads me to believe that there is some setting or piece of code somewhere in my main project that is interfering with loading the video, but I have no idea where to look or what to look for.