continuous video stream call using html5 [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
i want to call function aaP() continuously so that other pages of same site gets the same VISUAL but gets called only at page load
var video = document.querySelector('video');
if (navigator.getUserMedia) {
navigator.getUserMedia({ audio: true, video: true }, function (stream) {
setTimeout(function () { aaP(window.URL.createObjectURL(stream)); }, 99);
}, errorCallback);
}
function aaP(aapV) {
alert(5);
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
video.src = window.URL.createObjectURL(stream);
}
}
xmlHttp.open("GET", "WebForm1.aspx?res=aa &mssg=" + aapV, true);
xmlHttp.sen

Your code seems to be incomplete. Maybe you could detail a bit further what you want to achieve. If I understand your question correctly you want to keep the video/audio capture running while a user navigates through different pages of your site and that with no interruption. Correct?
This is not possible by design because Javascript gets executed when a page loads. So if you move to another page of your website the previously existent JavaScript objects will be destroyed and rebuilt on your new page.
Your best approach could be to keep your users on the same web page and then refresh the content of this page with Ajax as they navigate through the different sides of it.
EDIT: for video conferencing you could have a look at WebRTC. Those 2 articles should get you on the right track. Here and here. WebRTC will work great for one to few, one to one, few to few. If you need to support more concurrent connections you can have a look at Licode. There is also tokbox but that one needs to be paid for.

Related

Block visitors from internet explorer or microsoft edge [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed last year.
This post was edited and submitted for review last year and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I need a Javascript script to block internet explorer or microsoft edge visitors to prevent accessing my website on blogger
Edit*
Someone help me and answered the question across using user-agent
First of all, I don't recommend using that on your website. if there is some functionality that doesn't support this browser you can show a notification or popup telling the user to switch his browser to get a better experiment.
but if you see that is the better solution you can check this code example from here to check the user browser:
let userAgent = navigator.userAgent;
let browserName;
if(userAgent.match(/chrome|chromium|crios/i)){
browserName = "chrome";
}else if(userAgent.match(/firefox|fxios/i)){
browserName = "firefox";
} else if(userAgent.match(/safari/i)){
browserName = "safari";
}else if(userAgent.match(/opr\//i)){
browserName = "opera";
} else if(userAgent.match(/edg/i)){
browserName = "edge";
}else{
browserName="No browser detection";
}
document.querySelector("h1").innerText="You are using "+ browserName +" browser";
And this for redirect to another page:
window.location.replace("http://www.EXAMPLE.com");
Every browser and app which access a website has something called a "User Agent". The UA is part of the header that is sent/received with each HTTP call.
Since accessing your website is nothing else than sending a GET-request, you can handle this by checking the user agent in the header and re-route users to a page where you can tell them that they should a different browser.
Or you could entirely block the access by not displaying any elements if the user agent is either Edge or IE.
Here is an example on how to get the user agent:
https://www.w3schools.com/jsref/prop_nav_useragent.asp
If you want a better example this could also help:
https://learn.microsoft.com/en-us/microsoft-edge/web-platform/user-agent-guidance
TL;DR: All you need to do is to check the user agent. You can either do this by pattern matching or simpler by searching if the string contains something that's only there in IE/Edge browsers and act accordingly, e.g. by re-routing or not showing/hiding all elements. (I'd avoid the 2nd suggestion, since it's not user friendly)

JavaScript is not reading my file to alert, undefined when printing to console [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Why won't this read my file!? What am I missing
NOTE - I also get warning : XMLHttpRequest on the main thread is deprecated because - not sure what else to use?
<script>
function readTextFile(file)
{
var rawFile = new XMLHttpRequest();
rawFile.open("GET", file, true);
rawFile.onload= function (){
if(rawFile.readyState === 4)
{
if(rawFile.status === 200 || rawFile.status == 0)
{
var allText = rawFile.responseText;alert(allText);
console.log(alltext);
}
}
}
}
var test = readTextFile("file:///C:/Users/.../Desktop/***.txt")
console.log("test"+ test); //undefined
</script>
For security reasons, the web browser is not allowed to read local files.
You could however try running the app via the the same file:// protocol. Eg. type this URL in the browser address bar: file:///C:/Users/.../Desktop/myapp.htm (where myapp.htm is the app making the request)
The third argument in rawFile.open determines if the request should be async or not.
In your example, the value is set to true (async) so I'm not sure why you get the deprecation warning.
In newer browsers you can however use the Fetch API.
In order to read local files you could run a server on the user machine, that for example communicates with the web app using the HTTP protocol - and send the XMLHttpRequest (or fetch) to that server.
If you decide to use a local server, make sure it requires authorization and use Content Security Policy properly.

Get Meta Data content scripts in chrome extension [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I used chrome.tabs to get the meta data in content scripts for chrome extension. but it dosen't work because the chrome.tabs is only used in background script and popup script.
How do I have to do to get the meta data of active page in content scripts?
Thanks.
Since, as you noticed, a content script can't call tabs API, it need to ask something that can to do it.
That something is a background, or even better, event page.
Asking in this case means sending Messages. A message from a content script will be stamped with the Tab object of the page it comes from, so you don't need to look for it.
// Content script
chrome.runtime.sendMessage({action: "getTabDetails"}, function(response) {
// response.id is the tab ID
});
// Event script
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (message.action === "getTabDetails") {
// Here, sender.tab will be the tab you need; you can pass whatever data
// required back. For example, the ID:
sendResponse({id: sender.tab.id});
}
});

Javascript trigger a URL on Homepage Load [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
We are moving our website from hosting.
I was wondering why the Youama extension is not loading on our homepage. This is our website in old hosting as you can see upon loading the homepage the extension is loaded right away. But in our new hosting which is an exact replica, no changes or modifications added, as you can see it's not loading the extension, but if you click the Login at the top it will run the extension.
Can someone here please help me identify the issue? Or maybe give me a solution wherein I can manually add a Javascript code so I can trigger such event?
Looking forward.
There are hard coded links to the old site, see the example below. Change those links to the new domain.
function isUserLoggedIn()
{
$.ajax({
//Update to http://electricbot.com/lipstickboutique/
url: "http://lipstickboutiquewholesale.co.uk/checkuser.php",
async: false,
cache: false,
timeout: 30000
})
.done(function(data){
userStatus = data;
})
;
}
There is a javascript error that blocks the Youama extension to execute.
Maybe you are still sending ajax request to old url: There is some kind of CORS prevention on the back-end, which results in ajax request failing.

There is any way to save image/pdf content into local file system applicable for all browsers [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I got image content by ajax response in an array buffer.appended that array buffer to blob builder.now i want to write these contents to a file.Is there any way to do this..?
I used windows.requestFileSystem it is working fine with chrome but in mozilla not working..
here is my piece of code ,
function retrieveImage(studyUID, seriesUID, instanceUID, sopClassUID,nodeRef) {
window.requestFileSystem = window.requestFileSystem||window.webkitRequestFileSystem;
var xhr = new XMLHttpRequest();
var url="/alfresco/createthumbnail?ticket="+ticket+"&node="+nodeRef;
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
if(this.status == 200) {
window.requestFileSystem(window.TEMPORARY, 1024*1024, function(fs) {
var fn = '';
if(sopClassUID == '1.2.840.10008.5.1.4.1.1.104.1') {
fn = instanceUID+'.pdf';
} else {
fn = instanceUID+'.jpg';
}
fs.root.getFile(fn, {create:true}, function(fileEntry) {
fileEntry.createWriter(function(writer) {
writer.onwriteend = function(e) {
console.log(fileEntry.fullPath + " created");
}
writer.onerror = function(e) {
console.log(e.toString());
}
var bb;
if(window.BlobBuilder) {
bb = new BlobBuilder();
} else if(window.WebKitBlobBuilder) {
bb = new WebKitBlobBuilder();
}
bb.append(xhr.response);
if(sopClassUID == '1.2.840.10008.5.1.4.1.1.104.1') {
writer.write(bb.getBlob('application/pdf'));
} else {
writer.write(bb.getBlob('image/jpeg'));
}
}, fileErrorHandler);
}, fileErrorHandler);
}, fileErrorHandler);
}
};
xhr.send();
}
The script of a web page is not allowed to write arbitrary files [such as pdfs] to client's storage. And you should be thankful because that means that web pages have a hard time trying to put malware on your machine.
Instead you should redirect the user (or open a new window/tab) to an url where the browser can find the content desired for download, and let it handle it. Use the header to tell the client to download it or displayed as explained here.
If you need to create the downloaded content dynamically, then manage it on the server making it an active page (.php, .jsp, .aspx, etc...). What matters is to have the correct MIME type in the header of the response.
Note: yes, I'm telling you to not use ajax, just window.open. Edit: I guess you may want to present the images in a img, in that case, it is the same, just put the url in the src attribute and have no ajax. Only some javascript to update the attribute if appropiate.
Given your comment I understand that you want:
To cache the image in the client to avoid to have to get it back from the server every time.
To allow the user to customize his experience allowing the use of images from local storage.
Now, again for security reasons, arbirary access to client's files is not allowed. In this case it works both ways: first it prevents the webpage to spy you, and second it prevents you to inject malicious content on the page.
So, for the first part, as far as I know the default is to cache images [this is handled by your browser, and yes, you should clean it from time to time because it tends to grow]. If that is not working for you, I guess you could try use a cache manifest.
About the second, the usual way would be use local storage [which, again is handled by your browser, but is not arbitrary access to client's files] to store/retrieve the url of the image and use it present the image.
The image can still be saved at the server, and yes, it can be cached. To get it to the server - of course - you can always upload it with <input type="file" ... /> and you may need to set enctype to your form. - You already knew that, right? - On the server, store the image on a database (or dedicated folder). Now the page that is resposible to retrieve the image should:
check the request method
check user's permissions (identify it by the session / cookie)
check the parameters of the request (if any)
set the header
output the file got the database (or dedicated folder)
Now, let's say you want to allow this to works as an xcopy deployable application (that just happens to run in a browser). In this case you can always tell the user to store the images he want in a particular location and access them with a relative path.
Or - just because - you are hosting in a place were there is no chance of server-side scripting. So you got to go along only with what javascript gives you. Well, you cannot use relative path here, since it is not local... and if you try to use a local absolute path, the browser will just diss you (I mean, it just ignores it).
So, you can't get the image from a file of the client, and you can't store it on the server...
Well, as you know there is a working draft for that, and I notice it is what you are trying. The problem is that it is a working draft. The initial implementation gets staggered by the security issues, to quote Jonas Sicking:
The main problem with exposing this functionality to the web is security. You wouldn’t want just any website to read or modify your images. We could put up a prompt like we do with the GeoLocation API, given that this API potentially can delete all your pictures from the last 10 years, we probably want something more. This is something we are actively working on. But it’s definitely the case here that security is the hard part here, not implementing the low-level file operations.
So, I guess the answer is "not yet"? In fact, considering Microsoft's approach of only providing the parts of the standardar that reach recommendation status, and also its approach of launching a new version of IE each new version of Windows... then you will have to wait a while to have supports in all the browsers. First wait until FileAPI reaches recommendation status. Then wait until Microsoft updates IE to support it. And if, by any chance (as it seems will happen) it will be only for IE10 (or a future IE11) and those deosn't work on a Windows before Windows 8, you will be waiting a lot of people to upgrade.
If this is your situation, I would suggest to get an API for some image hosting web site, and use that instead [That will probably not be free (or not be private), so you could just change your web hosting already].
you cant have a common way to store the response in files compatible with all the browsers ,
there is a way , u can use FileReader in javascript but that again wudn't work on IE either .
I had the similar prob a few weeks ago , what i did was i made an ajax request to a server passing the content , the server stored the content for me in the file , then it return a reference to the stored file.
i stored my files in a temp database table and the server action returned the id for the file by which we can access the file from database whenever we want.
you can also store your files on the server in some thumbnail , but i prefered database.
if u need any more specification , let me know

Categories

Resources