Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Playlist Write Examples

peter-majeed edited this page Jan 3, 2013 · 5 revisions

#Playlist Write calls All calls that are part of the Brightcove Playlist Write API are wrapped and available within the .NET-MAPI-Wrapper. You will find examples of some of the more common use cases below.

Important Note

API calls are subject to the whims of internet connectivity, and may throw an exception for any number of reasons:

  • The Brightcove API may be down or not functioning correctly.
  • Network connectivity may be lost between your application and Brightcove.
  • Invalid parameters passed to the API may result in an error message in the response JSON. The error message will be wrapped in a BrightcoveApiException and thrown so that it may be handled via normal .NET error handling mechanisms.

Although the examples shown here do not include try/catch blocks, in order to ensure that your app is as robust as possible make sure to try/catch all API calls.

See Also

See how to work with the BrightcoveApi object on the Getting Started page.

Examples

## Create a playlist ```c# // Instantiate an API object by using the provided factory BrightcoveApi api = BrightcoveApiFactory.CreateApi("my API read token", "my API write token");
BrightcovePlaylist playlist = new BrightcovePlaylist
{
    Name = "Lorem ipsum",
    ReferenceId = "Lorem-ipsum-dolor-sit",
    ShortDescription = "Lorem ipsum dolor sit amet, consectetur adipisicing elit",
    PlaylistType = PlaylistType.Explicit // a manual playlist
};
playlist.VideoIds.Add(10000000000);
playlist.VideoIds.Add(10000000001);
playlist.VideoIds.Add(10000000002);

// Get the id of the playlist as you create it.
long newId = api.CreatePlaylist(playlist);
// Fetch the details of the playlist, if necessary.
BrightcovePlaylist newPlaylist = api.FindPlaylistById(newId);

<a name="create-smart-playlist" />
## Create a smart playlist
```c#
    // Instantiate an API object by using the provided factory
    BrightcoveApi api = BrightcoveApiFactory.CreateApi("my API read token", "my API write token");

    // No need to add to the VideoIds collection. This
    // playlist is not explicit, so it is therefore "smart".
    BrightcovePlaylist playlist = new BrightcovePlaylist
    {
        Name = "Lorem ipsum",
        ReferenceId = "Lorem-ipsum-dolor-sit",
        ShortDescription = "Lorem ipsum dolor sit amet, consectetur adipisicing elit",
        PlaylistType = PlaylistType.Alphabetical, // a smart playlist
        FilterTags = new[] { "bird", "fish" },
        TagInclusionRule = TagInclusionRule.Or
    };

    // Get the id of the playlist as you create it.
    long newId = api.CreatePlaylist(playlist);
    // Fetch the details of the playlist, if necessary.
    BrightcovePlaylist newPlaylist = api.FindPlaylistById(newId);
## Update a playlist ```c# // Instantiate an API object by using the provided factory BrightcoveApi api = BrightcoveApiFactory.CreateApi("my API read token", "my API write token");
// Get the details of the playlist.
BrightcovePlaylist playlist = api.FindPlaylistById(9876543210);
playlist.Name = "Edited playlist";
playlist.ShortDescription = "Edited playlist description";

// Work with the returned playlist.
BrightcovePlaylist brightcovePlaylist = api.UpdatePlaylist(playlist);

<a name="delete-playlist" />
## Delete a playlist
```c#
    // Instantiate an API object by using the provided factory
    BrightcoveApi api = BrightcoveApiFactory.CreateApi("my API read token", "my API write token");

    // Deletes the playlist with the given id. If the cascade argument
    // is set to false, it will *not* delete the playlist if it appears
    // in any existing players.
    api.DeletePlaylist(9876543210, false);

See also

More Examples

Clone this wiki locally