Getting started with AirConsol...

Quick Start

8min

General idea

  1. Create a new directory with two files screen.html and controller.html.
Document image


2. Include the AirConsole JS API and use it to communicate between devices.

Document image


3. Host your files (local/remote) and call: airconsole.com/#http://YOUR_GAME_URL/

Document image


Step by step guide

Create files:

Create a new directory for your game (E.g. game) and create two files in it:

/game

  • screen.html
  • controller.html

The screen.html is for the gameconsole's screen. The controller.html are for the gameconsole's controllers (gamepads).

Document image


Make sure both files can be accessed by: http://your-local-webserver/screen.html (or /controller.html)

If you don't want to create your own screen.html and controller.html right now and just play around, you can use our pong example (pong.zip) from the Classic Pong walkthrough.

Include AirConsole Javascript API file:

Include the AirConsole Javascript API in both files /screen.html and /controller.html

HTML


Send a message:

Here is a simple example where the controller sends "How are you?" to the screen and the screen replies with "Full of pixels!"

/controller.html

JS


/screen.html

JS


Test your game:

You need to start a local webserver in your /game folder to serve the screen.html and controller.html

In this example we will host the two files on:

http://192.168.0.1:8080/screen.html http://192.168.0.1:8080/controller.html

To run the game, go with the browser that should act as the screen to:

NOTE: there is NO screen.html at the end!

Game controllers (your smartphone) can join as usual over www.airconsole.com. Enter the code you see on the screen. The devices should now exchange the messages.

Simulator:

If you append /simulator in the URL, then you will get a split view of the screen and two controllers:

This makes testing and developing a lot easier

If you run into issue with HTTPS (mixed content issues), refer to the tunneling guide.

Device Ids - Important warning:

Make sure you do not assume that the controllers have device_ids 1, 2, 3 ... We strongly recommend you read the device ids and states guide!

Next steps:

Checkout the guide about our pong example or the API to learn more about how to build games for AirConsole.