Skip to main content
Version: iOS SDK v1.0.11

Playlists

VideoKit's playlist support lets your app skip through a list of videos with minimal to no loading time.

We support the following types of playlists:

PlaylistDescription
VKPlaylistImplement your own playlist filter
VKCustomPlaylistLoads with a list of videos from our backend
VKUserPlaylistLoad videos based on a user identity
VKFilteredPlaylistFilter list of videos by metadata
VKTagsPlaylistLoad videos by associated tags

VKPlaylist

public class VKMyOwnPlaylist: VKPlaylist {

init(videos: [VKVideo]) {
self.videos = videos
}

}

VKCustomPlaylist

Retrieve videos with ids 1a073e79-82d0-4d09-8640-44faa6ac0906 and 5fba1709-5cd5-4fb3-9b77-7987d550f9f3 and add them to the playlist

VKVideos.shared.get(byVideoIds: ["1a073e79-82d0-4d09-8640-44faa6ac0906", "5fba1709-5cd5-4fb3-9b77-7987d550f9f3"]) { (response: VKVideosResponse?, error: Error?) in
if let videos = response?.videos {
let playlist = VKCustomPlaylist(videos: videos)
}
}

Retrieve videos with ids 1a073e79-82d0-4d09-8640-44faa6ac0906 and 5fba1709-5cd5-4fb3-9b77-7987d550f9f3 and let VKCustomPlaylist do the video fetching for you.

You can retrieve the videos using VKPlaylistDelegate.

let playlist = VKCustomPlaylist(videoIds: ["1a073e79-82d0-4d09-8640-44faa6ac0906", "5fba1709-5cd5-4fb3-9b77-7987d550f9f3"])
playlist.delegate = self
extension YourClass: VKPlaylistDelegate {
func loaded(videos: [VKVideo]) {
// videos loaded
}
}

Or alternatively through the VKPlaylistUpdated Notification

NotificationCenter.default.addObserver(forName: .VKPlaylistUpdated, object: self, queue: nil) { [weak self] (notification) in
if let newIndexes = notification.userInfo["newIndexes"] as? [Int] {
print("Updated playlist has \(newIndexes.count) videos.")
}
}

let playlist = VKCustomPlaylist(videoIds: ["1a073e79-82d0-4d09-8640-44faa6ac0906", "5fba1709-5cd5-4fb3-9b77-7987d550f9f3"])
extension YourClass: VKPlaylistDelegate {
func loaded(videos: [VKVideo]) {
// videos loaded
}
}

VKUserPlaylist

let playlist = VKUserPlaylist(withUserIdentity: "unique-user-id")

VKFilteredPlaylist

let filter = VKVideoFilter()
let playlist = VKFilteredPlaylist(withFilter: filter, sortOrder: .asc)

VKTagsPlaylist

let playlist = VKTagsPlaylist(withTags: ["music", "dancing"], sortOrder: .asc)