The iOS SDK allows you to access Personal Cloud Storage account holder’s data to retrieve, create, edit, modify, and delete playlists. Supported types of playlists include image, music, video, and image-video playlists. The following examples provide detailed steps that describe how to use supported methods and include code samples to help you get started with playlists.
This example illustrates a call to addPlaylistItems:withCompletionHandler:
API. This API call adds items to the playlist.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCAddPlaylistItemsAPIParams
class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the addPlaylistItems:withCompletionHandler:
method.addPlaylistItems:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCAddPlaylistItemsAPIParams *params = [[PCAddPlaylistItemsAPIParams alloc] init];
params.playlistUID = @"playlist_ID"; //Unique ID related to a specific playlist. (required)
params.paths = @[@"path of items"]; // An array contains path of items. (required)
[[PCAPISDK sharedInstance] addPlaylistItems:params withCompletionHandler:^(NSArray *playlistItems, PCAPIQueryResponse *response)
{
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK:
NSLog(@"playlistItems contains list of items added in playlist");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
This example illustrates a call to createPlaylist:withCompletionHandler:
API. The result of this API call is creation of a new playlist.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCCreateplaylistAPIParams
class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the createPlaylist:withCompletionHandler:
method.createPlaylist:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCCreateplaylistAPIParams *params = [[PCCreateplaylistAPIParams alloc] init];
params.type = @"music"; //type is required to create playlist . (required)
params.name = @"Test Playlist"; //name is required to create playlist . (required)
[[PCAPISDK sharedInstance] createPlaylist:params withCompletionHandler:^(PCPlaylist *playlist, PCAPIQueryResponse *response){
switch (response.urlResponse.statusCode){
case PCAPIResponseCodeResourceCreated:
NSLog(@"Playlist is created with music type");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
This example illustrates a call to deletePlaylist:withCompletionHandler:
API. This API call deletes a playlists.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCDeletePlaylistAPIParams
class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the deletePlaylist:withCompletionHandler:
method.deletePlaylist:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCDeletePlaylistAPIParams *params = [[PCDeletePlaylistAPIParams alloc] init];
params.playlistUID = @"playlist_ID"; //Unique ID related to a specific playlist. (required)
[[PCAPISDK sharedInstance] deletePlaylist:params withCompletionHandler:^(PCAPIQueryResponse *response){
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK:
NSLog(@"Deleted the playlist");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
This example illustrates a call to deletePlaylistItem:withCompletionHandler:
API. This API call deletes an item from a specified playlist.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCDeletePlaylistItemAPIParams
class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the deletePlaylistItem:withCompletionHandler:
method.deletePlaylistItem:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCDeletePlaylistItemAPIParams* params = [[PCDeletePlaylistItemAPIParams alloc] init];
params.playlistUID = @"playlist_Uid"; //Unique ID related to a specific playlist. (required)
params.itemUID = @"item_Uid";// Unique ID related to a specific item in a playlist. (required)
[[PCAPISDK sharedInstance] deletePlaylistItem:params withCompletionHandler:^(PCAPIQueryResponse *response){
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK:
NSLog(@"deleted an item in a given playlist");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
This example illustrates a call to editPlaylist:withCompletionHandler:
API. This call allows you to edit a playlist.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCEditPlaylistAPIParams
class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the editPlaylist:withCompletionHandler:
method.editPlaylist:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCEditPlaylistAPIParams* params = [[PCEditPlaylistAPIParams alloc] init];
params.playlistUID = @"playlist_Uid"; //Unique ID related to a specific playlist. (required)
params.name = @"name"; //name is required to edit playlist. (required)
params.type = @"music"; //type is required to edit playlist. (required)
[[PCAPISDK sharedInstance] editPlaylist:params withCompletionHandler:^(PCPlaylist *playlist, PCAPIQueryResponse *response){
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK:
NSLog(@"playlist edited");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
This example illustrates a call to editPlaylistDefinition:withCompletionHandler:
API. This API call allows you to edit a playlist’s definition.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCEditPlaylistDefinitionAPIParams
class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the editPlaylistDefinition:withCompletionHandler:
method.editPlaylistDefinition:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCEditPlaylistDefinitionAPIParams* params = [[PCEditPlaylistDefinitionAPIParams alloc] init];
params.playlistUID = @"playlist_Uid"; //Unique ID related to a specific playlist. (required)
params.name = @"name"; //name is required to edit playlist definition. (required)
params.type = @"music"; //type is required to edit playlist definition. (required)
params.paths = @[@"path of items"]; // An array contains path of items.
[[PCAPISDK sharedInstance] editPlaylistDefinition:params withCompletionHandler:^(PCPlaylist *playlist, PCAPIQueryResponse *response){
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK:
NSLog(@"playlist definition edited");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
This example illustrates a call to getPlaylist:withCompletionHandler:
API. This API call returns a playlist of music type.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCGetPlaylistAPIParams
class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the getPlaylist:withCompletionHandler:
method.getPlaylist:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCGetPlaylistAPIParams *params = [[PCGetPlaylistAPIParams alloc] init];
params.type = @"music";
[[PCAPISDK sharedInstance] getPlaylist:params withCompletionHandler:^(NSArray *playlist, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK:
NSLog(@"Return list of playlist of music type");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
This example illustrates a call to getPlaylistContent:withCompletionHandler:
API. This API call retrieves the content of a playlist at the specified path.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCGetPlaylistContentAPIParams
class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the getPlaylistContent:withCompletionHandler:
method.getPlaylistContent:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCGetPlaylistContentAPIParams* params = [[PCGetPlaylistContentAPIParams alloc] init];
params.playlistUID = @"playlist_Uid"; //Unique ID related to a specific playlist. (required)
params.itemUID = @"item_Uid";// Unique ID related to a specific item in a playlist. (required)
[[PCAPISDK sharedInstance] getPlaylistContent:params withCompletionHandler:^(PCAPIQueryResponse *response)
{
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK:
NSLog(@"Retrieved the content of a playlist");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
This example illustrates a call to getPlaylistDefinition:withCompletionHandler:
API. This API call retrieves the definition of the specified playlist.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCGetPlaylistDefinitionAPIParams
class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the getPlaylistDefinition:withCompletionHandler:
method.getPlaylistDefinition:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCGetPlaylistDefinitionAPIParams *params = [[PCGetPlaylistDefinitionAPIParams alloc] init];
params.playlistUID = @"playlist_Uid"; //Unique ID related to a specific playlist. (required)
[[PCAPISDK sharedInstance] getPlaylistDefinition:params withCompletionHandler:^(PCPlaylist *playlist, PCAPIQueryResponse *response){
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK:
NSLog(@"retrieved user specific playlist definition");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
This example illustrates a call to getPlaylistItems:withCompletionHandler:
API. This API call retrieves the information about all items in a specified playlist.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCGetPlaylistItemsAPIParams
class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the getPlaylistItems:withCompletionHandler:
method.getPlaylistItems:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCGetPlaylistItemsAPIParams *params = [[PCGetPlaylistItemsAPIParams alloc] init];
params.playlistUID = @"playlist_Uid"; //Unique ID related to a specific playlist. (required)
[[PCAPISDK sharedInstance] getPlaylistItems:params withCompletionHandler:^(NSArray *playlistItems, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK:
NSLog(@"retrieved details of all the playlist's items for a given playlist.");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException *exception) {
NSLog(@"catching %@ reason %@", [exception name], [exception reason]);
}
Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.