Is it possible to record a window without user intervention in recordrtc? - ffmpeg

I know it may sound shady, but I'm developing a window recording program (right now using ffmpeg + gdigrab to grab windows) that records
The question is, can I pass the window to be recorded without the user having to choose it?
Thanks!

If you're using Chrome browser, you can open Google Chrome Properties dialog, find the "Target" box and put --enable-usermedia-screen-capturing at the end. E.g.
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --enable-usermedia-screen-capturing
Now relaunch the Chrome browser.
Screenshot for chrome properties box:
Now try following code on any HTTPs page (or on localhost page):
var screen_constraints = {
mandatory: {
chromeMediaSource: 'screen'
},
optional: []
};
var hints = {
audio: false,
video: screen_constraints
};
navigator.webkitGetUserMedia(hints, function(screen) {
// this is your screen; record it using MediaRecorder or RecordRTC
}, function(error) {
console.error(error);
});
Want to try on HTTP pages? Following flag may work:
--allow-http-screen-capture
Chrome flags reference: http://peter.sh/experiments/chromium-command-line-switches/

Related

Office.js displayDialogAsync error when displayInIframe: false

I'm trying to display, in an outlook web add-in, a dialog from a taskpane using the displayDialogAsync function. At first, I used displayInIframe: true and everything was working wonderfully, but for some reason I needed it to display in its own page.
So I changed the options to displayInIframe: false, and that causes a prompt to open. When it opens and I click Allow, I get a JSON.parser error.
Uncaught SyntaxError: Unexpected token d in JSON at position 0 at JSON.parse (<anonymous>) at O (outlook-web-16.01.js:20:204476) at HTMLInputElement.Y.f.onclick (outlook-web-16.01.js:20:196995)
It's comming from this line: var windowName = JSON.parse(window.name);
I tried turning the prompt off using promptBeforeOpen: false, but as it says in the docs, "When this option is set to false, Office on the web will not prompt the user to allow the add-in open a dialog, and the Office dialog will not open."
I was wondering if I was missing something, or if you can't actually open a dialog outside of an iframe in a taskpane?
Here is my code:
const dialogUrl = "https://office365.localhost.com/test.html";
Office.context.ui.displayDialogAsync(
dialogUrl,
{
displayInIframe: false,
height: 80,
width: 80
},
(result) => {
//Code
}
});

How to Make FireFox recieve background push notification without loading page?

I am using FCM for web push notifications.
All worked fine until suddenly Firefox stopped delivering push notifications except the page is open in the browser.
If the page is loaded and not in focus, notifications come in. I console.log()'d the onBackgroundMessage payload and I can confirm that the service worker receives it. But if I close that tab and send a push notification, it does not receive it.
The same setup works on Chrome, Opera, and Edge just fine no errors. Is there something with firefox?
Firefox version: 88.0.1 (64-bit)
in my Service Worker I have:
messaging.onBackgroundMessage(function (payload) {
// Customize notification here
var action_label;
if('action_label' in payload.data){
action_label = payload.data.action_label;
} else{
action_label = "Details";
}
const notificationTitle = payload.data.title;
const notificationOptions = {
body: payload.data.body,
icon: payload.data.icon,
requireInteraction: true,
data: {
click_action: payload.data.click_action,
url:payload.data.click_action
},
actions: [
{
action: "open_url", title: action_label
}
]
};
self.registration.showNotification(notificationTitle, notificationOptions);
});
This had to do with Firefox quitting instead closing, obtainable in MacBooks.
Not a real technical issue.

Opentok Screen Sharing with Audio

I try to create a Screen Sharing application with the opentok JS client that shares the publishers audio as well.
Screen Sharing works fine. But the audio is never shared.
Now, I noticed a warning in the console (Firefox) saying Invalid audioSource passed to Publisher - when using screen sharing no audioSource may be used. Does that mean it is not possible at all, or that the audio source is invalid?
With v2.13.0 it is now possible to pass a MediaStreamTrack as a custom audioSource and videoSource to initPublisher. This means you are able to add your microphone audio to the screen sharing stream. This will only work in Chrome or Firefox. IE does not support MediaStreamTrack's and Safari does not currently support screensharing.
const publish = Promise.all([
OT.getUserMedia({
videoSource: 'screen'
}),
OT.getUserMedia({
videoSource: null
})
])
.then(([screenStream, micStream]) => {
return OT.initPublisher(null, {
videoSource: screenStream.getVideoTracks()[0],
audioSource: micStream.getAudioTracks()[0]
});
});
Here is a sample of it all working https://output.jsbin.com/wozuhuc This sample will only work in Firefox because Chrome needs an extension.
I contacted the tokbox support and they confirmed, that the audio has to be published in an additional stream.
I had a go at making this work in Chrome, which is possible by using getDisplayMedia({video: true, audio: true}), which now shows a tickbox to allow the user to share device audio:
You can then use this to create a normal publisher which uses the video and audio streams from this call like so:
let prom = navigator.mediaDevices.getDisplayMedia({ video:true, audio: true });
prom.then(function(result) {
console.log("Collected permission. Going to start publishing.");
desktopStream = result;
var audioStream = desktopStream.getAudioTracks()[0];
var videoStream = desktopStream.getVideoTracks()[0];
console.log(audioStream);
// Screen sharing is available. Publish the screen.
screenPublisher = OT.initPublisher('ownScreen',
{
videoSource: videoStream,
audioSource: audioStream,
name: 'Sharing Screen',
maxResolution: { width: 1920, height: 1920 },
mirror: false,
fitMode: "contain",
},
function(error) {
if (error) {
console.log(error);
// Look at error.message to see what went wrong.
} else {
session.publish(screenPublisher, function(error) {
if (error) {
handleError();
}
$('#shareScreen').fadeOut(150, function(){
$('#stopShare').fadeIn(150);
});
$('#stopShare').addClass('blob blue');
});
}
}
);
You can also add a name to the screen share publisher to allow subscribers to distinguish between a regular video publisher and this new custom screen share publisher.
If you create a subscriber, and connect it to the session, it will receive audio and video from all publishers. As far as I know, there is no audio in screen sharing, that's why you cannot publish it. That should solve it. I hope this helps.

Offline data retrieval in a Cordova Windows project

I am having difficulties using the Kapsel OData plugin to retrieve data from a store when the device is offline.
Here is the situation :
Cordova application for Windows platform
When the app opens, I start by opening a store against my OData service (similar to the Northwind service)
The store is created and opened. I then try and retrieve data from the store using OData.read or by setting a model and then calling read() on it.
The store will successfully open. However, my call to read the data will succeed when the device is online, and fail when it is offline, no matter which of the two previous methods I use.
Here is my code :
function openStore() {
var properties = {
"name": "Emergency",
"host": applicationContext.registrationContext.serverHost,
"port": applicationContext.registrationContext.serverPort,
"https": applicationContext.registrationContext.https,
"serviceRoot": appId,
"definingRequests": {
"Products": "/Products"
}
};
store = sap.OData.createOfflineStore(properties);
store.open(openStoreSuccessCallback, errorCallback);
}
function openStoreSuccessCallback() {
sap.OData.applyHttpClient();
retrieveWithModel();//retrieveWithOData();
}
function retrieveWithModel() {
var uri = applicationContext.applicationEndpointURL;
var user = applicationContext.registrationContext.user;
var password = applicationContext.registrationContext.password;
var headers = { "X-SMP-APPCID": applicationContext.applicationConnectionId };
var oModel = new sap.ui.model.odata.ODataModel(uri, {
json: "true",
user: user,
password: password,
headers: headers
});
sap.ui.getCore().setModel(oModel);
oModel.read("/Products", {
success: function (oEvent) {
var msg = new Windows.UI.Popups.MessageDialog("Success");
msg.showAsync();
},
error: function (err) {
console.log("you have failed");
var msg = new Windows.UI.Popups.MessageDialog("Fail");
msg.showAsync();
}
});
}
function retrieveWithOData() {
var sURL = applicationContext.applicationEndpointURL + "/Products";
var oHeaders = {};
oHeaders['Authorization'] = authStr;
oHeaders['X-SMP-APPCID'] = applicationContext.applicationConnectionId;
//oHeaders['Content-Type'] = "application/json";
//oHeaders['X-CSRF-Token'] = "FETCH";
var request = {
headers: oHeaders,
requestUri: sURL,
method: "GET"
};
OData.read(request,
function (data, response) {
console.log('Success');
},
function (err) {
console.log('Fail');
}
);
}
Kapsel SDK version is 3.8.0
SMP SDK is SP08
Cordova version 5.3.3
I am wondering if this is an issue with the way the app is launched. I need a way to open the same instance of the application every time, so the offline store will be kept with all its data. Because Cordova-generated Visual Studio projects do not generate an .exe file (only .appx files which would need to be signed and sideloaded to be used), the way I proceed is : I run the application in online mode from Visual Studio, then pin it to the taskbar or start menu, close it and switch the device to offline mode, and reopen it from the task bar.
However, more and more it seems like this method does not work as expected.
Can anyone confirm that a Visual Studio project, opened from the taskbar, should run the same way as when it is run from VS, with the same dependencies, libraries etc? If such is the case (and I can't really imagine why it wouldn't be), does anyone have any experience with these technologies and see what a potential issue could be?
Any help would be greatly appreciated.
Thanks!
Ok I found the solution to my problem. In case anyone ever encounters the same issue, the problem was that my offline store was not being used (you can see with Fiddler that there are outbound requests to the backend system even in offline mode).
The Visual studio project does keep the store from one build or launch to the next.

Ext.Ajax.Request not working in Browser

Ext.Ajax.Request doesn't seem to work on desktop web browsers for me. It works perfectly fine on devices and on the xcode simulators but on desktop web browsers, it calls on the failure method. Here is the code:
// send ajax request
Ext.Ajax.request({
url: 'http://testapp.cloudapp.net/index.php/api/accounts/login/',
method: 'POST',
params: {
username: Ext.getCmp('username').getValue(),
password: Ext.getCmp('password').getValue()
},
dataType: 'json',
success : function(response, request) {
if(response.responseText == true) {
Ext.Msg.alert('validated');
// animate to wall view
Ext.Viewport.animateActiveItem(targetView, { type : 'fade' } );
//destroy Login and Register Views
var vwRegister = Ext.ComponentQuery.query('register')[0],
vwLogin = Ext.ComponentQuery.query('login')[0];
setTimeout( function() {
vwRegister.destroy();
vwLogin.destroy();
}, 2000);
}
else {
Ext.Msg.alert('invalid user');
}
},
failure: function(response, request) {
Ext.Msg.alert('error');
}
});
I don't think this has something to do with the "Same-origin policy" because I tried doing the same thing using jQuery's $.ajax function and it worked fine.
Check your debug console, you most likely will see an error about the same origin policy.
If nothing else try opening chrome with the --disable-web-security option to see if it helps.
See this question for exact syntax.
Good luck, Brad
Though not particularly safe or recommended, you can also start browsers like Chrome in a state that disables web security features, like the same origin policy.
For Windows...
chrome.exe --disable-web-security
For Mac...
Chrome.app --args --disable-web-security
Since I don't particularly enjoy using the terminal every time, you can write a bash script to do it for you, or use automator on a Mac.
Also, ensure the browser isn't already running, or else this will not work.

Resources