Updating an Existing Application with the iOS Skin
You can use the new iOS skin to update an existing application. Below is a walkthrough that illustrates how to integrate the iOS skin into the BasicPlaybackSampleApp.
- If you have not already done so, download and unzip the latest
version of the Ooyala mobile SDK for iOS. Also download the Ooyala Skin SDK for iOS which contains a necessary framework.
Finally, clone the ios-sample-apps repository by entering the following
git clone https://github.com/ooyala/ios-sample-apps.git
- From the cloned ios-sample-apps directory, go into the BasicPlaybackSampleApp subdirectory. Open the BasicPlaybackSampleApp.xcodeproj file in XCode.
- Add libz.tbd, a zip compression library. To do this, in the project, go to the Build Phases tab. Under the Link Binary With Libraries section, press the + plus button. Search for and add libz.tbd.
- Add the OoyalaSkinSDK.framework framework. The easiest way to do this is by dragging the framework into a suitable folder in the lefthand column. Make sure that the "Copy items if needed" box is checked. If necessary, add the folder's path to the Framework Search Paths slot under Build Settings in the Search Paths Settings. To add a new framework search path, click on the slot, add a colon : (separated by spaces) after the existing paths, and then insert the new path.
- Go to the Build Settings tab. Under the Linking section, add -ObjC to the slot that says "Other Linker Flags".
- Drag the main.jsbundle file from the OoyalaSkinSDK-iOS directory into the BasicPlaybackSampleApp > Players directory structure on the lefthand column of the Xcode project. Make sure that the "Copy items if needed" box is checked.
- You can make your own skin configuration files. Alternately, there is a skin-config subdirectory in the OoyalaSkinSDK-iOS folder. From your skin configuration files, drag the en.json, es.json, zh.json, and skin.json files into the Players directory. Make sure that the "Copy items if needed" box is checked.
- In BasicPlaybackSampleApp > Players > BasicSimplePlaybackViewController.m, change #import <OoyalaSDK/OOOoyalaPlayerViewController.h> to #import <OoyalaSkinSDK/OOSkinViewController.h>.
- Add #import <OoyalaSDK/OODiscoveryOptions.h> and #import <OoyalaSkinSDK/OOSkinOptions.h> to the list of imports.
- In the same file, replace all instances of OOOoyalaPlayerViewController with OOSkinViewController. This can be done by pressing CMD + F and performing find and replace.
Since OOSkinViewController needs more information than just a player to be
initialized, replace the line
self.ooyalaPlayerViewController = [[OOSkinViewController alloc] initWithPlayer:player];in the -(void) viewDidLoad method with
OODiscoveryOptions *discoveryOptions = [[OODiscoveryOptions alloc] initWithType:OODiscoveryTypePopular limit:10 timeout:60]; NSURL *jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; OOSkinOptions *skinOptions = [[OOSkinOptions alloc] initWithDiscoveryOptions:discoveryOptions jsCodeLocation:jsCodeLocation configFileName:@"skin" overrideConfigs:nil]; self.ooyalaPlayerViewController = [[OOSkinViewController alloc] initWithPlayer:player skinOptions:skinOptions parent:self.playerView launchOptions:nil];
- Drag the Fonts folder inside of the OoyalaSkinSDK-iOS directory into the root of the BasicPlaybackSampleApp XCode project. Make sure that the "Copy items if needed" box is checked. Also make sure that it is being copied as a group (not just a folder reference).
- Open Supporting Files > Info.plist. Press the + plus button by the Information Property List slot to add a new field. Add a field with the key 'Fonts provided by application' (this can be found in the drop-down menu). Set the array elements to be the ttf file names inside the Fonts folder (i.e., alice.ttf and fontawesome-webfont.ttf).
- Press the PLAY button to build and run the app.
To summarize, the following is the list of requirements for Ooyala Skin SDK to work in your application:
- Ooyala Skin SDK
- Should be linked.
- SDK version in the skin package's VERSION file should match the VERSION file in the Ooyala SDK.
- Should be bundled.
- Should be part of Info.plist.
- Localization Files (en.json, zh.json, etc.), skin-config.json, and main.jsbundle should be bundled.
- Objective-C code should use the OOSkinViewController, and it should use main.jsbundle as the jsCodeLocation.
- Other Linker Flags should be set to -ObjC.