xboxappdev 4. web apps on xbox

59
#xboxappdev Web Apps on Xbox Bringing Your Web Experience to the Console Kirupa Chinnathambi | @kirupa Program Manager

Upload: windows-developer

Post on 13-Jan-2017

103 views

Category:

Software


0 download

TRANSCRIPT

Page 1: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

Web Apps on XboxBringing Your Web Experience to the Console Kirupa Chinnathambi | @kirupaProgram Manager

Page 2: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

1. Web Apps as UWP2. Designing for the TV3. Integrating with the platform4. WebView5. What’s next!

Agenda

Page 3: XboxAppDev 4. Web Apps on Xbox

Please ask questions at any time.

I’ll be monitoring the live feed throughout the talk.

#XboxAppDev

Page 4: XboxAppDev 4. Web Apps on Xbox

Web Apps

Page 5: XboxAppDev 4. Web Apps on Xbox
Page 6: XboxAppDev 4. Web Apps on Xbox

1. Built on web technologies2. Cross-platform / cross-

browser3. Responsive4. Built using your favorite

tools

Page 7: XboxAppDev 4. Web Apps on Xbox

Web Apps as UWP

Page 8: XboxAppDev 4. Web Apps on Xbox
Page 9: XboxAppDev 4. Web Apps on Xbox

To allow you to easily re-use your skills and assets.

Page 10: XboxAppDev 4. Web Apps on Xbox

Hosted Web AppsYour app content is served from a public URL.Packaged Web AppsYour app content is entirely local and part of your application.

Page 11: XboxAppDev 4. Web Apps on Xbox

Hosted Web Apps

Page 12: XboxAppDev 4. Web Apps on Xbox

Think of it as a thin UWP wrapper around a supercharged iframe that displays content from your server.

Page 13: XboxAppDev 4. Web Apps on Xbox

Think of it as a thin UWP wrapper around a supercharged iframe that displays content from your server.

Page 14: XboxAppDev 4. Web Apps on Xbox

Demo: Bing UWP

Page 15: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

Why?

Page 16: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

UWP apps are fully integrated with Windows 10.

You have access to native device capabilities via WinRT APIs.

Page 17: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

You have many ways to build Hosted Web Apps. Some popular ones include: • Visual Studio• ManifoldJS• Cordova CLI

Page 18: XboxAppDev 4. Web Apps on Xbox

Demo: ManifoldJS

Page 19: XboxAppDev 4. Web Apps on Xbox

Demo: Visual Studio

Page 20: XboxAppDev 4. Web Apps on Xbox

Designing for the TV(aka the 10’ Experience)

Page 21: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

Unless you explicitly designed for it, your web apps are optimized for screens that you hold or sit very close to.

There are a handful of things you can do to help address that.

Page 22: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

.xboxBody {

margin: 50px;

}

Create a “TV safe border” of 50 or so pixels. Keep critical content away from it.

Page 23: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

You can explicitly check for Xbox via an API like AnalyticsInfo.

My preference: Check for DPI (150% default zoom), resolution, whether a controller is connected, etc.

Page 24: XboxAppDev 4. Web Apps on Xbox

var isGamePadConnected = false;

function checkGamepad() { if (navigator.getGamepads) { var gamepads = navigator.getGamepads();

if (gamepads[0]) { isGamePadConnected = true; } else { isGamePadConnected = false; } } requestAnimationFrame(checkGamepad);}checkGamepad();

Page 25: XboxAppDev 4. Web Apps on Xbox

var view = Windows.ApplicationView.GetForCurrentView();

view.SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);

By default, you will get a black border around the page. You can remove it with the following WinRT call:

Page 26: XboxAppDev 4. Web Apps on Xbox
Page 27: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

Use a library like TVJS to enable directional navigation easily for your hosted as well as packaged apps.

(This works on all Windows devices with a gamepad or keyboard!)

Page 28: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

You can get TVJS from here: https://aka.ms/tvjs

Page 29: XboxAppDev 4. Web Apps on Xbox

TVJS makes it especially easy to quickly focus on elements that aren’t typically hit targets.

Page 30: XboxAppDev 4. Web Apps on Xbox

Demo: TVJS

Page 31: XboxAppDev 4. Web Apps on Xbox

<section> <div> <div id="A" class="btn">A</div> <div id="B" class="btn">B</div> </div> <div> <div id="C" class="btn">C</div> </div> <div> <div id="D" class="btn">D</div> <div id="E" class="btn">E</div> </div></section>

Page 32: XboxAppDev 4. Web Apps on Xbox

<section> <div> <div id="A" class="btn">A</div> <div id="B" class="btn">B</div> </div> <div> <div id="C" class="btn">C</div> </div> <div> <div id="D" class="btn">D</div> <div id="E" class="btn">E</div> </div></section>

Page 33: XboxAppDev 4. Web Apps on Xbox

<section> <div> <div id="A" class="btn">A</div> <div id="B" class="btn">B</div> </div> <div> <div id="C" class="btn">C</div> </div> <div> <div id="D" class="btn">D</div> <div id="E" class="btn">E</div> </div></section>

Page 34: XboxAppDev 4. Web Apps on Xbox

In your JS, just call:TVJS.DirectionalNavigation.focusableSelectors.push(".btn");

Page 35: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

Mouse mode is the default controller experience. Same as the Edge browser on Xbox where:• Mouse movement is via left thumbstick• Zoom In / Zoom Out via left / right triggers• Scrolling via right thumbstick• You get magnetism support

Mouse Mode

Page 36: XboxAppDev 4. Web Apps on Xbox

Demo: Mouse Mode

Page 37: XboxAppDev 4. Web Apps on Xbox

Integrating with the Platform

Page 38: XboxAppDev 4. Web Apps on Xbox

if (typeof Windows !== "undefined") {

// Windows specific code goes here

}

How to detect if you are in a UWP environment:

Page 39: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

This is what makes your web app really shine and take advantage of what the Xbox provides beyond the browser.

Page 40: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

1. SMTC Integration

2. Background Audio

Page 41: XboxAppDev 4. Web Apps on Xbox

Demo: Video App

Page 42: XboxAppDev 4. Web Apps on Xbox

System Media Transport Controls (SMTC) are the common play, pause, back, and forward buttons exposed through Windows 10.

SMTC Integration

<video id="mediaVideo" src="img/Westminster_high.mp4" controls></video>

Just add the controls attribute. There is some JS that needs to be added as well.

Page 43: XboxAppDev 4. Web Apps on Xbox

No user wants their music to cut out when an app is minimized or (occasionally) out of focus:

Background Audio

<video id="mediaVideo" src="myVideo.mp4" msAudioCategory="BackgroundCapableMedia" controls></video>

Add the msAudioCategory attribute to a media element with a value of BackgroundCapableMedia.

Page 44: XboxAppDev 4. Web Apps on Xbox
Page 45: XboxAppDev 4. Web Apps on Xbox

WebView

Page 46: XboxAppDev 4. Web Apps on Xbox

Think of it is as really fancy/turbocharged iframe that acts as a window for displaying HTML content.

WebView is used across UWP apps across the Windows Platform.

Page 47: XboxAppDev 4. Web Apps on Xbox

<!DOCTYPE html>

<html>

<head>

<title>Webview Example</title>

<link href="css/default.css" rel="stylesheet" />

</head>

<body>

<x-ms-webview id="webview" src="https://www.bing.com"></x-ms-

webview>

<script src="js/main.js"></script>

</body>

</html>

Page 48: XboxAppDev 4. Web Apps on Xbox

<!DOCTYPE html>

<html>

<head>

<title>WebView</title>

</head>

<body>

<script>

var webview = document.createElement("x-ms-webview");

webview.navigate("https://www.bing.com");

document.body.appendChild(webview);

</script>

</body>

</html>

Page 49: XboxAppDev 4. Web Apps on Xbox

Demo: WebView Focus Transitions

Page 50: XboxAppDev 4. Web Apps on Xbox

There is a whole lot you can do with the WebView control beyond just displaying HTML content.

Page 51: XboxAppDev 4. Web Apps on Xbox

What’s Next!

Page 52: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

The same under-the-hood components that power the Edge browser power the web experience you get in UWP apps.

Page 53: XboxAppDev 4. Web Apps on Xbox

Improvements to the Edge platform accrue to UWPs as well.

Page 55: XboxAppDev 4. Web Apps on Xbox

Summary

Page 56: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

If you know how to build a cool web app, then you know almost everything these is to build an app for the Xbox (or any other UWP device).

Page 57: XboxAppDev 4. Web Apps on Xbox

#xboxappdev

Keep in mind ways of progressively enhancing your app depending on the capabilities available on the device you are targeting.

Page 58: XboxAppDev 4. Web Apps on Xbox

If you have any questions, feel free to ping me via @kirupa or send e-mail to [email protected].

Page 59: XboxAppDev 4. Web Apps on Xbox