Mobile SDK for tvOS

The Ooyala tvOS SDK provides basic playback for HLS and MP4 assets and supports FairPlay DRM and Ooyala analytics.

Note: React Native is not supported on tvOS.

Prerequisites

  • Before using Ooyala's tvOS SDK, download and set up the Ooyala mobile SDK for iOS (available at Ooyala Downloads) as described here: Mobile SDK for iOS.
  • The tvOS on which your app will run must be version 9 or higher.
What You Need

To get started with Ooyala’s tvOS SDK, download and open the OoyalaSDK-tvOS.zip and OoyalaSkinSDK-tvOS.zip files.

These two files supply the OoyalaTVSDK.framework and OoyalaTVSkinSDK.framework libraries.

Integrate the Ooyala tvOS SDK

Launch Xcode, open your Xcode project folder, and click your target.
  1. Copy OoyalaTVSDK.framework and OoyalaTVSkinSDK.framework into your library folder.
  2. Click Build Settings: select Supported Platforms > tvOS and Base SDK > Latest tvOS.
  3. Click Build Phases and expand Link Binary with Libraries. Ensure the OoyalaTVSDK.framework and OoyalaTVSkinSDK.framework are linked with your application here.
  4. Build and run your project on a tvOS simulator or an Apple TV device.
  5. (Optional) To verify that you have integrated the Ooyala tvOS SDK correctly, build and run the Ooyala tvOS sample app.

The Ooyala TVOSSampleApp demonstrates how you can integrate Apple's tvOS to run applications on Apple TV devices. To try out the sample app, visit https://github.com/ooyala/ios-sample-apps/tree/stable/PlaybackLab/TVOSSampleApp.

Customize the Ooyala tvOS Player UI

The Ooyala tvOS Player UI is unique and includes an open-source plugin that you can customize. To customize the UI:
  1. Fork https://github.com/ooyala/native-skin/tree/stable/sdk/tvOS.
  2. Remove the OoyalaTVSkinSDK.framework from your project.
  3. Add the OoyalaTVSkinSDK project that you forked into your master project.
  4. Modify OoyalaTVPlayerViewController to implement your custom UI features.
  5. (Optional) Submit a pull request.

Notes on Using the tvOS Core SDK

The Ooyala tvOS Core SDK is a direct port of the iOS Core SDK. The codebase for both SDKs is almost the same.

The tvOS Skin SDK provides a UI that was built from the ground-up specifically for the tvOS Platform. The iOS React-Native Skin SDK is not portable to tvOS because tvOS does not support react-native.

The Skin SDK is completely open-source in the native skin repo: https://github.com/ooyala/native-skin/tree/stable/sdk/tvOS. To make your own UI, fork the repo, use the Ooyala controls as a baseline, and extend the code however you like.

With the tvOS Core SDK, implementing the ViewController is significantly different from how it is done with other SDKs. Do not instantiating an OoyalaPlayer and create an OoyalaPlayerViewController as a child to the primary ViewController. Instead, extend the OOOoyalaTVPlayerViewController and segue to that new ViewController.

For example, the header file contains the following code:

#import <UIKit/UIKit.h>
#import <OoyalaTVSkinSDK/OOOoyalaTVPlayerViewController.h>
@interface FullscreenPlayerViewController : OOOoyalaTVPlayerViewController
@end
And the implementation file contains the following code:
self.pcode = self.option.pcode;
self.playerDomain = self.option.domain;
self.player = [[OOOoyalaPlayer alloc] initWithPcode:self.pcode domain:[[OOPlayerDomain alloc]
initWithString:self.playerDomain]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler:) name:nil
object:self.player];
[self.player setEmbedCode:self.option.embedCode];
[self.player play];

To see more code, you can look at these sample app references on github:

FullscreenPlayerViewController.h

FullscreenPlayerViewController.m

Interacting with the Sample App: To interact with an Apple TV, you must use an Apple TV Remote. In Xcode, when you build and run the app in Xcode, if you run the app in an Apple TV simulator on your Mac desktop, also use Hardware > Show Apple TV Remote.

To control the app, use the Apple TV Remote as follows:

  • To play or pause the video press the play/pause button, or hard-click (press) the touchpad until it depresses and clicks.

  • To seek forward or backward: soft-click the touchpad on either side of the remote.

  • While paused, to scrub forward or backward in the video, swipe left or right on the touchpad.

Avoid Using Inline Players: Although the sample app for tvOS includes one, we do not fully support "Inline Players" for the following reasons:

  • Inline players create user experience issues interacting with the player.
  • Apple recommends always displaying video in fullscreen.

Was this article helpful?