These methods allow you to programmatically open the Storyteller player to specific content like Stories, Pages, Categories, or Clip Collections.
All methods on this page are asynchronous and throwing. Call them from an asynchronous context and handle failures. For example:
importStorytellerSDKfuncopenFeaturedStory(){Task{@MainActorindo{tryawaitStoryteller.shared.openStory(id:"featured-story")}catch{print("Unable to open Story: \(error.localizedDescription)")}}}
configuration: A StorytellerClipCollectionConfiguration struct specifying the collection and optional starting points (see Embedded Clips for configuration details).
If a specific clip or category is specified via configuration.destination and found, it will be opened. Otherwise, the first clip in the collection is opened.
Throws if there is an issue opening the Collection (e.g., the requested Collection is not available).
importStorytellerSDKfuncopenTopPlays(){letconfiguration=StorytellerClipCollectionConfiguration(collectionId:"top-plays",context:["location":"home"])Task{@MainActorindo{tryawaitStoryteller.shared.openCollection(configuration:configuration)}catch{print("Unable to open Clips: \(error.localizedDescription)")}}}
externalId: The external ID of the specific Clip to open.
openReason: Why the player was opened. Used only for analytics.
If the clip with the externalId is found within the collection, it will be opened. Otherwise, the player will open to the first clip in the collection.
Throws if there is an issue opening the Collection (e.g., the requested Collection is not available).
{"slug": "open-player", "page_title": "Open a Player Programmatically", "page_url": "OpenPlayer/", "canonical_url": "/ios/OpenPlayer/", "markdown": "# Open Player\n\nThese methods allow you to programmatically open the Storyteller player to specific content like Stories, Pages, Categories, or Clip Collections.\n\nAll methods on this page are asynchronous and throwing. Call them from an asynchronous context and handle failures. For example:\n\n<!-- storyteller-swift-example: id=openplayer-featured-story target=sdk-ios context=declarations -->\n\n```swift\nimport StorytellerSDK\n\nfunc openFeaturedStory() {\n Task { @MainActor in\n do {\n try await Storyteller.shared.openStory(id: \"featured-story\")\n } catch {\n print(\"Unable to open Story: \\(error.localizedDescription)\")\n }\n }\n}\n```\n\n## Opening Stories & Categories\n\n### openCategory\n\nOpens a list of Stories filtered by a specific category ID.\n\n<!-- storyteller-swift-example: id=openplayer-01 target=sdk-ios context=statements -->\n\n```swift\ntry await Storyteller.shared.openCategory(category: \"category-id\")\n```\n\nSee the Showcase usage of `openCategory` in [`FeedImageView`](https://github.com/getstoryteller/storyteller-showcase-ios/blob/11.6.1/main/ShowcaseApp/Views/Home/Components/FeedImageView.swift#L3).\n\n**Parameters:**\n\n- `category`: The ID of the Story category to open.\n- `openReason`: Why the player was opened. Used only for analytics.\n\n**Throws** if there is an issue opening the category (e.g., the category is not available).\n\n### openStory (by ID)\n\nOpens a single Story by its specific ID.\n\n<!-- storyteller-swift-example: id=openplayer-02 target=sdk-ios context=statements -->\n\n```swift\ntry await Storyteller.shared.openStory(id: \"story-id\")\n```\n\n**Parameters:**\n\n- `id`: The ID of the Story to open.\n- `openReason`: Why the player was opened. Used only for analytics.\n\n**Throws** if there is an issue opening the Story (e.g., the requested Story is not available).\n\n### openStory (by External ID)\n\nOpens a single Story by its assigned external ID.\n\n<!-- storyteller-swift-example: id=openplayer-03 target=sdk-ios context=statements -->\n\n```swift\ntry await Storyteller.shared.openStory(externalId: \"story-external-id\")\n```\n\n**Parameters:**\n\n- `externalId`: The external ID of the Story to open.\n- `openReason`: Why the player was opened. Used only for analytics.\n\n**Throws** if there is an issue opening the Story (e.g., no Story found with the external ID).\n\n### openPage\n\nOpens a specific Page within its Story. The SDK deduces the correct Story based on the Page ID.\n\n<!-- storyteller-swift-example: id=openplayer-04 target=sdk-ios context=statements -->\n\n```swift\ntry await Storyteller.shared.openPage(id: \"page-id\")\n```\n\n**Parameters:**\n\n- `id`: The ID of the Page to open.\n- `openReason`: Why the player was opened. Used only for analytics.\n\n**Throws** if there is an issue opening the Page (e.g., the requested Page is not available).\n\n## Opening Clips & Collections\n\n### openCollection\n\nOpens a collection of Clips, optionally starting at a specific Clip or Category.\n\n<!-- storyteller-swift-example: id=openplayer-05 target=sdk-ios context=statements -->\n\n```swift\nlet configuration = StorytellerClipCollectionConfiguration(collectionId: \"collection-id\")\ntry await Storyteller.shared.openCollection(configuration: configuration)\n```\n\n**Parameters:**\n\n- `configuration`: A `StorytellerClipCollectionConfiguration` struct specifying the collection and optional starting points (see [Embedded Clips](EmbeddedClips.md#loading-clips) for configuration details).\n\nIf a specific clip or category is specified via `configuration.destination` and found, it will be opened. Otherwise, the first clip in the collection is opened.\n\n**Throws** if there is an issue opening the Collection (e.g., the requested Collection is not available).\n\n<!-- storyteller-swift-example: id=openplayer-top-plays target=sdk-ios context=declarations -->\n\n```swift\nimport StorytellerSDK\n\nfunc openTopPlays() {\n let configuration = StorytellerClipCollectionConfiguration(\n collectionId: \"top-plays\",\n context: [\"location\": \"home\"]\n )\n\n Task { @MainActor in\n do {\n try await Storyteller.shared.openCollection(configuration: configuration)\n } catch {\n print(\"Unable to open Clips: \\(error.localizedDescription)\")\n }\n }\n}\n```\n\n### Open Reason Enum\n\nThe optional `openReason` parameter accepts values of `StorytellerOpenReason`:\n\n<!-- storyteller-swift-example: id=openplayer-06 target=sdk-ios context=statements -->\n\n```swift\nlet openReason: StorytellerOpenReason = .instanceMethod\n```\n\nThis value is used only for analytics and has no functional effect on how the player behaves.\n\n### openClipByExternalId\n\nOpens a collection of Clips and attempts to navigate directly to a specific Clip within that collection using its external ID.\n\n<!-- storyteller-swift-example: id=openplayer-07 target=sdk-ios context=statements -->\n\n```swift\ntry await Storyteller.shared.openClipByExternalId(\n collectionId: \"collection-id\",\n externalId: \"clip-external-id\"\n)\n```\n\n**Parameters:**\n\n- `collectionId`: The ID of the Clip Collection.\n- `externalId`: The external ID of the specific Clip to open.\n- `openReason`: Why the player was opened. Used only for analytics.\n\nIf the clip with the `externalId` is found within the collection, it will be opened. Otherwise, the player will open to the first clip in the collection.\n\n**Throws** if there is an issue opening the Collection (e.g., the requested Collection is not available).\n", "copy_markdown_include_header": false, "base_path": "", "ai_dir": "ai", "missing_payload_behavior": "empty"}