tvml apps on the apple tv

63
TVML apps on the !

Upload: matias-korhonen

Post on 12-Jan-2017

784 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: TVML apps on the Apple TV

TVML apps on the !

Page 2: TVML apps on the Apple TV

Hi, I’m Matt. I mostly build things on the web, but also for iOS and now tvOS. I work at Kisko Labs.

(and maybe for OS X in the near future)→ matiaskorhonen.fi

→ Twitter: @matiaskorhonen→ Blog: randomerrata.com

Page 3: TVML apps on the Apple TV
Page 4: TVML apps on the Apple TV

Kisko TV

Coming soon…

Page 5: TVML apps on the Apple TV

Hobby projects

Page 6: TVML apps on the Apple TV

Beer StylesThe 2015 and 2008 beer, cider, and mead style

guidelines from the Beer Judge Certification Program.The style guidelines describe what each style of

beer, cider, and mead should taste, look, and smell like.

beerstyles.co

Page 7: TVML apps on the Apple TV
Page 8: TVML apps on the Apple TV

Piranhas (for iOS)Save money by comparing book prices between

Amazon stores, the Book Depository, and Wordery. Available on iOS and the web.

piranhas.co

Page 9: TVML apps on the Apple TV
Page 10: TVML apps on the Apple TV

There’s a new Apple TV

You may have heard of it…

Page 11: TVML apps on the Apple TV

Developer KitsYou may have received an Apple

TV developer kit…

Page 12: TVML apps on the Apple TV

“Prior to Apple’s commercial release of Apple TV, you agree not to publicly write about, review, or

display the Apple TV Developer Kit.”— Apple TV dev kit NDA

Page 13: TVML apps on the Apple TV

WhoopsApple Bans iFixit Developer Account and Removes

App After Apple TV Teardown— MacRumors / iFixit blog1

1 macrumors.com/2015/09/30/apple-bans-ifixit-developer-account-apple-tv

Page 14: TVML apps on the Apple TV

Shipping now(ish)

Page 15: TVML apps on the Apple TV

Web stuff on the Apple TV

You may have heard that there’s no UIWebView or WKWebView on the

Apple TV.There isn’t.2

2 developer.apple.com/library/prerelease/tvos/releasenotes/General/tvOS90APIDiffs/

Page 16: TVML apps on the Apple TV

Regardless of this, there is an Apple sanctioned way to create apps using web tech

Page 17: TVML apps on the Apple TV

Not all kinds of apps, but apps nonetheless…

Page 20: TVML apps on the Apple TV

Looks pretty familiar…

Page 21: TVML apps on the Apple TV

You’ll need some native code//// AppDelegate.swift//

import UIKitimport TVMLKit

@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate, TVApplicationControllerDelegate {

var window: UIWindow? var appController: TVApplicationController? let baseURL = "http://localhost:8000"

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { window = UIWindow(frame: UIScreen.mainScreen().bounds)

let context = TVApplicationControllerContext() let javaScriptURL = NSURL(string: "\(baseURL)/javascripts/application.js")!

context.javaScriptApplicationURL = javaScriptURL context.launchOptions["BASEURL"] = baseURL

appController = TVApplicationController(context: context, window: window, delegate: self) return true }

}

Page 22: TVML apps on the Apple TV

Yeah, that’s it.Everything else is served from your server as XML

(TVML) or JavaScript (TVJS)

Could you put everything in the app bundle? Maybe.

Page 23: TVML apps on the Apple TV

TVML3

It’s XML<?xml version="1.0" encoding="UTF-8" ?><document> <alertTemplate> <title>Hello World!</title> <description>Or “hello HelsinkiOS” or whatever.</description> </alertTemplate></document>

3 https://developer.apple.com/library/prerelease/tvos/documentation/LanguagesUtilities/Conceptual/ATV_Template_Guide/index.html#//apple_ref/doc/uid/

TP40015064

Page 24: TVML apps on the Apple TV

TVJS4

It’s JavaScriptApp.onLaunch = function(options) { var alertDoc, alertString, parser; alertString = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<document>\n<alertTemplate>\n" + "<title>" + title + "</title>\n" + "<description>" + description + "</description>\n" + "</alertTemplate>\n</document>"; parser = new DOMParser; alertDoc = parser.parseFromString(alertString, "application/xml"); return navigationDocument.presentModal(alertDoc);};

4 https://developer.apple.com/library/prerelease/tvos/documentation/TVMLJS/Reference/TVJSFrameworkReference/index.html

Page 25: TVML apps on the Apple TV

CoffeeScriptBut at least nothing stops you from using

CoffeeScript if it makes you happier… It makes me happier.

App.onLaunch = (options) -> alertString = """<?xml version="1.0" encoding="UTF-8" ?> <document> <alertTemplate> <title>#{title}</title> <description>#{description}</description> </alertTemplate> </document> """ parser = new DOMParser alertDoc = parser.parseFromString(alertString, "application/xml") navigationDocument.presentModal(alertDoc)

Page 26: TVML apps on the Apple TV

There’s a DOM and XMLHttpRequestIt should feel pretty familiar to any web developer.

→ There is a document object→ There isn’t a window object

Page 27: TVML apps on the Apple TV

Can I use JS libraries?Yes. As long as they work with the subset of the

DOM/JavaScript APIs that tvOS implements.

Page 28: TVML apps on the Apple TV

Can I use jQuery?No, at least not out of the box.

For one thing it tries to call document.createElement, which doesn’t exist on tvOS.

Page 29: TVML apps on the Apple TV

InspectorYou can use the Safari developer

tools for debugging

Page 30: TVML apps on the Apple TV

It’s pretty limitedIf you’re not building an app that’s primarily a media

consumption app, it’s probably the wrong choice.

Page 32: TVML apps on the Apple TV

alertTemplate

Page 33: TVML apps on the Apple TV

alertTemplate<alertTemplate> <title>…</title> <description>…</description> <button> <text>…</text> </button> <text>…</text></alertTemplate>

Page 34: TVML apps on the Apple TV
Page 35: TVML apps on the Apple TV

catalogTemplate

Page 36: TVML apps on the Apple TV

catalogTemplate<catalogTemplate> <banner> <title>…</title> </banner> <list> <section> <listItemLockup> … </listItemLockup> </section> <section> <header> … </header> <listItemLockup> … </listItemLockup> </section> </list></catalogTemplate>

Page 37: TVML apps on the Apple TV
Page 38: TVML apps on the Apple TV

And a bunch of others

Page 39: TVML apps on the Apple TV
Page 40: TVML apps on the Apple TV
Page 41: TVML apps on the Apple TV

Media centricAll the templates are very much geared towards

media consumption…

Page 42: TVML apps on the Apple TV
Page 43: TVML apps on the Apple TV
Page 44: TVML apps on the Apple TV
Page 45: TVML apps on the Apple TV
Page 46: TVML apps on the Apple TV
Page 47: TVML apps on the Apple TV
Page 48: TVML apps on the Apple TV
Page 49: TVML apps on the Apple TV
Page 50: TVML apps on the Apple TV
Page 51: TVML apps on the Apple TV

!

Page 52: TVML apps on the Apple TV

Aside: divTemplateThere is a divTemplate

Page 53: TVML apps on the Apple TV

Aside: divTemplateIf you are crazy, I’m think you could try to build a

sort of terrible canvas with JavaScript and 2,073,600 (=1920×1080) divTemplate tags.

If you do this let me know how the Apple TV likes having ~2 million elements on screen!

Page 54: TVML apps on the Apple TV

StylesAnd there are limited options for styling the

templates

Page 55: TVML apps on the Apple TV

It its very essence, TVMLKit let you build limited Single Page Apps for tvOS. If you want to get a bunch of videos or images onto the Apple TV, this is a great,

low effort way to get that done.

Page 56: TVML apps on the Apple TV

Why is TVMLKit on the Apple TV but actual web views aren’t?

Page 57: TVML apps on the Apple TV

My pet theory→ To prevent terrible web player wrappers

→ An easy path onto tvOS→ It was already there

Page 58: TVML apps on the Apple TV

The really important news!

Page 59: TVML apps on the Apple TV

!"#$ ⬅ New emoji in iOS 9.1!

Page 60: TVML apps on the Apple TV

Questions?

Page 61: TVML apps on the Apple TV

Footnotes→ TVML tutorial: tinyurl.com/TVMLtutorial→ This presentation: tinyurl.com/TVMLapps

Page 62: TVML apps on the Apple TV

Further footnotes→ Beer Styles: free in the App Store

→ Piranhas: free in the App Store or the web→ Kisko TV: in the App Store soon

Page 63: TVML apps on the Apple TV

Links to all the things: matiaskorhonen.fi