iPhone Native Application

Product
Video Cloud
Applies to Roles
Developer
Version
Brightcove 5
Edition
Express 499, Pro, Enterprise

This document describes an application we created using version 2.1 of the Video Cloud 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 Getting Started with the Video Cloud App SDK for iOS.

Please download the One Planet for iPhone Source.

Please download the One Planet for iPad Source.

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 Video Cloud App SDK for iOS:

Here is a look at One Planet:

 

OnePlanet Demo Video

 

We developed One Planet using the Video Cloud App SDK for iOS and the Video Cloud Media Read APIs. This SDK provides a framework that you can use to create your own native iOS application to deliver Video Cloud video to the iPhone, iPad, and other iOS devices. Read more about installing and using the Video Cloud 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 Video Cloud 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 connected 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

The One Planet iPhone app, and iPad app are 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 lefthand 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 Video Cloud 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 Video Cloud App SDK for iOS, but are core components of the Cocoa Touch media player. However, the BCMoviePlayerController 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 video detail view is pushed into the UINavigationController. There you are presented the ability to play the video or share the video.

Sharing

Selecting the sharing button in video details view opens the sharing view, with Email and Twitter options.

Sharing by Email

Selecting the Email button opens the in app email view provided by Apple. You can also configure the sharing view to open the external app.

Sharing by Twitter

Selecting the Twitter button starts the OAuth login process and gives you the ability to tweet once logged in.

If you need help or have a question, please visit our forums. You can also follow the Video Cloud iPhone SDK on Twitter: http://twitter.com/bciphonesdk or register for updates and announcements by e-mail about our mobile SDKs.

Tags
apps, iOS, iPad, iPhone, iTunes