dismissPlayer(animated: Boolean = true, reason: String? = null, onCompletion: () -> Unit = {}): force closes the currently open Story or Clip player. If no player is open when this is called, it has no effect.
animated: the flag indicating if close animation should be triggered. Defaults to true.
reason: the reason why the Story Page was force closed. This will be used to populate the dismissedReason parameter of the corresponding onUserActivityOccurred callback. If this is set to null the onUserActivityOccurred callback will not be triggered.
onCompletion: a callback that will be called when the player is dismissed. This is useful when you want to perform an action after the player is dismissed.
This method returns the count of stories available in the specified categories. It can be used to determine if a particular category or set of categories contains any Stories before rendering a UI component.
Parameters:
categoryIds - a list of category IDs to check for stories
Return value:
Returns the total number of stories available in the specified categories, or 0 if Storyteller is not initialized or the categoryIds list is empty
This method returns the count of clips available in the specified categories. It can be used to determine if a particular category or set of categories contains any Clips before rendering a UI component.
Parameters:
categoryIds - a list of category IDs to check for clips
Return value:
Returns the total number of clips available in the specified categories, or 0 if Storyteller is not initialized or the categoryIds list is empty
Preloads a Clips collection and optional single Clip IDs into the in-memory cache. This fetches the first page of the collection and stores it in the Clips cache, then fetches each requested clip by ID so single‑clip requests can read from cache. The loaded clips are also used to warm the playcard image cache to avoid a blank flash on first open.
Important: You must retain a strong reference to the returned StorytellerClipPreloadHandle while preloading is in progress. If the handle is garbage collected, preloading will stop.
Parameters:
collection - The Clips collection ID to preload.
clipsIds - Optional list of Clip IDs to preload (useful for clips beyond page 0).
preloadVideos - Whether to preload clip video content in addition to playcards. Defaults to false.
Return value:
Returns a StorytellerClipPreloadHandle that must be retained to keep preloading active. Call cancel() on the handle to stop preloading. Returns null if the SDK is not initialized or the collection is blank.
Best practices:
Only preload IDs for clips that are likely to be viewed soon (e.g., visible list items)
Call StorytellerClipPreloadHandle.cancel() when the preloaded clips are no longer needed
Large lists may contend with playback bandwidth; limit to near-term items
Include any single clip IDs that are outside the first page of the collection
Example usage:
classMyClipListViewModel:ViewModel(){privatevarpreloadHandle:StorytellerClipPreloadHandle?=nullfunonClipsVisible(collectionId:String,clipIds:List<String>){// Cancel previous preloadspreloadHandle?.cancel()// Start new preloads for the collection + visible clipspreloadHandle=Storyteller.preloadClips(collectionId,clipIds,preloadVideos=false)}overridefunonCleared(){super.onCleared()preloadHandle?.cancel()}}
{"slug": "additional-methods", "page_title": "Additional Methods", "page_url": "AdditionalMethods/", "canonical_url": "/android/AdditionalMethods/", "markdown": "# Additional Methods\n\n## Table of Contents\n\n- [Setting the global StorytellerDelegate](#setting-the-global-storytellerdelegate)\n- [Static Attributes](#static-attributes)\n- [Static Methods](#static-methods)\n\nThis page covers additional helper methods and properties.\n\n## Showcase examples\n\n- [Compose \u2014 `Storyteller.isSearchEnabled` (`StorytellerTopAppBar`)](https://github.com/getstoryteller/storyteller-showcase-android/blob/main/compose/app/src/main/java/com/getstoryteller/storytellershowcaseapp/ui/features/main/StorytellerTopAppBar.kt#L87)\n- [Compose \u2014 `Storyteller.dismissPlayer` before navigation (`ShowcaseStorytellerDelegate`)](https://github.com/getstoryteller/storyteller-showcase-android/blob/main/compose/app/src/main/java/com/getstoryteller/storytellershowcaseapp/data/ShowcaseStorytellerDelegate.kt#L121)\n- [XML \u2014 `Storyteller.dismissPlayer` before navigation (`ShowcaseStorytellerDelegate`)](https://github.com/getstoryteller/storyteller-showcase-android/blob/main/xml/app/src/main/java/com/getstoryteller/storytellershowcaseapp/data/ShowcaseStorytellerDelegate.kt#L86)\n\n## Setting the global StorytellerDelegate\n\nPlease see the dedicated [Storyteller Delegates](StorytellerDelegates.md) page.\n\n```kotlin\n Storyteller.storytellerDelegate = myCustomStorytellerDelegate\n```\n\n## Static Attributes\n\n### isInitialized\n\n`isInitialized` is a boolean static property which is set to `true` if Storyteller was initialized successfully.\n\n```kotlin\nval initialized = Storyteller.isInitialized\n```\n\n### isSearchEnabled\n\n`isSearchEnabled` is a boolean static property which is set to `true` if the Search feature is enabled in the Storyteller configuration.\n\n```kotlin\nval searchEnabled = Storyteller.isSearchEnabled\n```\n\n### isPlayerVisible\n\n`isPlayerVisible` is a boolean property which is set to `true` when a Story or Clip player is opened, `false` when the Story or Clip player is dismissed.\n\n```kotlin\nval isStoryPlayerVisible = Storyteller.isPlayerVisible\n```\n\n### version\n\nThe `version` is a static String property which holds the SDK version.\n\n```kotlin\nval storytellerVersion = Storyteller.version\n```\n\n### user\n\nAllows setting custom attributes for audience targeting. Please see [Working with Users](Users.md).\n\n```kotlin\nStoryteller.user.setCustomAttribute(\"location\", \"New York\")\n```\n\n## Static Methods\n\n### openSearch\n\n```kotlin\n fun openSearch(activity: Activity)\n```\n\nThis method opens the Search screen.\n\nParameters:\n\n- `activity` - this is the Activity that will be used to launch the Storyteller Search activity\n\n### openSheet\n\n```kotlin\nfun openSheet(activity: AppCompatActivity, sheetId: String, onError: (StorytellerError) -> Unit)\n```\n\nThis call opens a Sheet with a given ID.\n\nParameters:\n\n- `activity` - this is the Activity that will be used to launch the Sheet\n- `sheetId` - this is a Sheet's ID. If it is blank, `onError` will be called\n- `onError` - this is called when there is any issue with opening a Sheet (e.g. the sheetId is a blank string)\n\n### dismissPlayer\n\n`dismissPlayer(animated: Boolean = true, reason: String? = null, onCompletion: () -> Unit = {})`: force closes the currently open Story or Clip player. If no player is open when this is called, it has no effect.\n\n`animated`: the flag indicating if close animation should be triggered. Defaults to `true`.\n\n`reason`: the reason why the Story Page was force closed. This will be used to populate the `dismissedReason` parameter of the corresponding `onUserActivityOccurred` callback. If this is set to `null` the `onUserActivityOccurred` callback will not be triggered.\n\n`onCompletion`: a callback that will be called when the player is dismissed. This is useful when you want to perform an action after the player is dismissed.\n\n```kotlin\nStoryteller.dismissPlayer(true, \"reason\")\n```\n\n### resumePlayer\n\n`resumePlayer()`: resumes the currently open Story or Player Views. If no Player is open when this is called, it has no effect.\n\n```kotlin\nStoryteller.resumePlayer()\n```\n\n### getStoriesCount\n\n```kotlin\nsuspend fun getStoriesCount(categoryIds: List<String>): Int\n```\n\nThis method returns the count of stories available in the specified categories. It can be used to determine if a particular category or set of categories contains any Stories before rendering a UI component.\n\nParameters:\n\n- `categoryIds` - a list of category IDs to check for stories\n\nReturn value:\n\n- Returns the total number of stories available in the specified categories, or 0 if Storyteller is not initialized or the categoryIds list is empty\n\n### getClipsCount\n\n```kotlin\nsuspend fun getClipsCount(categoryIds: List<String>): Int\n```\n\nThis method returns the count of clips available in the specified categories. It can be used to determine if a particular category or set of categories contains any Clips before rendering a UI component.\n\nParameters:\n\n- `categoryIds` - a list of category IDs to check for clips\n\nReturn value:\n\n- Returns the total number of clips available in the specified categories, or 0 if Storyteller is not initialized or the categoryIds list is empty\n\n### preloadClips\n\n```kotlin\n@MainThread\nfun preloadClips(\n collection: String,\n clipsIds: List<String> = emptyList(),\n preloadVideos: Boolean = false\n): StorytellerClipPreloadHandle?\n```\n\nPreloads a Clips collection and optional single Clip IDs into the in-memory cache. This fetches the first page of the collection and stores it in the Clips cache, then fetches each requested clip by ID so single\u2011clip requests can read from cache. The loaded clips are also used to warm the playcard image cache to avoid a blank flash on first open.\n\n**Important:** You must retain a strong reference to the returned `StorytellerClipPreloadHandle` while preloading is in progress. If the handle is garbage collected, preloading will stop.\n\nParameters:\n\n- `collection` - The Clips collection ID to preload.\n- `clipsIds` - Optional list of Clip IDs to preload (useful for clips beyond page 0).\n- `preloadVideos` - Whether to preload clip video content in addition to playcards. Defaults to `false`.\n\nReturn value:\n\n- Returns a `StorytellerClipPreloadHandle` that must be retained to keep preloading active. Call `cancel()` on the handle to stop preloading. Returns `null` if the SDK is not initialized or the collection is blank.\n\nBest practices:\n\n- Only preload IDs for clips that are likely to be viewed soon (e.g., visible list items)\n- Call `StorytellerClipPreloadHandle.cancel()` when the preloaded clips are no longer needed\n- Large lists may contend with playback bandwidth; limit to near-term items\n- Include any single clip IDs that are outside the first page of the collection\n\nExample usage:\n\n```kotlin\nclass MyClipListViewModel : ViewModel() {\n private var preloadHandle: StorytellerClipPreloadHandle? = null\n\n fun onClipsVisible(collectionId: String, clipIds: List<String>) {\n // Cancel previous preloads\n preloadHandle?.cancel()\n // Start new preloads for the collection + visible clips\n preloadHandle = Storyteller.preloadClips(collectionId, clipIds, preloadVideos = false)\n }\n\n override fun onCleared() {\n super.onCleared()\n preloadHandle?.cancel()\n }\n}\n```\n", "copy_markdown_include_header": false, "base_path": "android", "ai_dir": "ai", "missing_payload_behavior": "empty"}