Using WebRTC getUserMedia with UWP WebView - win-universal-app

I've created a basic UWP application with a WebView. I'm navigating to this URL: https://webrtc.github.io/samples/src/content/getusermedia/gum/ to test the use of getUserMedia().
The error I get is: getUserMedia error: NotFoundError
Does anyone know if this should be possible, and if I'm therefore doing something wrong? Anyone using getUserMedia within a UWP WebView?
Thanks for any guidance.

getUserMedia error: NotFoundError
This error will occurre when the user denies permission, or media is not available.
In an UWP app, when you want to access Media capture, you will need to open the manifest file of your project, go to the Capabilities label and select the Webcam capability to enable the Camera device for your app.
This will solve the problem, but for your case, I think you may also need to enable the Microphone capability in the same way.

In addition to the accepted answer, I needed to add this handler to the webview to allow permission:
webView.PermissionRequested += WebView_PermissionRequested;
...
private void WebView_PermissionRequested(WebView sender,
WebViewPermissionRequestedEventArgs args)
{
args.PermissionRequest.Allow();
}

Related

Adding Dynamic Cast Button to Android Application

From the Google documentation about adding a Cast button, https://developers.google.com/cast/docs/android_sender#adding-the-cast-button , it seems like the option they provide is for us to add a static button to the Action Bar. That said, what would I do if I wanted to add a Cast Button to my application only if there's a device on the network dynamically? Also, what are some ways you would create a custom button that mimic the functionality of a MediaRouter Button.
Any input would be appreciated!
Based on your response in the comments, it seems like you want the normal behavior of a cast button, provided by, say, the MediaRouteActionProvider except that you don't want the cast discovery to include "guest mode". Is that a fair rephrasing of your question? If that is the case, then you can simply use the MediaRouteActionProvider and when you add your app in the developer console, you can uncheck the box that says "Supports Google Cast Guest Mode". Then guest mode (i.e. discovery of your app when not on wifi) is disabled for app and only devices that are on the same wifi network as your phone will be discoverable for your app.
After following the steps for incorporating cast in your application. Eg https://github.com/googlecast/CastHelloText-android/blob/master/src/com/example/casthelloworld/MainActivity.java Create an android button and call the following method in the button
public void connect() {
android.media.MediaRouter mMediaRouter = (android.media.MediaRouter)getApplicationContext().getSystemService(Context.MEDIA_ROUTER_SERVICE);
mMediaRouter.selectRoute(android.media.MediaRouter.ROUTE_TYPE_USER,mMediaRouter.getRouteAt(1));
}
This automatically connects to the chromecast and calls the #Override
public void onRouteSelected(MediaRouter router, RouteInfo info) method.

Corona net::ERR_CACHE_MISS comes when loading an external url in Corona

I am using Corona to make an app. I have implemented following code to open a website/a page inside my app view instead of browser:
function openLink(event)
if(event.phase == "ended")then
print("btn clicked")
local webView = native.newWebView( display.contentCenterX, display.contentCenterY, 320, 480 )
webView:request( "http://www.coronalabs.com/" )
local text1 = display.newText("",100,100,native.systemFontBold,20)
text1.text = "native should come"
end
end
btn:addEventListener("touch", openLink)
Its giving me following error on device when button is tapped:
net::ERR_CACHE_MISS
Please help me out with this. Also, I have few questions regarding feasibility of this function.
Can I access full interactivity of website inside app view? i.e. scroll through pages, open other pages, navigate to other elements of website etc.
If I can't access complete website with ease, is there any possibility that I can open multiple pages one after another of same website on click of various buttons created by me inside app?
Any help is greatly appreciated.
The ERR_CACHE_MISS error comes from Chrome. To avoid it, check the following:
Make sure you can get to the URL from a browser on the mobile
device to ensure the issue isn't with your Internet connection.
Make sure that your build.settings file in your Corona app allows for Internet
permissions. For Android, this means including the following in build.settings:
-- Android permissions
androidPermissions = {
"android.permission.INTERNET",
},

Using both activeTab and serial permissions

I am trying to use a hardware serial device to change what displays on a webpage in Chrome. I'm making a Chrome extension to do so, however it seems as if I cannot use both the activeTab and serial permissions at the same time. The activeTab permission requires the app to not be a packaged app, and the serial permission requires the app to be packaged.
How can I get around this if possible?
I am using the page redder sample code as the way to change the webpage, however it requires the activeTab permission. Maybe there is a workaround to this? Thanks
The only way I can think of is to create one Chrome Extension and one Chrome App that communicates to each other: https://developer.chrome.com/extensions/messaging#external
// The ID of the extension we want to talk to.
var laserExtensionId = "abcdefghijklmnoabcdefhijklmnoabc";
// Make a simple request:
chrome.runtime.sendMessage(laserExtensionId, {getTargetData: true},
function(response) {
if (targetInRange(response.targetData))
chrome.runtime.sendMessage(laserExtensionId, {activateLasers: true});
});
// Start a long-running conversation:
var port = chrome.runtime.connect(laserExtensionId);
port.postMessage(...);
An alternative is to make a Native Messaging host that communicates with the device and with your extension.
From architectural point of view this makes more sense, but limits your deployment options, as the host program can't be bundled with the extension in the Web Store.

ChromeCast(google cast) can't find app name

ChromeCast (google cast) can't find my app name.
I already registered the app in the whitelist.
I can find and launch apps/YouTube, apps/ChromeCast, apps/OldAppName,
but not apps/NewAppName.
Why so? How can I do any thing?
thanks a lot.
Sincoew
Hi Ali Naddaf,
Thanks you for your reply.
I already checked each step by your link again, My app ID is already in whitelist.
I used "//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"
in my receiver app.
but when I Invoke receiver use new app ID, It's return below Error on receiver source code.
(google default)enter code here
case Message.CODE.ERROR_NET_ABORTED:
return new Message(
Message.getLocaleString('BrainFreeze'),
Message.getLocaleString('Sorry'),
Message.getLocaleString('ActivityAborted'));
On ChromeCast "receiver/1.0/cast_receiver.js",
I can found my app use app ID, such as "192.168.xxx.xxx:8008/apps/AppID",
This rule is still can work???
Thanks a lot.
Sincoew
The error source code is in home screen,
http://192.168.xxx.xxx:9222/devtools/devtools.html?xxxxxx
"message.js" file,
This is ChromeCast default home screen source code
I use below receiver:
//github.com/googlecast/cast-custom-receiver/blob/master/sample_media_receiver.html
sender:
1 //github.com/googlecast/cast-sender-tool-chrome
2 our iOS app sender, (google sample)
ps. default app is normal work, YouTube/ChromeCast/old app-ID(version 1.0 js)
and I can found below page use browser,
"192.168.xxx.xxx:8008/apps/YouTube"
"192.168.xxx.xxx:8008/apps/Chromecast"
"192.168.xxx.xxx:8008/apps/old app-ID"
but can't found
"192.168.xxx.xxx:8008/apps/new app-ID"
Thanks a lot,
Sincoew
Most likely your device is not whitelisted. You need to register your chromecast device for your appid and then, follow the instructions in this post to troubleshoot. Also read the development site for chromecast; it has valuable info.

How to create a Google/Safari extension with ability to override audio playing in a tab?

I am trying my hand at developing my own Safari extensions that could perform basic Pandora commands from the an extension menu (with an open tab streaming from the Pandora site). I'm just wondering if there is a way I can programmatically mute my Pandora music if I were to play a YouTube video from another tab? I've seen it done on a Google Chrome extension called "SoundControl" but have no idea whether it is at all possible to implement on Safari. Any suggestions or reference to the safari manual would be appreciated. Thanks!
Add an event listener to your code like this:
safari.application.addEventListener("activate", activateHandler, true);
function activateHandler(event) {
if(event.target.activeTab.url.indexOf("youtube") != -1)
{
//Pause your player in here
}
}
Look at music player tutorial in here
Window or tab activated event tutorial is in here

Resources