Search in sources :

Example 1 with PlaylistItemSnippet

use of com.google.api.services.youtube.model.PlaylistItemSnippet in project opencast by opencast.

the class YouTubeAPIVersion3ServiceImpl method addPlaylistItem.

@Override
public PlaylistItem addPlaylistItem(final String playlistId, final String videoId) throws IOException {
    // Resource type (video,playlist,channel) needs to be set along with resource id.
    final ResourceId resourceId = new ResourceId();
    resourceId.setKind("youtube#video");
    resourceId.setVideoId(videoId);
    // Set the required snippet properties.
    final PlaylistItemSnippet playlistItemSnippet = new PlaylistItemSnippet();
    playlistItemSnippet.setTitle("First video in the test playlist");
    playlistItemSnippet.setPlaylistId(playlistId);
    playlistItemSnippet.setResourceId(resourceId);
    // Create the playlist item.
    final PlaylistItem playlistItem = new PlaylistItem();
    playlistItem.setSnippet(playlistItemSnippet);
    // The first argument tells the API what to return when a successful insert has been executed.
    final YouTube.PlaylistItems.Insert playlistItemsInsertCommand = youTube.playlistItems().insert("snippet,contentDetails", playlistItem);
    return execute(playlistItemsInsertCommand);
}
Also used : ResourceId(com.google.api.services.youtube.model.ResourceId) PlaylistItemSnippet(com.google.api.services.youtube.model.PlaylistItemSnippet) PlaylistItem(com.google.api.services.youtube.model.PlaylistItem)

Aggregations

PlaylistItem (com.google.api.services.youtube.model.PlaylistItem)1 PlaylistItemSnippet (com.google.api.services.youtube.model.PlaylistItemSnippet)1 ResourceId (com.google.api.services.youtube.model.ResourceId)1