Is possible create a Real Time Multiplayer game web based? - google-play-services

I am trying to use the Google Play Game Services to create a multiplayer game based web, but I can't create the Rooms. Is possible use the Google play game services on web to use the real multiplayer?
<meta name="google-signin-clientid" content="32241234345-oklsdfhgiodf89789gfgfy9ym.apps.googleusercontent.com" />
<meta name="google-signin-cookiepolicy" content="single_host_origin" />
<meta name="google-signin-callback" content="signinCallback" />
<meta name="google-signin-scope" content="https://www.googleapis.com/auth/games https://www.googleapis.com/auth/plus.login">
<!--meta name="google-signin-scope" content="https://www.googleapis.com/auth/games-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script src="https://apis.google.com/js/client.js"></script>
<script src="https://apis.google.com/js/client:plusone.js"></script>
<script>
var appId = '0000000000';
var clientId = '0000000000-dfdsfsdfsdfsdgsdgfsdtodnjj8hq6hjm.apps.googleusercontent.com';
var apiKey = 'SDFGSDKjjk123123';
//var scopes = 'https://www.googleapis.com/auth/plus.me';
var scopes = 'https://www.googleapis.com/auth/games';
function create(){
gapi.client.request({
path: 'https://www.googleapis.com/games/v1/rooms/create',
method: 'POST',
callback: function(response) {
console.log(response);
}
});
return false;
}

The answer depends on whether or not you want the game to be in real time or not. If you are ok with a turn based multiplayer game then you can use the REST API.
For more info visit this link: https://developers.google.com/games/services/common/concepts/turnbasedMultiplayer
If you want multiplayer to be real-time then the answer is No. You currently can not do that with Googles API. It is only available on mobile.

Unfortunately only works with Android and iOS
The Google Play Games real-time multiplayer service is supported on
these platforms:
Android through the Google Play services SDK
iOS through the iOS SDK
https://developers.google.com/games/services/common/concepts/realtimeMultiplayer

Related

Stream static video file through webrtc

what I am trying to accomplish is to have on my page audio and video file. And then send them through webrtc. I managed to do this with audio using web audio api like this.
HTML:
<audio id="audio">
<source src="../assets/outfoxing.mp3" />
</audio>
JS:
const audioElement = document.getElementById("audio");
const incomingSource = audioContext.createMediaElementSource(audioElement);
const outgoingStream = audioContext.createMediaStreamDestination();
incomingSource.connect(outgoingStream);
const outgoingTrack = outgoingStream.stream.getAudioTracks()[0];
audioElement.play();
await this.sendTransport.produce({ track: outgoingTrack });
For webrtc I am using mediasoup
Now I want to do the same with the video. But there is no such thing like web video api so I am stuck. How can I accomplish this task.
There are some limitations, but you could refer to this sample implementation.
It uses the captureStream() method.

broadcast a web-cam to (YouTube, Twitch , facebook) using HTML5 and WebRTC

I'm working on a project where i need to broadcast a live video on youtube, twitch , Facebook or other platforms from my website using HTML5 , rtmp , webrtc, nodejs....
so instead of going to youtube and start a live video, i want to start the video from my website
but im new to webrtc and live streaming and i don't know what to do or how to start this so please if anyone have any ideas or suggestions about how to do this please contact me or leave a comment here
this is what i did
SERVER SIDE (NodeJs)
io.on('connection', (socket) =>{
socket.on('stream', stream =>{
console.log(stream)
socket.broadcast.emit('stream', stream);
});
})
Client Side
Html (video.html)
<div id="videos">
<video id="video" autoplay>
</video>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js"></script>
<script src="js/video.js"></script>
Javascript (video.js)
var socket = io();
navigator.mediaDevices.getUserMedia({
video : true,
audio: true
})
.then(stream =>{
document.getElementById('video').srcObject = stream
socket.emit("stream", stream);
})
socket.on('stream', stream=>{
video = document.createElement("video")
video.srcObject = stream
video.setAttribute('autoplay')
document.getElementById("videos").appendChild(video)
})
You will need to do a WebRTC to RTMP bridge on your backend.
There are a lot of things to consider, but this is a common question so I threw together twitch. It is an example of doing this.

Sample Code for Google Translate API

I want to use the Google Translate API in eclipse and I've checked the Google API website, but there isn't any sample code for the Google Translate API in Java. Can someone provide some and explain how to get started. I have already read the documentation on this API.
https://cloud.google.com/translate/v2/quickstart#JSONP
<html>
<head>
<title>Translate API Example</title>
</head>
<body>
<div id="sourceText">Hello world</div>
<div id="translation"></div>
<script>
function translateText(response) {
document.getElementById("translation").innerHTML += "<br>" + response.data.translations[0].translatedText;
}
</script>
<script>
var newScript = document.createElement('script');
newScript.type = 'text/javascript';
var sourceText = escape(document.getElementById("sourceText").innerHTML);
// WARNING: Your API key will be visible in the page source.
// To prevent misuse, restrict your key to designated domains or use a
// proxy to hide your key.
var source = 'https://www.googleapis.com/language/translate/v2?key=YOUR_API_KEY&source=en&target=de&callback=translateText&q=' + sourceText;
newScript.src = source;
document.getElementsByTagName('head')[0].appendChild(newScript);
</script>
</body>
</html>
The Google Client Libraries are now the recommended APIs to use. You can now find Java specific Translation API Client Library examples in the documentation.
To report any issues with the new Java specific Client Libraries, you can directly file an issue on the GitHub Issue tracker.
you can installe this package for laravel
https://packagist.org/packages/charef/free-translate-api

Apps Script webapp: how to authenticate bigquery?

I am trying to get my apps script webapp to execute as "user accessing the webapp", but its bigquery should run as me, the developer. (If I run the webapp as me, everything works...) I looked at the documentation at https://developers.google.com/bigquery/docs/authorization. There is no apps script example, so I tried to get the javascript example working.
<html>
<head>
<script src="https://apis.google.com/js/client.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
function auth() {
gapi.auth.authorize(config, function() {
gapi.client.load('bigquery', 'v2');
$('#client_initiated').html('BigQuery client authorized');
$('#auth_button').fadeOut();
$('#dataset_button').fadeIn();
});
}
// User Submitted Variables
var projectNumber = 'XXXXXXXXXX';
var clientId = 'XXXXXXXXXX.apps.googleusercontent.com';
var config = {
'client_id': clientId,
'scope': 'https://www.googleapis.com/auth/bigquery'
};
function listDatasets() {
var request = gapi.client.bigquery.datasets.list({
'projectId':projectNumber
});
request.execute(function(response) {
$('#result_box').html(JSON.stringify(response.result.datasets, null));
});
}
</script>
</head>
<body>
<button id="auth_button" onclick="auth();">Authorize</button>
<div id="client_initiated"></div>
<button id="dataset_button" style="display:none;" onclick="listDatasets();">Show datasets</button>
<div id="result_box"></div>
</body>
</html>
I generated a client id as a browser app with https://script.google.com as the server address. With the code above, I get this error: Cannot read property 'authorize_m___' of undefined.
My question is twofold: 1) Would an apps script webapp authenticate in the same way as the javascript app authenticates? I.e. can I use that code as a guide for my apps script?
And 2) any suggestions about how to debug the javascript sample code? Note that I ran this code as an apps script webapp.... That is probably an error....
The answer... or workaround answer is given here: How to pass parameters from one Google-Apps-Script to another and execute?
I can use two stage authentication in place of direct authentication: the user logs in as him/herself, I get the user's name to find their files, then switch to a webapp that uses BigQuery and execs as me, the developer.
A good workaround for advanced services authentication under apps scripts....

Meta refreshing on the iTunes Store

Recently Apple has unified its affiliate management by providing links with target "itunes_store' of the kind:
In Arrivo! HD - Rome's and Milan's buses, taxi and metros, and trip sharing for the conscious visitor to the Ethernal city - Fabrizio Bartolomucci
Yet, in order to simplify its management, I would like to call it by means of a meta refresh from a page on my site only I have no hint about how the handle the target thing. The Windows open command just handles standard targets and if I enter 'itunes-store', I get an empty page.
Thanks for your help.
I'm pretty sure you can't specify a target on a meta refresh, but here is some JavaScript that does what you want. Just place this block somewhere on your page.
<script type="text/javascript">
var url = "https://itunes.apple.com/it/app/in-arrivo-hd-i-tempi-di-arrivo/id409812280?mt=8&uo=4&at=11l5Jz%22";
var link = document.createElement('a');
link.setAttribute('href', url);
link.setAttribute('target', 'itunes_store');
link.click();
</script>
Funnily combining your solution with the normal meta refresh does the trick. This is the full code working both on the web, on the iPhone, on Facebook and by the QR code. Great!
<script type="text/javascript">
var url = "itmss://itunes.apple.com/it/app/in-arrivo-hd-i-tempi-di-arrivo/id409812280?mt=8&uo=4&at=11l5Jz%22";
var link = document.createElement('a');
link.setAttribute('href', url);
link.setAttribute('target', 'itunes_store');
link.click();
</script>
<meta http-equiv="refresh" content="0; url=https://itunes.apple.com/us/app/in-arrivo!-hd-romes-milans/id409812280?mt=8&uo=4">