About Playlists

About Playlists

Contents

Introduction

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.

Examples

addPlaylistItems

This example illustrates a call to addPlaylistItems:withCompletionHandler: API. This API call adds items to the playlist.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCAddPlaylistItemsAPIParams class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the addPlaylistItems:withCompletionHandler: method.
  5. Perform the addPlaylistItems:withCompletionHandler: API call using the code sample in this example.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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]);
    }

createPlaylist

This example illustrates a call to createPlaylist:withCompletionHandler: API. The result of this API call is creation of a new playlist.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCCreateplaylistAPIParams class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the createPlaylist:withCompletionHandler: method.
  5. Perform the createPlaylist:withCompletionHandler: API call using the code sample in this example.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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]);
    }

deletePlaylist

This example illustrates a call to deletePlaylist:withCompletionHandler: API. This API call deletes a playlists.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCDeletePlaylistAPIParams class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the deletePlaylist:withCompletionHandler: method.
  5. Perform the deletePlaylist:withCompletionHandler: API call using the code sample in this example.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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]);
    }

deletePlaylistItem

This example illustrates a call to deletePlaylistItem:withCompletionHandler: API. This API call deletes an item from a specified playlist.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCDeletePlaylistItemAPIParams class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the deletePlaylistItem:withCompletionHandler: method.
  5. Perform the deletePlaylistItem:withCompletionHandler: API call using the code sample in this example.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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]);
    }

editPlaylist

This example illustrates a call to editPlaylist:withCompletionHandler: API. This call allows you to edit a playlist.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCEditPlaylistAPIParams class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the editPlaylist:withCompletionHandler: method.
  5. Perform the editPlaylist:withCompletionHandler: API call using the code sample in this example.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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]);
    }

editPlaylistDefinition

This example illustrates a call to editPlaylistDefinition:withCompletionHandler: API. This API call allows you to edit a playlist’s definition.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCEditPlaylistDefinitionAPIParams class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the editPlaylistDefinition:withCompletionHandler: method.
  5. Perform the editPlaylistDefinition:withCompletionHandler: API call using the code sample in this example.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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]);
    }

getPlaylist

This example illustrates a call to getPlaylist:withCompletionHandler: API. This API call returns a playlist of music type.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCGetPlaylistAPIParams class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the getPlaylist:withCompletionHandler: method.
  5. Perform the getPlaylist:withCompletionHandler: API call using the code sample in this example.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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]);
    }

getPlaylistContent

This example illustrates a call to getPlaylistContent:withCompletionHandler: API. This API call retrieves the content of a playlist at the specified path.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCGetPlaylistContentAPIParams class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the getPlaylistContent:withCompletionHandler: method.
  5. Perform the getPlaylistContent:withCompletionHandler: API call using the code sample in this example.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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]);
    }

getPlaylistDefinition

This example illustrates a call to getPlaylistDefinition:withCompletionHandler: API. This API call retrieves the definition of the specified playlist.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCGetPlaylistDefinitionAPIParams class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the getPlaylistDefinition:withCompletionHandler: method.
  5. Perform the getPlaylistDefinition:withCompletionHandler: API call using the code sample in this example.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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]);
    }

getPlaylistItems

This example illustrates a call to getPlaylistItems:withCompletionHandler: API. This API call retrieves the information about all items in a specified playlist.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCGetPlaylistItemsAPIParams class and provide the required parameter. If the required parameter is not provided, the API call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the getPlaylistItems:withCompletionHandler: method.
  5. Perform the getPlaylistItems:withCompletionHandler: API call using the code sample in this example.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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.