Skip to content

Instantly share code, notes, and snippets.

@erikprice
Last active August 29, 2015 13:56
Show Gist options
  • Save erikprice/8962433 to your computer and use it in GitHub Desktop.
Save erikprice/8962433 to your computer and use it in GitHub Desktop.
//
// CPPViewController.m
// Catalog Playlist Playback
//
// Created by Robert Crooks on 10/2/13.
// Copyright (c) 2013 Brightcove. All rights reserved.
//
#import "CPPViewController.h"
// import the SDK master header and necessary RAC header
#import "BCOVPlayerSDK.h"
#import <ReactiveCocoa/RACEXTScope.h>
@implementation CPPViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.catalog = [[BCOVCatalogService alloc] initWithToken:@"nFCuXstvl910WWpPnCeFlDTNrpXA5mXOO9GPkuTCoLKRyYpPF1ikig.."];
self.controller = [[BCOVPlayerSDKManager sharedManager] createPlaybackControllerWithViewStrategy:nil];
self.controller.view.frame = self.view.bounds;
[self.view addSubview:self.controller.view];
//This is how you playback videos from a playlist
@weakify(self);
[self.catalog
findPlaylistWithPlaylistID:@"2149006311001" parameters:nil
completion:^(BCOVPlaylist *playlist, NSDictionary *jsonResponse, NSError *error) {
@strongify(self);
if(playlist){
self.controller.autoAdvance = YES;
[self.controller setVideos:playlist];
[self.controller play];
}
}];
NSLog(@"%@", self.catalog.requestFactory.defaultVideoFields);
//The above line will output
/*
(
renditions,
FLVFullLength,
videoStillURL,
name,
shortDescription,
referenceId,
id,
accountId,
customFields,
FLVURL,
cuePoints,
HLSURL
)
*/
// To ask for additional information - you can pass information to parameters
NSArray *fields = [self.catalog.requestFactory.defaultVideoFields arrayByAddingObject:@"tags"];
NSDictionary *videoFields = @{@"video_fields": [fields componentsJoinedByString:@","]};
[self.catalog findVideoWithReferenceID:@"lucy" parameters:videoFields completion:^(BCOVVideo *video, NSDictionary *jsonResponse, NSError *error) {
if(video){
//Getting properties from the video, these keys can be found in BCOVCatalogConstants.h
NSLog(@"Name: %@", video.properties[kBCOVCatalogJSONKeyName]);
NSLog(@"Description: %@", video.properties[kBCOVCatalogJSONKeyShortDescription]);
//Custom field:
NSLog(@"Tags: %@", video.properties[@"tags"]);
//Sources from the video can be accessed by the following:
[video.sources enumerateObjectsUsingBlock:^(BCOVSource *source, NSUInteger idx, BOOL *stop) {
NSLog(@"Source %i, Delivery Method: %@ URL: %@", idx, source.deliveryMethod, source.url);
//There are other values of importance that are stored in source properties
NSLog(@"Source %i, Properties %@", idx, source.properties);
}];
}
}];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment