Making apps for the Apple TV:
-What is the Apple TV?
-AirPlay
-Adding AirPlay support to iOS apps
-Testing AirPlay in the iOS simulator
-Design considerations
Video from NSScotland 2014 at: https://vimeo.com/album/3132071/video/111942376
Presented at NSScotland 2014 and LiDG November 2014
7. 512 MB of RAM
8 GB of flash memory to cache content
7
8. Apple TV gives you access to the
best 1080p HD content —
including blockbuster films, hit TV
programmes, live sport, your
music, photos, videos and more
— all on your high-definition TV.
You can even play content from
your iOS device or Mac on your
TV using AirPlay.
X
41. Second Screen
1. Check for an external screen at app startup
2. Register for notifications for screen state changes
3. Create a second window, link to a screen and display it.
34
42. Second Screen
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {!
//…!
!
NSInteger screenCount = [[UIScreen screens] count];!
if (screenCount > 1) {!
UIScreen *secondScreen = [[UIScreen screens] lastObject];!
[self setupSecondScreen:secondScreen];!
}!
//...!
}
1. Check for an external screen at app startup
35
43. Second Screen
// previous code!
[[NSNotificationCenter defaultCenter] addObserver:self !
selector:@selector(screenAdded:) !
name:UIScreenDidConnectNotification !
object:nil]; !
!
[[NSNotificationCenter defaultCenter] addObserver:self!
selector:@selector(screenRemoved:)!
name:UIScreenDidDisconnectNotification!
object:nil];!
//...
2. Register for notifications for screen state changes
36
44. Second Screen
2. Register for notifications for screen state changes
- (void)screenAdded:(NSNotification *)screenNotification {!
UIScreen *newScreen = [screenNotification object];!
[self setupSecondScreen:newScreen];!
} !
!
- (void)screenRemoved:(NSNotification *)screenNotification {!
if (self.secondWindow) {!
self.secondWindow.hidden = YES;!
self.secondWindow = nil;!
}!
}
37
45. Second Screen
3. Create a second window, link to a screen and display it
- (void)setupSecondScreen:(UIScreen *)newScreen {!
CGRect windowBounds = newScreen.bounds;!
if (!self.secondWindow) {!
self.secondWindow = [UIWindow alloc]
initWithFrame:windowBounds];!
self.secondWindow.screen = newScreen;!
//setup UI content and add as rootViewController!
self.secondWindow.hidden = NO;!
}!
}
38
46. Second Screen
Things to remember
1. Notifications will queue when you’re app is in the background
so always add observers in an app lifetime object like
AppDelegate.
2. To change the UIWindow attached to a UIScreen, hide the
window first as it’s possible but an expensive operation.
3. Your second screen has no access to orientation information
or notifications so use status bar orientation.
4. Use UIScreens availableModes to determine if a lower
resolution is available for graphically intensive content
39
47. Controller
Once you’ve setup a second screen and assigned
it a rootViewController, you can then change the
content on your main screen to be a controller
or other content.
*hands still not
included
40
48. Multiple Users
You can expand the experience to display content from multiple
users onto your second screen by using Game Center API’s,
or for non-game collaboration, the Multipeer Networking API’s
Game Center Bonjour
WWDC 2013 - Session 708WWDC 2013 - Session 506
41
61. "Think how much your life has changed,
and all the things around you that have
changed, and yet TV, when you go into
the living room to watch TV or wherever
it may be, it almost feels like you're
rewinding the clock and you've entered
a time capsule and you're going
backwards.”
-Tim Cook
54