A Closer Look at the iOS Sample App and Integrations

A closer look at the source code of the sample app highlights the touch points you need focus on to build your own app:
  • The Imports
  • ViewController Implementation, with Ad Manager
  • The Constants
  • View Setup and OOFreeWheelManager Initialization
  • Set FreeWheel Ad Parameters
  • Play the Video

To begin, open the FreeWheelSampleApp/ViewController.m file.

The Header and Library Files

For your Xcode project Build Phase, be sure to include the following in the Link Binaries With Libraries (click Add Other...):
Freewheel Headers
  • OoyalaFreeWheelSDK-iOS/libOoyalaFreeWheel.a
  • From the baseline Ooyala Mobile SDK, the libOoyalaSDK.a library. (For your convenience, this is also included in the FreeWheel sample app directory.)
  • The AdManager.framework folder that you've downloaded from the FreeWheel website
  • The following frameworks (unless you already have them in your project). To add these, select them from the list of Xcode frameworks:
    • libxml2.dylib
    • UIKit.framework
    • CoreGraphics.framework
    • QuartzCore.framework
    • MediaPlayer.framework
    • CoreLocation.framework
    • MessageUI.framework
    • EventKit.framework
    • CoreMedia.framework
    • AVFoundation.framework
    • AdSupport.framework (optional)

To your Xcode project itself, add Ooyala's the OoyalaFreeWheelSDK-iOS/FreeWheelHeaders folder.

The Imports

The first three import statements pull in header definitions from the baseline Ooyala Mobile SDK.

The fourth import pulls in the Ooyala FreeWheel Manager definitions.

#import <OoyalaSDK/ViewController.h>
#import <OoyalaSDK/OOOoyalaPlayerViewController.h>
#import <OoyalaSDK/OOOoyalaPlayer.h>
#import <OoyalaSDK/OOFreeWheelManager.h>

ViewController Implementation, with Ad Manager

These lines define the ViewController implementation. Notice the definition of the fwAdManager property as an OOFreeWheelManager-type interface.
@interface ViewController ()
@property (nonatomic, strong) OOOoyalaPlayerViewController *ooyalaPlayerViewController;
@property (nonatomic, strong) OOFreeWheelManager *fwAdManager;

@implementation ViewController

@synthesize ooyalaPlayerViewController;           
For reference documentation about the OOFreeWheelManager, see the OoyalaFreeWheelSDK-iOS/Documentation subdirectory.

The Constants

Whereas the sample app defines constants PCODE, EMBEDCODE, and PLAYERDOMAIN (see See the FreeWheel Sample App in Action on iOS), you probably want to define variables, especially for the EMBEDCODE constant (asset ID or content ID).

View Setup and OOFreeWheelManager Initialization

In the sample app, the view is setup and the fwAdManager object is initialized as an OOFreeWheelManager:

- (void)viewDidLoad {
  [super viewDidLoad];
	ooyalaPlayerViewController = [[OOOoyalaPlayerViewController alloc] initWithPcode:PCODE domain:[[OOPlayerDomain alloc]

  //Setup video view
  [ooyalaPlayerViewController.view setFrame:self.videoView.bounds];
  [self addChildViewController:ooyalaPlayerViewController];
  [self.videoView addSubview:ooyalaPlayerViewController.view];
  //Setup FreeWheel
  self.fwAdManager = [[OOFreeWheelManager alloc] initWithOoyalaPlayerViewController:ooyalaPlayerViewController];    

Set FreeWheel Ad Parameters

To set the ad parameters you need, change the values of the parameters included in the app. First, after the ooyalaPlayerView controller has been initialized (in the previous step) but before attempting to play the video, create an NSMutableDictionary named fwParameters; then set the desired parameter values to your own settings (replacing the sample values shown below).

The parameters highlighted below must be set in the app itself; the others can be set as explained in Essential Parameters and FreeWheel OPF Module Ad Set.

//Set FreeWheel parameters. Note that these are optional, and override configurations set in Backlot or in Ooyala internals
    NSMutableDictionary *fwParameters = [[NSMutableDictionary alloc] init];

  [fwParameters setObject:@"90750" forKey:@"fw_ios_mrm_network_id"];
  [fwParameters setObject:@"http://demo.v.fwmrm.net/" forKey:@"fw_ios_ad_server"];
  [fwParameters setObject:@"90750:ooyala_ios" forKey:@"fw_ios_player_profile"];
  [fwParameters setObject:@"ooyala_test_site_section" forKey:@"fw_ios_site_section_id"];
  [fwParameters setObject:@"ooyala_test_video_with_bvi_cuepoints" forKey:@"fw_ios_video_asset_id"];
  [fwParameters setObject:@"channel=TEST;subchannel=TEST;section=TEST;mode=online;
   player=ooyala;beta=n" forKey:@"FRMSegment"];

  [self.fwAdManager overrideFreeWheelParameters:fwParameters];

Playing the Video

Finally, on the following lines, the setEmbedCode method is from the baseline Ooyala Mobile SDK. These lines invokes the Ooyala player with the desired video identifier. Use a variable for the identifier (other than EMBEDCODE constant) in your app.
[ooyalaPlayerViewController.player setEmbedCode:EMBEDCODE];
[ooyalaPlayerViewController.player play];

해당 내용이 도움 되었습니까?