Use a Clips player view to play Clips in an element on your page, instead of
opening the Clips player from a row or grid. The Web SDK has two Clips player
views. Both render into your container, fill it, and accept the same content
sources, configuration, and delegate.
Uses the full Clips player layout, which can show neighboring Clips on wide screens. Locks page scrolling while it's shown. dismissPlayer dismisses it.
The rest of this page uses StorytellerEmbeddedClipsPlayerView. The same
steps apply to StorytellerClipsPlayerView.
Provide exactly one source. With a collection ID, the player keeps collection
behavior: users can move between the collection's Clips when the collection
supports it. With { clipId } or { externalId }, the player shows only that
Clip. The constructor throws an Error if you pass no source or more than one.
The embedded Clips player uses the same configuration fields as
StorytellerClipsPlayerView. See
Configure views
for every field. The TypeScript example assumes
import * as Storyteller from '@getstoryteller/storyteller-sdk-javascript';
and imports the IStorytellerEmbeddedClipsPlayerConfiguration type.
constcustomTheme=newStoryteller.UiTheme();// See Customize themesconstembeddedClipPlayer=newStoryteller.StorytellerEmbeddedClipsPlayerView('embedded-clips-player-id',{externalId:'clip-external-id'});constembeddedClipPlayerConfiguration:IStorytellerEmbeddedClipsPlayerConfiguration={theme:customTheme,uiStyle:Storyteller.UiStyle.dark,};embeddedClipPlayer.configuration=embeddedClipPlayerConfiguration;
You can also change the source through configuration. Provide exactly one of
collection, clipId, or externalId. An update with an invalid source logs
an error and keeps the current source.
StorytellerEmbeddedClipsPlayerView uses the Clips player delegate
(IStorytellerClipsPlayerDelegate) through the same delegate property as
StorytellerClipsPlayerView. See
Handle view callbacks for every callback.
onPlayerDismissed means that the player was dismissed, so the back button
doesn't call it. The button calls onTopLevelBackTapped if you define it;
otherwise, it calls window.history.back().
When topLevelBackButtonEnabled is false or not set, the player doesn't show
the back button and doesn't call onTopLevelBackTapped from it.
Use StorytellerClipsPlayerView when an area of your page, such as a Clips
section or a Clips page, is set aside for the player. It takes the same
arguments, configuration, and delegate as
StorytellerEmbeddedClipsPlayerView:
{"slug": "storyteller-embedded-clips-player-view", "page_title": "Add a Clips Player to a Page", "page_url": "StorytellerEmbeddedClipsPlayerView/", "canonical_url": "/web/StorytellerEmbeddedClipsPlayerView/", "markdown": "# Add a Clips player to a page {#embedded-clips-player}\n\nUse a Clips player view to play Clips in an element on your page, instead of\nopening the Clips player from a row or grid. The Web SDK has two Clips player\nviews. Both render into your container, fill it, and accept the same content\nsources, configuration, and delegate.\n\n## Choose a Clips player view {#choose-a-clips-player-view}\n\n| View | Use it for | Behavior |\n| --- | --- | --- |\n| `StorytellerEmbeddedClipsPlayerView` | Clips inside other page content, such as a live blog or match center | Shows one Clip at a time. The rest of the page keeps scrolling. `Storyteller.sharedInstance.dismissPlayer` doesn't close it. |\n| [`StorytellerClipsPlayerView`](#clips-player-view) | An area of the page set aside for Clips | Uses the full Clips player layout, which can show neighboring Clips on wide screens. Locks page scrolling while it's shown. `dismissPlayer` dismisses it. |\n\nThe rest of this page uses `StorytellerEmbeddedClipsPlayerView`. The same\nsteps apply to `StorytellerClipsPlayerView`.\n\n## Initialization\n\n`StorytellerEmbeddedClipsPlayerView` accepts the same content sources as\n`StorytellerClipsPlayerView`: a collection ID, `{ clipId }`, or\n`{ externalId }`.\n\n```javascript\nconst embeddedCollectionPlayer =\n new Storyteller.StorytellerEmbeddedClipsPlayerView(\n 'embedded-clips-player-id',\n 'clip-collection-id'\n );\n\nconst embeddedSingleClipPlayer =\n new Storyteller.StorytellerEmbeddedClipsPlayerView(\n 'embedded-clips-player-id',\n { clipId: 'clip-id' }\n );\n\nconst embeddedSingleClipPlayerByExternalId =\n new Storyteller.StorytellerEmbeddedClipsPlayerView(\n 'embedded-clips-player-id',\n { externalId: 'clip-external-id' }\n );\n```\n\nProvide exactly one source. With a collection ID, the player keeps collection\nbehavior: users can move between the collection's Clips when the collection\nsupports it. With `{ clipId }` or `{ externalId }`, the player shows only that\nClip. The constructor throws an `Error` if you pass no source or more than one.\n\n## Sizing\n\nSet the player's size with CSS on the container. The constructor has no\n`width` or `height` options.\n\nFor portrait Clips, set the container width and use a `9 / 16` aspect ratio so\nthe browser works out the height:\n\n```html\n<div\n id=\"embedded-clips-player-id\"\n style=\"width: 430px; max-width: 100%; aspect-ratio: 9 / 16;\"\n><\/div>\n```\n\n```javascript\nconst embeddedSingleClipPlayer =\n new Storyteller.StorytellerEmbeddedClipsPlayerView(\n 'embedded-clips-player-id',\n { externalId: 'clip-external-id' }\n );\n```\n\n## Configuration\n\nThe embedded Clips player uses the same configuration fields as\n`StorytellerClipsPlayerView`. See\n[Configure views](StorytellerListView.md#embedded-clips-player-configuration)\nfor every field. The TypeScript example assumes\n`import * as Storyteller from '@getstoryteller/storyteller-sdk-javascript';`\nand imports the `IStorytellerEmbeddedClipsPlayerConfiguration` type.\n\n```typescript\nconst customTheme = new Storyteller.UiTheme(); // See Customize themes\nconst embeddedClipPlayer = new Storyteller.StorytellerEmbeddedClipsPlayerView(\n 'embedded-clips-player-id',\n { externalId: 'clip-external-id' }\n);\nconst embeddedClipPlayerConfiguration: IStorytellerEmbeddedClipsPlayerConfiguration =\n {\n theme: customTheme,\n uiStyle: Storyteller.UiStyle.dark,\n };\n\nembeddedClipPlayer.configuration = embeddedClipPlayerConfiguration;\n```\n\nYou can also change the source through `configuration`. Provide exactly one of\n`collection`, `clipId`, or `externalId`. An update with an invalid source logs\nan error and keeps the current source.\n\n```javascript\nembeddedClipPlayer.configuration = {\n externalId: 'new-clip-external-id',\n};\n```\n\n## Handle the back button {#back-button-delegate}\n\n`StorytellerEmbeddedClipsPlayerView` uses the Clips player delegate\n(`IStorytellerClipsPlayerDelegate`) through the same `delegate` property as\n`StorytellerClipsPlayerView`. See\n[Handle view callbacks](StorytellerListViewDelegate.md) for every callback.\n\n```javascript\nconst embeddedClipPlayer = new Storyteller.StorytellerEmbeddedClipsPlayerView(\n 'embedded-clips-player-id',\n { externalId: 'clip-external-id' }\n);\n\nembeddedClipPlayer.topLevelBackButtonEnabled = true;\nembeddedClipPlayer.delegate = {\n onTopLevelBackTapped: () => {\n window.history.back();\n },\n};\n```\n\n`onPlayerDismissed` means that the player was dismissed, so the back button\ndoesn't call it. The button calls `onTopLevelBackTapped` if you define it;\notherwise, it calls `window.history.back()`.\n\nWhen `topLevelBackButtonEnabled` is `false` or not set, the player doesn't show\nthe back button and doesn't call `onTopLevelBackTapped` from it.\n\n## Use a Clips player for a dedicated area {#clips-player-view}\n\nUse `StorytellerClipsPlayerView` when an area of your page, such as a Clips\nsection or a Clips page, is set aside for the player. It takes the same\narguments, configuration, and delegate as\n`StorytellerEmbeddedClipsPlayerView`:\n\n```javascript\nconst clipPlayer = new Storyteller.StorytellerClipsPlayerView(\n 'clips-player-id',\n 'clip-collection-id'\n);\n\nclipPlayer.topLevelBackButtonEnabled = true;\nclipPlayer.delegate = {\n onTopLevelBackTapped: () => {\n window.history.back();\n },\n};\n```\n\n`StorytellerClipsPlayerView` differs from the embedded player in three ways:\n\n- It uses the full Clips player layout, which can show neighboring Clips on wide screens.\n- It locks page scrolling while it's shown.\n- `Storyteller.sharedInstance.dismissPlayer` dismisses it and calls its `onPlayerDismissed` callback.\n\nFor its constructor and configuration, see\n[Clips player initialization](StorytellerListView.md#clips-player-initialization)\nand\n[Clips player configuration](StorytellerListView.md#clips-player-configuration).\n", "copy_markdown_include_header": false, "base_path": "", "ai_dir": "ai", "missing_payload_behavior": "empty"}