Documentation

Video Querying Guide

VKVideoStore is where it all starts

To access all videos in the library, we have a class called VKVideoStore that allows you to query all your videos.

To access anything in the video store you must have a session in place by calling VKAccount.current.startSession().

You must ensure the connection state is VKAccountState.connected. This can be checked through VKAccount.current.accountState.

Making a Query

To make a query you use the VKVideoStore.shared.getVideoPlaylist() or VKVideoStore.shared.getVideos() call. There you will be returned a VKVideoPlaylist or [VKVideoObject] in the completion block.

Queries are made using tags and metadata. Here are some example queries.

Get the playlist with all videos:

VKVideoStore.shared.getVideoPlaylist(withTags: [], withMetadata: [:]) { (playlist: VKVideoPlaylist?, error: Error?) in
    if (error != nil) {
        // Handle error
    }
    else {
        // Video results is contained in 'playlist'
    }
}

Get video playlist with tags only:

VKVideoStore.shared.getVideoPlaylist(withTags: ["birthday", "outdoor"], withMetadata: [:]) { (playlist: VKVideoPlaylist?, error: Error?) in
    if (error != nil) {
        // Handle error
    }
    else {
        // Video results is contained in 'playlist'
    }
}

Get video playlist with metadata only:

VKVideoStore.shared.getVideoPlaylist(withTags: [], withMetadata: ["group" : "private", "selected" : "true"]) { (playlist: VKVideoPlaylist?, error: Error?) in
    if (error != nil) {
        // Handle error
    }
    else {
        // Video results is contained in 'playlist'
    }
}

Get video playlist with metadata and tags:

VKVideoStore.shared.getVideoPlaylist(withTags: ["birthday", "outdoor"], withMetadata: ["group" : "private", "selected" : "true"]) { (playlist: VKVideoPlaylist?, error: Error?) in
    if (error != nil) {
        // Handle error
    }
    else {
        // Video results is contained in 'playlist'
    }
}

Get videos by ids:

VKVideoStore.shared.getVideos(ids: ["1a073e79-82d0-4d09-8640-44faa6ac0906", "5fba1709-5cd5-4fb3-9b77-7987d550f9f3"]) { (videos: [VKVideoObject]?, error: Error?) in
    if (error != nil) {
        // Handle error
    }
    else {
        // Video results is contained in 'videos'
    }
}

Delete Video

To delete video you can use VKVideoStore.shared.removeVideo method as here:

VKVideoStore.shared.removeVideo(id: "338d4ccd-f509-489a-93f1-bf6050fd0444") { (success: Bool, error: Error?) in
    if (error != nil) {
        // Handle error
    }
    else {
        // Video was deleted
    }
}

For more information about the framework, please head to the API Reference site.