I am building a NW.js (Node-Webkit) dashboard app which I want to be able to control with a game controller (for example: XBox 360 controller or Logitech controller).
I'm calling the following onready but when I debug its not recognizing any gamepads.
angular.element(document).ready(function() {
if(canGame()) {
var prompt = "To begin using your gamepad, connect it and press any button!";
$("#gamepadPrompt").text(prompt);
$(window).on("gamepadconnected", function() {
$("#gamepadPrompt").html("Gamepad connected!");
console.log("connection event");
});
$(window).on("gamepaddisconnected", function() {
console.log("disconnection event");
$("#gamepadPrompt").text(prompt);
});
}
});
function canGame() {
return "getGamepads" in navigator;
}
When I debug the code, it doesn't appear to be detecting any gamepads. I also try:
navigator.webkitGetGamepads()
but it doesn't show any gamepads being detected either.
Has anyone successfully used gamepads with a NW.js app?
I would greatly appreciate some help getting this to work.
I found the answer to my issue. Gamepads are indeed compatible with NW.js. I however, was using an old version (~v0.08).
The code I posted earlier when running with NW.js v0.12.2.
Related
In my Ionic Application, I need to open my other application link in Play store.
I have tried following so far :
window.open('market://details?id=com.myapp.something', '_self')
And
window.open('market://details?id=com.myapp.something', '_system', 'location=no');
Above links opens in InnAppBrowser, I need them to open in playstore itself.
Any suggestions?
I found that you can open it in your system Browser with Package ID and it will automatically redirect you to respective application store.
$window.open("https://play.google.com/store/apps/details?id=your-app-package-name&hl=en","_system");
This worked for me the best.
EDIT :
There is a plugin available which might help : Launch Review
Redirect IONIC application to play store
window.open("https://play.google.com/store/apps/details?id=com.carClient.bookMyDreamCar","_system");
open playstore in your application
window.location.assign('https://play.google.com/store/apps/details?id=com.carClient.bookMyDreamCar')
If you want to open market apps for rating reviews then will be better to use this plugin instead
Ionic V3: https://ionicframework.com/docs/v3/native/launch-review/
Ionic >= V4: https://ionicframework.com/docs/native/launch-review
It has in app review for ios >10.3 (higher changes to get a review) and simply opens google play market for android.
Dependency injection:
import { LaunchReview } from '#ionic-native/launch-review';
constructor(
private _platform: Platform,
private _launchReview: LaunchReview
) { }
Implementation:
appId = null;
if (this._platform.is('android')) {
appID = '_COM.ANDROID.PACKAGE.NAME_';
} else if (this._platform.is('ios')) {
appID = '_APPLEID_';
}
if (appID) {
if (this._launchReview.isRatingSupported()) {
// For iOS > 10.3
this._launchReview.rating().then((result) => {
alert(result);
});
} else {
this._launchReview.launch(appID);
}
}
2020 Answer. Ionic 4.
Only window.location.assign helped for me. Working both iOS and Android. iOS URL should be itms-apps://itunes.apple.com/app/${iosITunesAppId}, Android one https://play.google.com/store/apps/details?id=${packageName}. packageName can be obtained using cordova-plugin-app-version plugin.
UPD: looks as I found why methods like window.open('market://details?id=com.myapp.something', '_system'); didn't work for me. Looks as they require cordova-plugin-inappbrowser plugin to be installed. I haven't that plugin installed in my app so that method didn't work.
So, I am not sure if this is the correct approach, but this was working properly before the Authors of Autobahn decided to close the AWS Hot Link (completely understandable).
So, the site I am working on basically allows users to select an internal reference, and have a conversation about it (they need to exchange documents, etc).
Whenever they click on a reference, they get subscribed to the server so they can receive real-time updates from other users, but if they change to a different reference, the first subscription needs to be closed out, and then open a new one.
Here's the JavaScript code that is not working as of this morning (After the AWS close out):
if (typeof conn == 'undefined') {
console.log("Conn is undefined...");
} else {
conn.close(); // Cerramos la conexión que ya existía, para evitar duplicar conexiones.
}
//conn = new ab.Session('wss://plt.prolog-mex.com/wss2/',
conn = new autobahn.Session('wss://plt.prolog-mex.com/wss2/',
function() {
conn.subscribe(idReferencia, function(topic, data) {
boardUser = $('#messageBoard').attr('usuario');
if (boardUser == data.idUsuario) {
clase = 'message-own';
} else {
clase = 'message-nonown';
}
$('#messageBoard').prepend('<p class="'+ clase +'"><span><b>'+data.usuario+' | '+data.when+'</b></span><br>'+data.article+'</p>')
});
},
function() {
console.warn('WebSocket connection closed');
},
{'skipSubprotocolCheck': true}
);
I'm thinking that the version I got from GitHub is not the same version they had on AWS, but that's just an assumption.
Any ideas?
Indeed I am using a really old version. I just came to realize this right now. Ratchet has stoped developing the library and is stuck using WAMPv1 protocol. The guys from autobahn JS actually stopped supporting it since '14 - the main problem is that Legacy versions were gone alongside with the bucket they took out a few days ago (oldest you could get is version 0.9, I am in 0.8)
2 years ago, sergeyvolkov decided to upload the files to GitHub (https://github.com/sergeyvolkov/autobahn-old) and I was able to get the 0.8 version from there and have my site up and running again.
There's the site in case anybody else had their site broken as well, however it is better if you replace Ratchet with Thruway so that you can use the newer versions of WAMP and Autobahn.
I've recently gotten my hands on the WebRTC sdk by PubNub. Everything's been going great but I've been having trouble displaying video from a client to my screen.
As mentioned in their documentations and tutorial I've written the following code:
function login(form) {
var pub = <publish_key>;
var sub = <subscribe_key>;
var phone = window.phone = PHONE({
number : form.username.value,
publish_key : pub,
origin :'pubsub.pubnub.com',
subscribe_key : sub,
//media : { audio : true, video : true }
ssl :true
});
var ctrl = window.ctrl = CONTROLLER(phone);
ctrl.ready(function(){
form.username.style.background="#55ff5b";
form.login_submit.hidden="true"; // Hide login button
ctrl.addLocalStream(vid_thumb);
});
ctrl.receive(function(session){
session.connected(function(session){
video_out.appendChild(session.video);
});
session.ended(function(session) { ctrl.getVideoElement(session.number).remove(); });
});
}
function makeCall(){
if (!window.phone) alert("Login First!");
var num = form.number.value;
if (phone.number()==num) return false; // No calling yourself!
ctrl.dial(num);
return false;
}
Evrything seems to be working, but the actual video is not being shown on my screen.
(I'm using chrome browsers on both machines)
Can anybody please help out?
Thanks
i got the solution..
Its a very weird solution though and i cant really say how it solved my problem..
I was previously putting my javascript codes in another script file and then linking that file to my HTML page. But as soon i transferred those code to my HTML page everything seemed to work just fine.
Thanks everyone.
WebRTC Video Streaming in PubNub P2P
Answer: WebRTC running on localhost with HTTPS
We answered a similar question yesterday. You can find the answer here in the following Stackoverflow answer link. Essentially you need to make sure you are running HTTPS locally and also using the correct variable scoping as mentioned by Craig Conover.
And you can find the source code on github gist.
I'm am attempting to record audio using Ionic and ngCordova.
Here is my code:
$scope.captureAudio = function() {
var options = { limit: 3, duration: 10 };
$cordovaCapture.captureAudio(options).then(function(audioData) {
// Success! Audio data is here
alert(audioData);
console.log(audioData);
}, function(err) {
// An error occurred. Show a message to the user
alert(err);
});
};
When I run this in the emulator it works fine and brings up the voice recorder and when the recording is done it logs out the audioData.
When I upload it to ionic view and run it I get nothing. Not even an error.
Has anyone seen anything like this before ?
Thanks
Kevin
$cordovaCapture plugin is not yet supported by ionic view.
Please see the list of supported plugins in this link.
You can run the code in device directly using run command.
ionic run android
ZeroClipboard doesn't work and it doesn't throw any errors (javascript console).
The website is hosted on a HTTPS webserver running on localhost. Both the website and the SWF are served over HTTPS by the same server.
The SWF is loaded and positioned correctly over the button (with ID: testButton). When right-clicking on the button, the flash context menu (About Adobe Flash Player 11.7...) is shown.
However, none of the events, not even "load", gets fired.
I am working on this problem for two days months now and i can't find a solution.
Additional info:
ZeroClipboard version: v1.1.7, also tried v1.2.0-beta.3, edit: This also happens with v1.3.1
Browser: Chromium 28 on Mac OSX
Official test website is working
Here is my code:
var clip = new ZeroClipboard(document.getElementById("testButton"), {
moviePath: "media/zeroclipboard.swf"
});
clip.on("dataRequested", function(client, args) {
client.setText("Copy me!");
});
clip.on("load", function(client) {
alert("movie is loaded");
});
clip.on("complete", function(client, args) {
alert("Copied text to clipboard: " + args.text);
});
clip.on("mouseover", function(client) {
alert("mouse over");
});
clip.on("mouseout", function(client) {
alert("mouse out");
});
clip.on("mousedown", function(client) {
alert("mouse down");
});
clip.on("mouseup", function(client) {
alert("mouse up");
});
After months I finally found a solution:
ZeroClipboard doesn't work out-of-the-box in CommonJS environments in the browser, even it says it does.
The fix for that is assigning the module scope variable (e.g. ZeroClipboard) to the global window object:
ZeroClipboard = require("zeroclipboard");
window.ZeroClipboard = ZeroClipboard;
I created a bug report on this:
https://github.com/zeroclipboard/zeroclipboard/issues/332
I'm not sure if this would help~ but have you tried changing your moviePath a little bit?
Like this:
{moviePath:"//YOURSERVER/path/ZeroClipboard.swf"}
I was trying to use ZeroCLipboard in the whole month and most of the time I fail because I got the path wrong in one way or another...
Good luck anyways~
If you extract the project exactly, the .SWF file is located here:
moviePath: "../zeroclipboard.swf"
I solved editing this line on ZeroClipboard.min.js
return a+"ZeroClipboard.swf"
to:
return "//YOUR/PATH/TO/ZeroClipboard.swf"
Would just like to point out for anybody else who finds this question first: ZeroClipboard does not work when looking at the file locally i.e. file://path/index.html. This is because of Adobe's security policies blocking the file:// protocol.
https://stackoverflow.com/a/9450359/710377
If you're already using Node.js at all (even just for the package manager) you can spin up a basic web server on the command line to test ZeroClipboard with npm install http-server -g and http-server /path/ (assuming that npm stuff is already on your path).