Skip to main content

Cloud Bookmarks

Bookmarks is a personalization library that provides cloud bookmarking services to enable Continue Watching / Continue Listening experiences.

The library helps persist last watched position for VOD content and provides APIs to retrieve, update, and delete bookmark positions.

[!IMPORTANT] Bookmarks are not applicable for Live playback. They are also not intended for promo/ad playback.

[!NOTE] Playing downloaded content without a network? See Offline bookmarks to save progress on the device and sync it to the cloud when the device is back online. The same flow is summarized in Download To Go.

Automatic enforcement with BookmarksManager​

BookmarksManager can automate bookmark updates using player state/progress callbacks.

Create BookmarkSessionConfiguration​

BookmarkSessionConfiguration defines sync and deletion behavior.

PropertyTypeDefaultDescription
endPointStringN/ABookmarks microservice endpoint URL.
bookmarkSyncIntervalTimeInterval60000Sync interval in milliseconds.
bookmarkThresholdPercentageDouble?0.95Fully-watched threshold as percentage factor.
thresholdPlaybackPositionMsTimeInterval?nilAbsolute position threshold in milliseconds.
minWatchedPositionMsTimeInterval?nilPlayback position in milliseconds the playhead must reach before writing/deleting bookmarks.
let config = FLBookmarksFactory.bookmarkSessionConfiguration(
endPoint: bookmarkEndPointURL,
bookmarkSyncInterval: 15_000,
bookmarkThresholdPercentage: 0.98,
thresholdPlaybackPositionMs: 1_800_000,
minWatchedPositionMs: 120_000
)

NOTE: minWatchedPositionMs defines an optional playback position (in milliseconds) the playhead must reach during a session before any bookmark is written or deleted. Once reached (via normal playback or scrubbing forward), the gate remains open for the rest of the session so scrubbing back below this position continues to update bookmarks. If not specified (nil), bookmarks are written from the first sync.

Create BookmarkAttributes​

Use BookmarkAttributes to provide content metadata for manager-driven updates. The structure depends on the content type.

Normal content (movie / standalone VOD)​

For standalone VOD content, provide only itemId, offset, and optionally contentType. Leave other optional fields as nil.

Per Personalization API, request body expects: itemId, offset

let normalAttributes = BookmarkAttributes(
itemId: "movie-123",
seasonId: nil,
episodeId: nil,
videoId: nil,
offset: 120_000, // milliseconds
mode: nil,
seasonNumber: nil,
episodeNumber: nil,
contentType: "movie"
)

Series / episodic content​

For episodic content, provide itemId, offset, seasonId, episodeId, mode: .series, and optionally season/episode numbers and content type.

Per Personalization API, request body expects: itemId, offset, seasonId, episodeId, mode: "series" (or "episode")

let seriesAttributes = BookmarkAttributes(
itemId: "series-content-id",
seasonId: "season-1-id",
episodeId: "episode-3-id",
videoId: nil,
offset: 120_000, // milliseconds
mode: .series,
seasonNumber: 1,
episodeNumber: 4,
contentType: "tvepisode"
)

Playlist content​

For playlist content, provide itemId (playlist ID), videoId (video in the playlist), offset, and mode: .playlist.

Per Personalization API, request body expects: itemId, offset, videoId, mode: "playlist"

let playlistAttributes = BookmarkAttributes(
itemId: "playlist-id",
seasonId: nil,
episodeId: nil,
videoId: "video-in-playlist-id",
offset: 120_000, // milliseconds
mode: .playlist,
seasonNumber: nil,
episodeNumber: nil,
contentType: nil
)

Create BookmarksManager​

  1. Always Prefer the bookmarkAttributes overload (the itemId overload is deprecated).
let bookmarksManager = FLBookmarksFactory.bookmarksManager(
configuration: config,
bookmarkAttributes: attributes,
authorizer: platformAuthorizer,
httpClient: FLFoundationFactory.httpClient() // optional
)
  1. If your app already created a BookmarkService, you can construct manager with the bookmarkService overload as well. If you use this to create bookmarkManager, refer final section of this doc to find manual bookmark manager creation. Do not prefer this, always prefer the above bookmarksManager creation unless its absolutely necessary.
let bookmarkService = FLBookmarksFactory.bookmarkService(
endPoint: bookmarkEndPointURL,
authorizer: platformAuthorizer
)

let bookmarksManager = FLBookmarksFactory.bookmarksManager(
configuration: config,
bookmarkAttributes: attributes,
bookmarkService: bookmarkService
)

Hook manager callbacks into your player/composable player flow:

composablePlayer.addStateChangeBlock(bookmarksManager.processPlaybackStateChange)
composablePlayer.addHeartBeatBlock(bookmarksManager.processPlaybackProgress)

BookmarkService​

BookmarkService declares APIs to record, remove, and retrieve bookmark positions. Because bookmark calls are authorized network calls, provide a PlatformAuthorizer when creating the service.

import FLBookmarks
import FLFoundation
import FLPlatformCore

let bookmarkEndPointURL = "https://example.com/" // include trailing slash

let bookmarkService: BookmarkService = FLBookmarksFactory.bookmarkService(
endPoint: bookmarkEndPointURL,
httpClient: FLFoundationFactory.httpClient(), // optional
authorizer: platformAuthorizer
)

Retrieve last watched position​

Applications usually fetch bookmark position before playback starts (for example, content details page, continue watching rails).

Response model​

All retrieve APIs return one or more BookmarkRecord values.

FieldTypeDescription
itemIdStringUnique identifier of the content item.
offsetTimeIntervalLast watched position in milliseconds.
updatedTimestampTimeInterval?Server timestamp when bookmark was last updated.
seasonIdString?Season identifier (episodic content).
episodeIdString?Episode identifier (episodic content).
videoIdString?Video identifier (playlist use cases).
modeMode?Bookmark mode (.series, .episode, .playlist).
seasonNumberInt?Season number (episodic content).
episodeNumberInt?Episode number in season (episodic content).
contentTypeString?Content type metadata, when available.
playlistBookmarks[PlaylistBookmarkRecord]?Per-video bookmarks for playlist content.

PlaylistBookmarkRecord represents bookmark data for an individual video inside a playlist.

FieldTypeDescription
videoIdStringUnique identifier of the video in the playlist.
offsetTimeIntervalLast watched position for this video in milliseconds.
playlistIdStringIdentifier of the parent playlist.
updatedTimestampTimeIntervalServer timestamp when this video bookmark was updated.

Singular content​

Use getBookmark(itemId:completion:) to fetch bookmark for one content item.

let contentId = "1234-5678-90ABC" 

bookmarkService.getBookmark(itemId: contentId) { result in
switch result {
case .success(let record):
let itemId = record.itemId
let offset = record.offset
let contentType = record.contentType
let seasonId = record.seasonId
let episodeId = record.episodeId
let seasonNumber = record.seasonNumber
let episodeNumber = record.episodeNumber
let videoId = record.videoId
let mode = record.mode
let timestamp = record.updatedTimestamp
let playlistBookmarks = record.playlistBookmarks
print(itemId, offset, contentType ?? "")

case .failure(let error):
print("getBookmark failed: \(error)")
}
}

Episodic content (series)​

Use getSeriesBookmarks(seriesIdentifier:pageNumber:pageSize:sortBy:sortOrder:completion:).

let seriesId = "098-765-4321"

bookmarkService.getSeriesBookmarks(
seriesIdentifier: seriesId,
pageNumber: 1,
pageSize: 10,
sortBy: .timestamp,
sortOrder: .descending
) { result in
switch result {
case .success(let records):
records.forEach { record in
print(record.itemId, record.offset, record.episodeId ?? "")
}

case .failure(let error):
print("getSeriesBookmarks failed: \(error)")
}
}

Playlist content​

Use getPlaylistBookmarks(playlistIdentifier:pageNumber:pageSize:sortBy:sortOrder:completion:).

let playlistId = "098-765-4321"

bookmarkService.getPlaylistBookmarks(
playlistIdentifier: playlistId,
pageNumber: 1,
pageSize: 10,
sortBy: .timestamp,
sortOrder: .descending
) { result in
switch result {
case .success(let records):
records.forEach { record in
print(record.itemId, record.offset, record.videoId, record.updatedTimestamp)
}

case .failure(let error):
print("getPlaylistBookmarks failed: \(error)")
}
}

Current user bookmarks​

Use getBookmarks(pageNumber:pageSize:sortBy:sortOrder:completion:) to fetch incompletely watched bookmarks for the current user.

bookmarkService.getBookmarks(
pageNumber: 1,
pageSize: 10,
sortBy: .timestamp,
sortOrder: .descending
) { result in
switch result {
case .success(let records):
records.forEach { record in
print(record.itemId, record.offset)
}

case .failure(let error):
print("getBookmarks failed: \(error)")
}
}

Queue-based bookmarking​

For queue playback, use the queue-capable bookmarksManager overload with a MediaPlaylistItemTransitionCallback implementation that returns AssetBookmarkConfiguration for each transition.

Usage​

1. Implement MediaPlaylistItemTransitionCallback​

Your client code implements MediaPlaylistItemTransitionCallback to provide bookmark configuration for each item:

class MyPlayerViewController: MediaPlaylistItemTransitionCallback {
func onMediaPlaylistItemTransition(for item: MediaPlaylistItem) -> AssetBookmarkConfiguration? {
// Return configuration for the item, or nil to skip bookmarking
}
}

2. Create QueueBookmarksManager​

let configuration = FLBookmarksFactory.bookmarkSessionConfiguration(
endPoint: endPoint,
bookmarkSyncInterval: 5000,
bookmarkThresholdPercentage: 0.95
)

// Initial bookmark attributes (will be updated on transitions)
let initialAttributes = BookmarkAttributes(
itemId: "initial-id",
seasonId: nil,
episodeId: nil,
videoId: nil,
mode: nil,
offset: 120_000, // Eg: 2 minutes in milliseconds
seasonNumber: nil,
episodeNumber: nil,
contentType: ""
)

// Create queue bookmark manager with configuration provider
let queueBookmarksManager = FLBookmarksFactory.bookmarksManager(
configuration: configuration,
bookmarkAttributes: initialAttributes,
bookmarkService: bookmarkService,
configurationCallback: self // implements MediaPlaylistItemTransitionCallback
)

3. Integrate with Player​

// Add state change and heartbeat blocks
player.addStateChangeBlock(block: queueBookmarksManager.processPlaybackStateChange)
player.addHeartBeatBlock(block: queueBookmarksManager.processPlaybackProgress)

4. Restoring Playback from Bookmark​

Each item's bookmark is stored separately using existing bookmark APIs:

// Get bookmark for a specific item
bookmarkService.getBookmark(itemId: lastPlayedItemId) { result in
switch result {
case .success(let record):
// Restore playback from saved position
let startOffset = record.offset / 1000 // Convert ms to seconds
player.seek(to: startOffset)

case .failure:
// No bookmark exists, start from beginning
break
}
}

Offline bookmarks​

Cloud bookmarks need a network connection. With offline bookmarks, users can watch downloaded content without a connection, resume where they stopped, and have that progress synced to the cloud automatically once the device is back online.

This is opt-in. Apps that do not use it keep the current cloud bookmark behavior. It applies to VOD content only.

important

Offline bookmarking and downloadsBookmarkManager are designed specifically for downloaded content played from local device storage. For standard online streaming playback, continue to use bookmarksManager and BookmarkService.

What users get​

ScenarioResult
Start a download offlineResumes from the last position played on the device.
Lose the network during playbackPlayback continues, progress is kept.
Network returnsProgress is synced to the cloud automatically.
Close the player offline, return to the app minutes or hours laterThe last played position is synced to the cloud.
App is force-quit while offlineThe position is still available on next launch and synced then.
Start onlineResumes from the latest position, even if an offline position is not yet synced.

Changes needed in your app​

  • Register once the user and profile are known, using the same PlatformAuthorizer you use for cloud bookmarks.
  • Read the saved position before starting downloaded playback.
  • Create the bookmarks manager with the offline overload.
  • Clean up when the user signs out or switches profile.

[!IMPORTANT] Your UserAuthorizationDelegate must be able to return a token or an error, because progress can be synced while the user is not on a login screen.

Step 1: Register the current session​

Register after the session is restored on launch, and again after login or profile activation. Use an ownerKey that identifies both the user and profile, so profiles never see each other's progress. Keep the returned handle.

If the app launches offline without a PlatformAuthorizer, pass nil for authorizer and call setPlatformAuthorizer(_:) once online to sync locally stored progress.

import FLBookmarks
import FLPlatformCore

let offlineBookmarks = FLBookmarksFactory.registerOfflineBookmarkSynchronizer(
ownerKey: "\(userId)-\(profileId)",
authorizer: platformAuthorizer, // Optional: pass nil if offline at launch
httpClient: FLFoundationFactory.httpClient(), // Optional: defaults to FLFoundationFactory.httpClient()
maxSyncedRowsPerOwner: 500 // Optional: defaults to 500. Minimum enforced is 500; pass > 500 for a larger cap.
)

// If launched offline without an authorizer, set it once online to sync stored bookmarks:
offlineBookmarks.setPlatformAuthorizer(platformAuthorizer)

Step 2: Resume from the saved position​

Before creating the player for a downloaded item, read its saved position from local storage. getBookmark supports standalone movies (itemId), TV episodes (itemId + episodeId), and playlist videos (itemId + videoId). Use offsetInSeconds with .initialPlaybackTime.

let bookmark = await offlineBookmarks.getBookmark(
itemId: contentId,
episodeId: episodeId, // Optional: series episode identifier
videoId: videoId // Optional: playlist video identifier
)

var preferences: [PlayerPreference] = []
if let bookmark {
preferences.append(.initialPlaybackTime(time: bookmark.offsetInSeconds))
}
player.set(preferences: preferences)

For a downloads list with progress indicators, read several items at once:

let bookmarks = await offlineBookmarks.getBookmarks(itemIds: downloadedContentIds)

OfflineBookmark properties​

getBookmark and getBookmarks return OfflineBookmark instances conforming to Sendable:

PropertyTypeDescription
itemIdStringUnique content, series, or playlist identifier.
offsetTimeIntervalPlayback position in milliseconds (same unit as BookmarkRecord.offset).
offsetInSecondsTimeIntervalPlayback position in seconds, ready for .initialPlaybackTime(time:).
isSyncedBoolfalse while pending server sync; true once confirmed by the server.
updatedAtDateLocal device timestamp of when the bookmark was last written.
episodeIdString?Episodic series episode identifier, if applicable.
videoIdString?Playlist video identifier, if applicable.

Step 3: Record progress during playback​

important

downloadsBookmarkManager is designed specifically for downloaded content (played using the download task's local AVURLAsset). It persists progress directly to local device storage before cloud replay, ensuring playback positions are saved even without an internet connection. For online streaming playback, continue using bookmarksManager.

Create the manager with the offlineSynchronizer overload instead of the authorizer or bookmarkService overloads. The configuration and BookmarkAttributes are the same as for cloud bookmarks.

let bookmarksManager = FLBookmarksFactory.downloadsBookmarkManager(
configuration: config,
bookmarkAttributes: attributes,
offlineSynchronizer: offlineBookmarks
)

player.addStateChangeBlock(bookmarksManager.processPlaybackStateChange)
player.addHeartBeatBlock(bookmarksManager.processPlaybackProgress)

For queue-based playback, use the overload with configurationCallback: and pass the same offlineSynchronizer.

[!NOTE] The itemId in BookmarkAttributes must match the content id of the downloaded item, otherwise its progress cannot be found.

Step 4: Handle sign-out, profile changes, and deleted downloads​

Manage the synchronizer lifecycle and local bookmark storage during account switches, deletions, and download purges:

EventWhat to call
Launch or loginRegister after the session is restored.
Credentials recover after a sign-in or token failureofflineBookmarks.requestSync()
Switch to another profileofflineBookmarks.unregister() before changing credentials, then register the new profile.
Remove a profiletry await offlineBookmarks.clear(userId: userId, profileId: profileId) before changing credentials.
Full app data wipe / Complete sign-outtry await offlineBookmarks.clear()

After unregister() or clear(), create new managers following the next registration.

Calling clear() with no arguments permanently deletes all offline bookmark records across all users and profiles on the device. When removing a single profile, always call the scoped overload clear(userId:profileId:) to avoid erasing other profiles' bookmarks.

API reference​

Use these FLBookmarksFactory and OfflineBookmarkSynchronizer APIs for offline bookmarking:

APIDescription
FLBookmarksFactory.registerOfflineBookmarkSynchronizer(ownerKey:authorizer:)Enables offline bookmarks for a user and profile. Returns an OfflineBookmarkSynchronizer.
FLBookmarksFactory.downloadsBookmarkManager(configuration:bookmarkAttributes:offlineSynchronizer:)Manager for a single item.
FLBookmarksFactory.downloadsBookmarkManager(configuration:bookmarkAttributes:offlineSynchronizer:configurationCallback:)Manager for queue/playlist playback.
getBookmark(itemId:episodeId:)Saved OfflineBookmark for an item, or nil.
getBookmarks(itemIds:)Saved bookmarks keyed by item id.
unregister()Stops offline bookmarks for this handle. Saved progress is kept.
removeBookmark(itemId:episodeId:)Permanently removes local bookmark records when a download is purged/deleted from disk.
clear(userId:profileId:)Deletes local bookmarks for a specific profile (or all profiles for a user when profileId is omitted).
clear()Deletes all local bookmark records in the store across all users and profiles.
requestSync()Sends unsynced progress now.

Test your integration​

Downloads need a physical device. Use airplane mode to simulate network changes.

  1. Download a title, play it online for about 30 seconds, then close the player.
  2. Turn on airplane mode, play the download, stop at a different position and close the player.
  3. Play it again, still offline. It should resume from the position of step 2.
  4. Turn airplane mode off and open the app. The cloud bookmark should now show the position of step 2.
  5. Repeat step 2, force-quit the app, then relaunch while online. The latest position should reach the cloud.
  6. Sign in with another profile. The first profile's progress must not appear.
Manual enforcement with BookmarkService

Maintaining bookmark positions can also be manually enforced by calling BookmarkService APIs directly when the application needs explicit control over when bookmarks are recorded or removed.

Applications can directly call service APIs to upsert or remove bookmarks. Prefer BookmarksManager for most integrations, since it automatically handles periodic bookmark put/delete operations.

Payload mapping​

Content typePersonalization API expectationiOS putBookmark fields
Normal content (movie / standalone VOD)itemId, offsetitemId, offset, and keep seasonId, episodeId, videoId, mode as nil
Series / episodic contentitemId, offset, seasonId, episodeId, mode = "series" (or episode mode where applicable)itemId, offset, seasonId, episodeId, mode: .series (or .episode when your flow is episode-specific)
Playlist contentitemId, offset, videoId, mode = "playlist"itemId, offset, videoId, mode: .playlist

Normal content vs series bookmark vs playlist bookmark​

  • Normal content bookmark is for a single asset. Retrieve with getBookmark(itemId:) and delete with deleteBookmark(itemId:completion:).
  • Series bookmark carries series metadata (seasonId, episodeId, mode) and can be listed via getSeriesBookmarks(seriesIdentifier:...) and deleted with deleteBookmark(itemId:episodeId:mode:completion:)(using mode: .episode for episode-specific deletion).
  • Playlist bookmark carries playlist metadata (videoId, mode) and can be listed via getPlaylistBookmarks(playlistIdentifier:...) and deleted with deleteBookmark(itemId:videoId:mode:completion:)(using mode: .playlist for playlist-video deletion).
let contentId = "123ABC-LC131-PLOJ45"
let latestPositionMs: TimeInterval = 99_999

bookmarkService.putBookmark(
itemId: contentId,
offset: latestPositionMs,
seasonId: nil,
episodeId: nil,
videoId: nil,
mode: nil,
seasonNumber: nil,
episodeNumber: nil,
contentType: nil
) { result in
switch result {
case .success:
print("Bookmark recorded for \(contentId) at \(latestPositionMs)ms")
case .failure(let error):
print("putBookmark failed: \(error)")
}
}

bookmarkService.deleteBookmark(itemId: contentId) { result in
switch result {
case .success:
print("Bookmark deleted for \(contentId)")
case .failure(let error):
print("deleteBookmark failed: \(error)")
}
}