iPhone Native Application

Technology
Media API
Required
Media API token
Edition
Express 499, Pro, Enterprise

This document describes an application we created using the Brightcove App SDK for iOS. If you'd like to learn more about the SDK, including the documentation package for you to download and use to start building iPhone apps, please read our Getting Started with the Brightcove App SDK for iOS article here.

You may already be familiar with the One Planet portal application described in an earlier article. This article is about a parallel application that is native to the iPhone and iPod Touch, as opposed to a web-based application launched through the Safari mobile browser. For simplicity's sake, we'll refer to the One Planet Native Sample Application as "One Planet".

You can also check out these other documents about the Brightcove App SDK for iOS:

Here is a look at One Planet:

 

OnePlanet Demo Video

 

We developed One Planet using the Brightcove App SDK for iOS and the Brightcove Media Read APIs. This SDK, which is currently in development, provides a framework that you will be able to use to create your own native iOS application to deliver Brightcove video to the iPhone, iPad, and other iOS devices. Read more about installing and using the Brightcove App SDK for iOS.

Installing, Building and Starting One Planet

There are two ways you can get started with One Planet on your device:

Using Xcode

Before you can install One Planet on your device through Xcode, you will need to request and receive a development certificate and provisioning profile. To do this, visit the iPhone Developer Program at the Apple Developer Connection.

Installation through Xcode assumes that you already have Xcode and the Apple iPhone SDK installed on your computer. Download the Brightcove App SDK for iOS, and open the BrightcoveDemo.Xcodeproj file. You can run One Planet either through your device, or through the Xcode iPhone Simulator. If you decide to install and run One Planet on your device, please make sure that the device is connnected to the Internet. Once you've chosen a target for installation, click Build & Go, and One Planet will build, install and start on the target.

Using the Apple Store and iTunes

One Planet is now available through the iTunes Store. After you download and install the application, select it from the screen on your device.

One Planet in Action

The best way to describe the behavior of One Planet is through a series of user scenarios, starting with application startup.

Startup and Menu views

When One Planet starts, the default view you will see is the Channels view. This view is populated by a call to PlaylistTableViewController.fetchAllPlaylists, which returns a BCItemCollection of Playlists to the screen, with a limit of 10 playlists.

When a channel is selected, a new VideoTableViewController is allocated and added to the navigation controller. To load the channel's videos, the VideoTableViewController makes a call to loadTableDataFromBrightcoveForPlaylist

- (void)loadTableDataFromBrightcoveForPlaylist {

// show a 'loading' indicator and then tear down

BrightcoveDemoAppDelegate *delegate = (BrightcoveDemoAppDelegate *)[[UIApplication sharedApplication] delegate];

BCMediaAPI *bc = delegate.bcServices;

NSError *err;

BCPlaylist *playlist = [bc findPlaylistById:self.playlistId videoFields:[NSArray arrayWithObjects:@"id", @"FLVURL", @"thumbnailURL", @"name", @"shortDescription", @"renditions", nil] playlistFields:[NSArray arrayWithObjects:@"name", @"videos", nil] customFields:nil error:&err];

if (!playlist) {
[ErrorHandlerService logMediaAPIError:err];
}

self.videos = playlist.videos;
self.title = playlist.name;
[self.tableView reloadData];
}

Contained in the BCPlaylist object is the list of videos.

Newest View

When a viewer selects the Newest Videos view, a VideoTableViewController is allocated and added to the navigation controller. The VideoTableViewController makes a call to initWithNibAndType, with the listType specified as RECENT_VIDEOS. In the initWithNibAndType method, a call is made to loadTableDataFromBrightcoveForAllVideos

- (void)loadTableDataFromBrightcoveForAllVideos {

//[self showLoaderScreen];
BrightcoveDemoAppDelegate *delegate = (BrightcoveDemoAppDelegate *)[[UIApplication sharedApplication] delegate];
BCMediaAPI *bc = delegate.bcServices;
BCSortOrderType sortOrder;
NSError *err;
BCItemCollection *videoCollection;

if (videoListType == POPULAR) {
sortOrder = BCSortByTypePlaysTrailingWeek;
}

else {
sortOrder = BCSortByTypeModifiedDate;
}

videoCollection = [bc findAllVideos:10 pageNumber:0 sortBy:sortOrder sortOrder:BCSortOrderTypeDESC getItemCount:NO videoFields:[NSArray arrayWithObjects:@"id", @"FLVURL", @"thumbnailURL", @"name", @"shortDescription", @"renditions", nil] customFields:nil error:&err];

if (!videoCollection) {
[ErrorHandlerService logMediaAPIError:err];
}

self.videos = videoCollection.items;
[self.tableView reloadData];
}

In loadTableDataFromBrightcoveForAllVideos, the sortBy parameter is set to BCSortByTypeModifiedDate, the sortOrder is set to DESC, and a call is made to BCMediaAPI.findAllVideos with these parameters. A BCItemCollection of videos is returned, with a limit of 10 videos.

Popular View

When you select the Popular Videos view, a VideoTableViewController is allocated and added to the navigation controller. The VideoTableViewController makes a call to initWithNibAndType, with the listType specified as POPULAR. In the initWithNibAndType method, a call is made to loadTableDataFromBrightcoveForAllVideos. In loadTableDataFromBrightcoveForAllVideos, the sortBy parameter is set to BCSortByTypePlaysTrailingWeek, the sortOrder is set to DESC, and a call is made to BCMediaAPI.findAllVideos with these parameters. A BCItemCollection of videos is returned, with a limit of 10 videos.

- (void)loadTableDataFromBrightcoveForAllVideos {

//[self showLoaderScreen];

BrightcoveDemoAppDelegate *delegate = (BrightcoveDemoAppDelegate *)
  [[UIApplication sharedApplication] delegate];
BCMediaAPI *bc = delegate.bcServices;
BCSortOrderType sortOrder;
NSError *err;
BCItemCollection *videoCollection;

if (videoListType == POPULAR) {
sortOrder = BCSortByTypePlaysTrailingWeek;
}

else {
sortOrder = BCSortByTypeModifiedDate;
}

videoCollection = [bc findAllVideos:10 pageNumber:0 sortBy:sortOrder
  sortOrder:BCSortOrderTypeDESC getItemCount:NO
  videoFields:[NSArray arrayWithObjects:@"id", @"FLVURL", @"thumbnailURL", @"name",
     @"shortDescription", @"renditions", nil] customFields:nil error:&err];

if (!videoCollection) {
[ErrorHandlerService logMediaAPIError:err];
}

self.videos = videoCollection.items;
[self.tableView reloadData];
}

Each row in the Channel, Newest and Popular views contains a video thumbnail in the left hand window, and on the right, the video title and a short description. These are populated in VideoTableViewController.tableView method. When a row is selected, the VideoPlayerService.playVideo method is called to begin playback of the video. The implementation will show a loader screen and then fade in the native video player once enough of the video bits have loaded.

BC Wall View

On switching the view to BC Wall, a BrightcoveWallViewController is allocated and added to the navigation controller. A call is made to the Brightcove Media API with the specified listType parameter (either POPULAR or NEWEST), returning a BCItemCollection of videos, with a limit of 60. With a maximum of 15 videos per page, the BC Wall view is 4 pages of video thumbnails.

- (id)initWithType:(videoList) pListType {
      [super init];
      listType = pListType;
      
      return self;
  }

The Player view

The major functions of the Player view, such as the scrubber and transport controls, are not part of the Brightcove App SDK for iOS, but are core components of the Cocoa Touch media player. However, the BCPlayer wrapper provides an interface to the Cocoa Touch media player, as well as the Related Videos and Sharing controls.

When a video is selected from a playlist, the VideoPlayerService's playVideo method is called, with a BCVideo as a parameter. This sets up the player and the the states of the Related Videos and Sharing controls.

Player View: Related/Popular Videos

An array of related videos is fetched by default when the player first opened. This array is accessed when the Related Videos control to the left of the transport controls is selected during playback, or when the video finishes playing. Selecting one of the videos from the view that opens calls the VideoPlayerService.playVideo method, with the selected BCVideo as the parameter.

Sharing

Selecting the sharing button in either the Player screen or the Related/Popular Videos view opens the sharing view, with Email and Twitter options.

Sharing by Email

Selecting the Email button sends an alert to the user that One Planet will close in order to open the device's email client.

Sharing by Twitter

Selecting the Twitter button calls the twitterTouchEvent method, which opens the Twitter view in the Player interface. The video is not paused during this process.

If you need help or have a question, please visit our forums. You can also follow the Brightcove iPhone SDK on Twitter: http://twitter.com/bciphonesdk.