Aurora Attributes and Properties

Learn more about the attributes and properties available for your embedded player.

Quick reference

Customizable attributes and properties

HTML attributeJavaScript propertyDescription
media-idmediaIdRequired. The unique ID of a media.
aspectaspectSets the aspect ratio of the player.
audio-description-controlaudioDescriptionControlEnabled/disables the Audio Description control in the play bar
autoplayautoplayIf set to true the media will play as soon as it's ready.
big-play-buttonbigPlayButtonEnables/disables the big play button which appears in the center of the video before play.
controls-visible-on-loadcontrolsVisibleOnLoadEnables/disables whether the control bar is present on load before play.
copy-link-and-thumbnailcopyLinkAndThumbnailEnables/disables whether the "Copy link and thumbnail" option is present in context menu.
current-timecurrentTimeSets the current time of the media as a decimal in seconds.
do-not-trackdoNotTrackDisables viewing session tracking for heatmaps and other analytics.
emailemailSets which specific email address should be associated with this media's viewing sessions.
end-video-behaviorendVideoBehaviorSets the behavior of the media when it ends.
fullscreen-controlfullscreenControlEnables/disables the fullscreen control in the control bar.
mutedmutedMutes/unmutes the media.
playback-rate-controlplaybackRateControlEnables/disables the playback rate option inside the settings control.
play-bar-controlplayBarControlEnables/disables the play bar in the control bar.
player-colorplayerColorSets the base color of the player.
playlist-linksplaylistLinksAssociates specially crafted media links on your page with a media, turning all of them together into a playlist.
playlist-loopplaylistLoopEnables/disables the behavior of the playlist to loop back to the first media in the list after all media have been played.
play-pause-controlplayPauseControlEnables/disables the play/pause control in the control bar.
play-pause-notifierplayPauseNotifierEnables/disables the brief animation of a pause/play symbol when playing/pausing.
posterposterSets the thumbnail of the media.
preloadpreloadSets the loading strategy for the media.
quality-controlqualityControlEnables/disables the manual quality selection option in the settings control.
quality-maxqualityMaxSet the maximum quality for automatic playback.
quality-minqualityMinSet the minimum quality for automatic playback.
resumableresumableTells the media to pick up where the viewer left off the next time they load the page where the media is embedded.
rounded-playerroundedPlayerControls all rounded corners of the player.
seoseoEnables/disable if the media's metadata will be injected into the page's on-page markup.
settings-controlsettingsControlEnables/disables the settings control in the control bar.
silent-autoplaysilentAutoplaySets how sound and autoplay work together.
swatchswatchEnables/disables the placeholder image which displays while the player is loading.
transparent-letterboxtransparentLetterboxIf set to true the background behind the player will be transparent, allowing the page color to show through instead of the default black letterboxing.
video-qualityvideoQualitySets the quality level of the media.
volumevolumeSets the volume of the player.
volume-controlvolumeControlEnables/disables the volume control in the control bar.

Read-only properties

JavaScript propertyDescription
bufferedReturns a TimeRanges object that represents the ranges of the media resource that the user agent has buffered.
durationReturns the duration of the media in seconds.
embedOptionsReturns all the embed options being set on the player from attributes and media data.
endedReturns true if the media has ended playback.
eventKeyReturns the event_key for the current viewing session. You can get all events for your account from the Stats API.
inFullscreenReturns true if the media is currently in fullscreen.
nameReturns the name of the media, as defined in the Wistia application.
pausedReturns true if the media is paused.
percentWatchedReturns the percent of the media that has been watched as a decimal between 0 and 1.
readyStateReturns a value that expresses the current state of the element with respect to rendering the current playback position.
secondsWatchedReturns the number of unique seconds that have been watched for the media.
secondsWatchedVectorReturns an array where each index represents the number of times the viewer has watched each second of the media.
stateReturns the current state of the media.
visitorKeyReturns the unique visitor key of the viewer of the media.

Try it!

Attributes:

Properties:

beforeplay

Using attributes and properties

HTML attributes

Attributes are additional values which can be added to <wistia-player> to further customize its look and behavior. Multiple attributes can be set on a <wistia-player> element at once.

<script src="https://fast.wistia.com/player.js" async></script>

<!-- This player is red. -->
<wistia-player id="my-player-1" media-id="abc123" player-color="#ff0000"></wistia-player>

<!-- This player is green. -->
<wistia-player id="my-player-2" media-id="abc123" player-color="#00ff00"></wistia-player>

<!-- And this player has a bunch of different options set at once! -->
<wistia-player id="my-player-3" media-id="abc123" big-play-button="false" muted player-color="#0000ff"></wistia-player>

Attributes can also be set on the React component version of the player, <WistiaPlayer>. They're set as props on the component and use camelCase syntax rather than snake-case syntax.

import { WistiaPlayer } from "@wistia/wistia-player-react";

// This player is red.
<WistiaPlayer id="my-player-1" mediaId="abc123" playerColor="#ff0000" />

// This player is green.
<WistiaPlayer id="my-player-2" mediaId="abc123" playerColor="#00ff00" />
    
// And this player has a bunch of different options set at once!
<WistiaPlayer id="my-player-3" mediaId="abc123" bigPlayButton={false} muted={true} playerColor="#0000ff" />

JavaScript properties

Every HTML attribute available on <wistia-player> also has a corresponding JavaScript property—so the attribute player-color corresponds to and will be equal to the property playerColor.

Like attributes, properties can be used to set the look and behavior of the <wistia-player>. Properties are set via JavaScript rather than HTML, and they can also be used to get more information than just attributes can provide, such as a player's currentTime, state, and videoQuality.

Properties are usually better than attributes when you need to make an update to <wistia-player> after the initial render of the element because they won't trigger a DOM change.

<script src="https://fast.wistia.com/player.js" async></script>

<wistia-player id="my-player-1" media-id="abc123"></wistia-player>
<wistia-player id="my-player-2" media-id="abc123"></wistia-player>
<wistia-player id="my-player-3" media-id="abc123"></wistia-player>

<script>
  // This player will now be red.
  const player1 = document.getElementById("my-player-1");
  player1.playerColor = "#ff0000";

  // This player will now be green.
  const player2 = document.getElementById("my-player-2");
  player2.playerColor = "#00ff00";

  // And this player will now not have a big play button, will be muted, and will be blue!
  const player3 = document.getElementById("my-player-3");
  player3.bigPlayButton = false;
  player3.muted = true;
  player3.playerColor = "#0000ff";
</script>

Attributes and properties specific to popover embeds can be found in our Popover Embed Documentation.


media-id

Required. The unique ID of a media.

To get the media ID for a video, refer to the URL of the media's page in Wistia. The alphanumeric characters following /medias/ are what you want.

HTML attributeJavaScript propertyTypeDefault valueExample values
media-idmediaIdstringundefined"abc123", "ns6e2w2xw1"

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" />

aspect

Sets the aspect ratio of the player.

HTML attributeJavaScript propertyTypeDefault valueExample values
aspectaspectnumberundefined1.778, 16 / 9

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" aspect="1.778"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" aspect={1.778} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.aspect = 1.778;
  player.aspect; // Returns 1.778
</script>

audio-description-control

Enables/disables the Audio Description Control in the control bar.

🙌

Note: If this control is enabled, but no Alternate Audio tracks are found for the video, the control will not appear in the control bar.

HTML attributeJavaScript propertyTypeDefault valueExample values
audio-description-controlaudioDescriptionControlbooleanfalsetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" audio-description-control="true"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" audioDescriptionControl={true} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.audioDescriptionControl = true;
  player.audioDescriptionControl; // Returns true
</script>

autoplay

If set to true the video will play as soon as it's ready.

You can also add ?wvideo=mediaid to the end of any URL where a Wistia video is embedded, so that it will automatically start playing when your viewer visits that link. You can test this out in your Wistia account too!

🙌

Note: autoplay will not work on iOS and other mobile devices due to restrictions on bandwidth on cellular networks. You can find more information on these restrictions in the Player API Documentation.

Videos will autoplay whenever possible, but some browsers (like most mobile browsers and Safari) prevent video autoplay.

HTML attributeJavaScript PropertyTypeDefault valueExample values
autoplayautoplaybooleanfalsetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" autoplay></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" autoplay={true} />

big-play-button

Enables/disables the big play button which appears in the center of the video before play.

HTML attributeJavaScript propertyTypeDefault valueExample values
big-play-buttonbigPlayButtonbooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" big-play-button="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" bigPlayButton={false} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.bigPlayButton = false;
  player.bigPlayButton; // Returns `false`
</script>

controls-visible-on-load

Enables/disables whether the control bar is present on load before play.

HTML attributeJavaScript propertyTypeDefault valueExample values
controls-visible-on-loadcontrolsVisibleOnLoadbooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" controls-visible-on-load="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" controlsVisibleOnLoad={false} />

copy-link-and-thumbnail

Enables/disables whether the "Copy link and thumbnail" option is present in context menu.

If set to false, once your media is embedded on a webpage, the option to "Copy Link and Thumbnail" when you right click on your media will be removed.

🙌

Note: If set to false, you will not be able to create a thumbnail that links to the page where the video is embedded.

HTML attributeJavaScript propertyTypeDefault valueExample values
copy-link-and-thumbnailcopyLinkAndThumbnailbooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" copy-link-and-thumbnail="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" copyLinkAndThumbnail={false} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.copyLinkAndThumbnail = false;
  player.copyLinkAndThumbnail; // Returns `false`
</script>

current-time

Sets the current time of the media as a decimal in seconds.

This option will maintain the state of the video: if the video was playing, it will continue playing after seek. If it was not playing, the video will be paused.

🙌

Note: On iOS, when seeking from the "beforeplay" state, setting player.currentTime is subject to the same restrictions as player.play(). However, there is a bit of nuance. If you set player.currentTime = 30 before play, the media will not play per the restrictions. But once the viewer clicks the media to play it, it will begin playing 30 seconds in.

HTML attributeJavaScript propertyTypeDefault valueExample values
current-timecurrentTimenumber05, 10.375

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" current-time="5"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" currentTime={5} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.currentTime = 3.5;
  player.currentTime; // Returns `3.5`
</script>

do-not-track

If set to true, disables viewing session tracking for heatmaps and other analytics.

By default, data for each viewing session is tracked and reported back to the Wistia servers for display in heatmaps and aggregation graphs.

HTML attributeJavaScript propertyTypeDefault valueExample values
do-not-trackdoNotTrackbooleanfalsetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" do-not-track></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" doNotTrack={true} />

email

Sets which specific email address should be associated with this media's viewing sessions.

HTML attributeJavaScript propertyTypeDefault valueExample values
emailemailstringundefined"[email protected]"

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" email="[email protected]"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" email="[email protected]" />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.email = '[email protected]';
  player.email; // Returns `[email protected]`
</script>

end-video-behavior

Sets the behavior of the media when it ends.

HTML attributeJavaScript propertyTypeDefault valueExample values
end-video-behaviorendVideoBehaviorstring"default""default", "loop", "reset"

Possible values:

ValueDescription
"default"Default behavior. The video stays on the last frame
"reset"The video shows the thumbnail. Control Bar visibility depends on controls-visible-on-load
"loop"The video plays again from the beginning

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" end-video-behavior="reset"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" endVideoBehavior="reset" />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.endVideoBehavior = 'reset';
  player.endVideoBehavior; // Returns `'reset'`
</script>

fullscreen-control

Enables/disables the fullscreen control in the control bar.

🙌

Note: iframe embeds must have the allowfullscreen attribute for this option to be meaningful. If allowfullscreen attribute is missing, the fullscreen control will not appear.

HTML attributeJavaScript propertyTypeDefault valueExample values
fullscreen-controlfullscreenControlbooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" fullscreen-control="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" fullscreenControl={false} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.fullscreenControl = false;
  player.fullscreenControl; // Returns `false`
</script>

muted

Enables/disables the audio mute setting of the player.

Set this option to true on the initial load of the player if you would like your video to play silently and not show the "Click For Sound" icon.

HTML attributeJavaScript propertyTypeDefault valueExample values
mutedmutedbooleanfalsetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" muted></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" muted={true} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.muted = true;
  player.muted; // Returns `true`
</script>

playback-rate-control

Enables/disables the playback rate option inside the settings control.

HTML attributeJavaScript propertyTypeDefault valueExample values
playback-rate-controlplaybackRateControlbooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" playback-rate-control="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" playbackRateControl={false} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.playbackRateControl = false;
  player.playbackRateControl; // Returns `false`
</script>

play-bar-control

Enables/disables the play bar in the control bar. The play bar includes the playhead, current time, and scrubbing functionality.

HTML attributeJavaScript propertyTypeDefault valueExample values
play-bar-controlplayBarControlbooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" play-bar-control="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" playBarControl={false} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.playBarControl = false;
  player.playBarcontrol; // Returns `false`
</script>

player-color

Sets the base color of the player. Expects a six-character hexadecimal RGB string like #2949E5. The string can include or exclude the preceding # character.

HTML attributeJavaScript propertyTypeDefault valueExample values
player-colorplayerColorstring"636155""ff0000", "#00FF00"

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" player-color="#2949E5"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" playerColor="#2949E5" />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.playerColor = "1e64f0";
  player.playerColor; // Returns "1e64f0"
</script>

playlist-links

Associates specially crafted media links on your page with a media, turning all of them together into a playlist. For more detailed information about playlist links and their possible values, check out the full Embed Links documentation.

HTML attributeJavaScript propertyTypeDefault valueExample values
playlist-linksplaylistLinksstringundefined"auto", "manual", ${containerId}

Possible values:

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" playlist-links="auto"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" playlistLinks="auto" />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.playlistLinks = "auto";
  player.playlistLinks; // Returns "auto"
</script>

playlist-loop

If the media has a playlist and this value is set to true, the playlist will loop back to the first media and replay it once the last media has finished.

HTML attributeJavaScript propertyTypeDefault valueExample values
playlist-loopplaylistLoopbooleanfalsetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" playlist-loop></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" playlistLoop={true} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.playlistLoop = true;
  player.playlistLoop; // Returns `true`
</script>

play-pause-control

Enables/disables the play/pause control in the control bar.

HTML attributeJavaScript propertyTypeDefault valueExample values
play-pause-controlplayPauseControlbooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" play-pause-control="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" playPauseControl={false} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.playPauseControl = false;
  player.playPauseControl; // Returns `false`
</script>

play-pause-notifier

Enables/disables the brief animation of a pause/play symbol when playing/pausing.

HTML attributeJavaScript propertyTypeDefault valueExample values
play-pause-notifierplayPauseNotifierbooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" play-pause-notifier="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" playPauseNotifier={false} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.playPauseNotifier = false;
  player.playPauseNotifier; // Returns `false`
</script>

poster

Overrides the thumbnail image which appears before the video plays. Expects an absolute URL to an image. For the best results, the image should match the exact aspect ratio of the video.

HTML attributeJavaScript propertyTypeDefault valueExample values
posterposterstring"https://embed-ssl.wistia.com/deliveries/${uuid}/.jpg""https://my-image.com/picture.jpg"

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" poster="https://my-image.com/picture.jpg"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" poster="https://my-image.com/picture.jpg" />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.poster = "https://my-image.com/picture.jpg"; 
  player.poster; // Returns "https://my-image.com/picture.jpg"
</script>

preload

Sets the loading strategy for the media.

🙌

Note: The attribute/property preload must be set before the player is embedded. Changing it after the player is loaded on the page will have no impact.

HTML attributeJavaScript propertyTypeDefault valueExample values
preloadpreloadstring"auto""auto", "none", "metadata"

Possible values:

ValueDescription
"auto"All data is preloaded.
"none"No data, other than the bare minimum to render a media player on the page, is preloaded.
"metadata"Only video/audio metadata is preloaded.

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" preload="none"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" preload="none" />

quality-control

Enables/disables the manual quality selection option in the settings control.

HTML attributeJavaScript propertyTypeDefault valueExample values
quality-controlqualityControlbooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" quality-control="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" qualityControl={false} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.qualityControl = false;
  player.qualityControl; // Returns `false`
</script>

quality-max

Set the maximum quality for automatic playback. <wistia-player> will still run bandwidth checks to test for speed and play the highest quality version at or below the set maximum.

🙌

Note: Keep in mind, viewers will still be able to manually select a quality outside the set maximum (using the option on the player) unless quality-control is set to false.

HTML attributeJavaScript propertyTypeDefault valueExample values
quality-maxqualityMaxnumberundefined224, 360, 540

Possible values

ValueDescription
224224p max
360360p max
540540p max
720720p max
10801080p max
38403830p max

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" quality-max="1080"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" qualityMax={1080} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.qualityMax = 1080; 
  player.qualityMax; // Returns `1080`
</script>

quality-min

Set the minimum quality for automatic playback. <wistia-player> will still run bandwidth checks to test for speed and play the highest quality version at or above the set minimum.

🙌

Note: Keep in mind, viewers will still be able to manually select a quality outside the set minimum (using the option on the player) unless quality-control is set to false.

HTML attributeJavaScript propertyTypeDefault valueExample values
quality-minqualityMinnumberundefined224, 360, 540

Possible values:

ValueDescription
224224p min
360360p min
540540p min
720720p min
10801080p min
38403830p min

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" quality-min="540"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" qualityMin={540} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.qualityMin = 540; 
  player.qualityMin; // Returns `540` 
</script>

resumable

Tells the media to pick up where the viewer left off the next time they load the page where the media is embedded.

HTML attributeJavaScript propertyTypeDefault valueExample values
resumableresumableboolean || "auto""auto""auto', true, false

Possible values:

ValueDescription
"auto"The resumable feature will only be enabled if the video is 5 minutes or longer, is not autoplay, and is not set to loop at the end.
trueAlways enables the resumable feature.
falseAlways disables the resumable feature.

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" resumable></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" resumable={true} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.resumable = true;
  player.resumable; // Returns `true`
</script>

rounded-player

Controls all rounded corners of the player. Expects a number value between 0 and 24.

HTML attributeJavaScript propertyTypeDefault valueExample values
rounded-playerroundedPlayernumber05, 24

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" rounded-player="24"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" roundedPlayer={24} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.roundedPlayer = 24;
  player.roundedPlayer; // Returns `24`
</script>

seo

Enables/disables if the media's metadata will be injected into the page's on-page markup. Learn more about SEO.

🙌

Note: It is best to have this value set correctly immediately upon embed. Otherwise, web crawlers like Google may miss your video's SEO.

🙌

Note: Changing this value from true to false after the video has been embedded will not remove any SEO markup that has already been added to the page.

HTML attributeJavaScript propertyTypeDefault valueExample values
seoseobooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" seo="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" seo={false} />

settings-control

Enables/disables the settings control in the control bar. This control allows viewers to control the quality and playback speed of the video.

See quality-control and playback-rate-control if you want more control over what is available within the settings control.

HTML attributeJavaScript propertyTypeDefault valueExample values
settings-controlsettingsControlbooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" settings-control="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" settingsControl={false} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.settingsControl = false;
  player.settingsControl; // Returns `false`
</script>

silent-autoplay

Sets how sound and autoplay work together. This option allows videos to autoplay in a muted state in contexts where normal autoplay is blocked or not supported (e.g. iOS, Safari 11+, Chrome 66+).

The silent-autoplay option will act as an autoplay preference, but will not have the video autoplay by itself. In order for this option to work, the video will need to be set to play through the autoplay embed option or set via Customize within the Wistia app.

🙌

Note: A video is considered to be "autoplaying" if the play() command is not issued within a user-generated event (like a click) or within the "end" event handler (e.g. for the next video in a playlist).

If you need to see when the video enters and exits "silent playback mode," refer to the docs on the silent-playback-mode-change event.

HTML attributeJavaScript propertyTypeDefault valueExample values
silent-autoplaysilentAutoplayboolean || "allow"falsetrue, false, "allow"

Possible values:

ValueDescription
"allow"The video will default to normal autoplay, with silent autoplay as a fallback if needed
trueThe video will default to autoplaying silently
falseThe video will not autoplay silently

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" autoplay silent-autoplay="allow"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" autoplay={true} silentAutoplay="allow" />

swatch

Enables/disables the placeholder image which displays while the player is loading. Changing this option after the player has loaded will have no effect.

HTML attributeJavaScript propertyTypeDefault valueExample values
swatchswatchbooleantruetrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" swatch="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" swatch={false} />

transparent-letterbox

If set to true the background behind the player will be transparent, allowing the page color to show through instead of the default black letterboxing. Letterboxing may occur if there's an aspect ratio discrepancy between the dimensions of the video and its container—this option is not connected to alpha transparency.

HTML attributeJavaScript propertyTypeDefault valueExample values
transparent-letterboxtransparentLetterboxbooleanfalsetrue,false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" transparent-letterbox="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" transparentLetterbox={false} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.transparentLetterbox = false;
  player.transparentLetterbox; // Returns `false`
</script>

video-quality

Sets and returns the quality level of the media. It accepts either an integer indicating the exact quality level to stream (ex. 224, 360, etc) or the string "auto" to enable adaptive bit rate streaming.

🙌

Note: If you specify a quality level corresponding to an asset that doesn't exist for your media, videoQuality will default to the highest or lowest quality asset available. For example, if you pass 1080 as an argument but your video doesn't have a 1080p asset, videoQuality will select the 720p asset instead.

HTML attributeJavaScript propertyTypeDefault valueExample values
video-qualityvideoQualitynumber | "auto""auto"720, "auto"

Possible values:

ValueDescription
"auto"Enable adaptive bit rate streaming.
224224p
360360p
540540p
720720p
10801080p
38403830p

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" video-quality="360"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" videoQuality={360} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.videoQuality = 720;
  player.videoQuality; // Returns `720`
</script>

volume

Set the volume of the media. Expects an integer value between 0 and 1. To mute the media on load, set this option to 0.

HTML attributeJavaScript propertyTypeDefault valueExample values
volumevolumenumber10,0.5, 1

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" volume="0.5"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" volume={0.5} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.volume = 0.5;
  player.volume; // Returns `0.5`
</script>

volume-control

Enables/disables the volume control in the control bar.

🙌

Note: On mobile devices where we use the native volume controls, this option has no effect.

HTML attributeJavaScript propertyTypeDefault valueExample values
volume-controlvolumeControlbooleantruetrue,false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123" volume-control="false"></wistia-player>
import { WistiaPlayer } from "@wistia/wistia-player-react";
<WistiaPlayer id="my-player" mediaId="abc123" volumeControl={false} />
<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById("my-player"); // Finds the existing player
  player.volumeControl = false;
  player.volumeControl; // Returns `false`
</script>

Using read-only properties

Read-only JavaScript properties cannot be set, and provide useful information about the data and state of the <wistia-player>. Properties like duration and state can be used alongside other player attributes, properties, events, and methods to build out functionality for the <wistia-player>.

<script src="https://fast.wistia.com/embed/abc123.js" async type="module"></script>
<script src="https://fast.wistia.com/player.js" async></script>

<wistia-player id="my-player" media-id="abc123"></wistia-player>
<button type="button" id="halfway-button">Skip to the halfway point!</button>

<script>
  const player = document.getElementById('my-player');
  const halfwayButton = document.getElementById('halfway-button');

  // When a button is clicked...
  halfwayButton.addEventListener('click', () => {
    // Use the read-only duration property to set the media to its halfway point
    player.currentTime = player.duration / 2;
  });
</script>

buffered

Read only. Returns a TimeRanges object that represents the ranges of the media resource that the user agent has buffered.

JavaScript propertyTypeExample values
bufferedobject{ end: end(index), length: 1, start: start(index) }

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(player.buffered);
  
  // Example output: TimeRanges{ end: end(index), length: 1, start: start(index) }
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handleApiReady() {
    if (player.current === null) { return; }
    console.log(player.buffered);
    
    // Example output: TimeRanges{ end: end(index), length: 1, start: start(index) }
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onApiReady={handleApiReady} />
  );
}

duration

Read only. Returns the duration of the media as a decimal in seconds. This will return undefined until the loaded-metadata event has fired.

JavaScript propertyTypeExample values
durationnumber | undefined5.125, 120, undefined

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(`This video is ${player.duration} seconds long.`);
  
  // Example output: "This video is 120 seconds long."
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handleLoadedMetadata() {
    if (player.current === null) { return; }
    console.log(`This video is ${player.duration} seconds long.`);
    
    // Example output: "This video is 120 seconds long."
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onLoadedMetadata={handleLoadedMetadata} />
  );
}

embedOptions

Read only. Returns all the embed options being set on the player from attributes and media data.

JavaScript propertyTypeExample values
embedOptionsobject{}, { playerColor: "00ff00", fullscreenControl: false }

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(player.embedOptions);
  
  // Example output: { playerColor: "00ff00", fullscreenControl: false }
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handleApiReady() {
    if (player.current === null) { return; }
    console.log(player.embedOptions);
    
    // Example output: { playerColor: "00ff00", fullscreenControl: false }
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onApiReady={handleApiReady} />
  );
}

ended

Read only. Returns true if the media has ended playback.

JavaScript propertyTypeExample values
endedbooleantrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(`The media has${player.ended ? "" : " not"} ended.`);
  
  // Example output: "The media has ended."
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handleEnded() {
    if (player.current === null) { return; }
    console.log(`The media has${player.ended ? "" : " not"} ended.`);
    
    // Example output: "The media has ended."
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onEnded={handleEnded} />
  );
}

eventKey

Read only. Returns the event_key for the current viewing session, if it exists. You can get all events for your account from the Stats API.

JavaScript propertyTypeExample values
eventKeystring | undefinedundefined, "123-abc-4567-89"

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(player.eventKey);
  
  // Example output: "123-abc-4567-89"
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handleApiReady() {
    if (player.current === null) { return; }
    console.log(player.eventKey);
    
    // Example output: "123-abc-4567-89"
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onApiReady={handleApiReady} />
  );
}

inFullscreen

Read only. Returns true if the media is currently in fullscreen.

JavaScript propertyTypeExample values
inFullscreenbooleantrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(`The player is${player.inFullscreen ? "" : " not"} currently in fullscreen.`);
  
  // Example output: "The player is not currently in fullscreen."
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handleCancelFullscreen() {
    if (player.current === null) { return; }
    console.log(`The player is${player.inFullscreen ? "" : " not"} currently in fullscreen.`);
    
    // Example output: "The player is not currently in fullscreen."
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onCancelFullscreen={handleCancelFullscreen} />
  );
}

name

Read only. Returns the name of the media, as defined in the Wistia application. Returns undefined until the loadedmetadata event has fired.

JavaScript propertyTypeExample values
namestring | undefined"My Video Title", "Lenny Delivers Video", undefined

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(player.name);
  
  // Example output: "Lenny Delivers Video"
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handleLoadedMetadata() {
    if (player.current === null) { return; }
    console.log(player.name);
    
    // Example output: "Lenny Delivers Video"
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onLoadedMetadata={handleLoadedMetadata} />
  );
}

paused

Read only. Returns true if the media is paused.

JavaScript propertyTypeExample values
pausedbooleantrue, false

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(`The player is${player.paused ? "" : " not"} paused.`);
  
  // Example output: "The player is paused."
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handlePause() {
    if (player.current === null) { return; }
    console.log(`The player is${player.paused ? "" : " not"} paused.`);
    
    // Example output: "The player is paused."
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onPause={handlePause} />
  );
}

percentWatched

Read only. Returns the percent of the media that has been watched as a decimal between 0 and 1. This is equivalent to computing player.secondsWatched / Math.floor(player.duration).

This percentage value is relative to where a viewer started playback during their viewing session. For example, if a viewer starts the video in the middle and watches it to the end, player.percentWatched will return 0.5. If that same viewer in that same session then starts the video from the beginning and watches to the middle, player.percentWatched will return 1, as the whole video has now been watched.

JavaScript propertyTypeExample values
percentWatchednumber0, 0.7525

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(`The viewer has watched ${(player.percentWatched * 100)}% of the video.`);
  
  // Example output: "The viewer has watched 75.25% of the video."
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handlePercentWatchedChange() {
    if (player.current === null) { return; }
    console.log(`The viewer has watched ${(player.percentWatched * 100)}% of the video.`);
    
    // Example output: "The viewer has watched 75.25% of the video."
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onPercentWatchedChange={handlePercentWatchedChange} />
  );
}

readyState

Read only. Returns a value that expresses the current state of the element with respect to rendering the current playback position.

JavaScript propertyTypeExample values
readyStatenumber0, 4

Possible values:

ValueCorresponding stateDescription
0HAVE_NOTHINGNo information regarding the media resource is available.
1HAVE_METADATAEnough of the resource has been obtained that the duration of the resource is available.
2HAVE_CURRENT_DATAData for the immediate current playback position is available.
3HAVE_FUTURE_DATAData for the immediate current playback position is available and there is enough data for future playback without having to immediately revert to HAVE_METADATA.
4HAVE_ENOUGH_DATAAll previous conditions are met and data is loading at a pace which will not be overtaken by the default playback rate.

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(player.readyState)
  
  // Example output: 4
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handleApiReady() {
    if (player.current === null) { return; }
    console.log(player.readyState)
    
    // Example output: 4
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onApiReady={handleApiReady} />
  );
}

secondsWatched

Read only. Returns the number of unique seconds that have been watched for the media. This does not include seconds that have been skipped by seeking.

JavaScript propertyTypeExample values
secondsWatchednumber0, 24

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(`The viewer has watched ${player.secondsWatched} seconds.`);
  
  // Example output: "The viewer has watched 24 seconds."
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handleSecondChange() {
    if (player.current === null) { return; }
    console.log(`The viewer has watched ${player.secondsWatched} seconds.`);
    
    // Example output: "The viewer has watched 24 seconds."
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onSecondChange={handleSecondChange} />
  );
}

secondsWatchedVector

Read only. Returns an array where each index represents the number of times the viewer has watched each second of the media. This can be used to quickly determine if a viewer has missed or rewatched an important part of a video.

For example, if a media is 10 seconds long and the viewer has watched the first three seconds, it will look like this:

[1, 1, 1, 0, 0, 0, 0, 0, 0, 0]

If the viewer has watched the entire video once and rewatched the first 5 seconds, it will look like this:

[2, 2, 2, 2, 2, 1, 1, 1, 1, 1]
JavaScript propertyTypeExample values
secondsWatchedVectorobject[1, 1, 0, 0, 0], [1, 2, 1, 2, 2, 1, 1, 1]

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  player.addEventListener("ended", () => {
    var watchedVector = player.secondsWatchedVector;
    var watchedImportantSeconds = 0;
    for (var i = 4; i < 9; i++) {
      if (watchedVector[i] > 0) {
        watchedImportantSeconds += 1;
      }
     }
    if (watchedImportantSeconds < 2) {
      console.log("You should really go back and watch seconds 5 through 10. They're important!");
    }
  });
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handleEnded() {
    if (player.current === null) { return; }
    var watchedVector = player.secondsWatchedVector;
    var watchedImportantSeconds = 0;
    for (var i = 4; i < 9; i++) {
      if (watchedVector[i] > 0) {
        watchedImportantSeconds += 1;
      }
    }
    if (watchedImportantSeconds < 2) {
      console.log("You should really go back and watch seconds 5 through 10. They're important!");
    }
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onEnded={handleEnded} />
  );
}

state

Read only. Returns the current state of the media. The most common use case for state is implementing a play/pause toggle button.

JavaScript propertyTypeExample values
statestringtrue, false

Possible values:

ValueDescription
"beforeplay"Initial state of the media.
"playing"The media is currently playing.
"paused"The media was playing, but is now paused.
"ended"The media has ended playback.

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>
<button type="button" id="play-pause-button">Play / Pause</button>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  const customPlayPauseButton = document.getElementById('play-pause-button');

  customPlayPauseButton.addEventListener('click', () => {
    if (player.state === 'playing') { // Read player state
      player.pause();
    } else {
      player.play();
    }
  });
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handleClick() {
    if (player.current === null) { return; }
    
    if (player.state === 'playing') { // Read player state
      player.pause();
    } else {
      player.play();
    }
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" />
    <button type="button" onClick={handleClick}>Play / Pause</button>
  );
}

visitorKey

Read only. Returns the unique visitor key of the person watching the video. This is used to associate multiple viewing sessions with a single person. You can use it to filter events in the Stats API.

JavaScript propertyTypeExample values
visitorKeystring"123_abc", undefined

Example code:

<script src="https://fast.wistia.com/player.js" async></script>
<wistia-player id="my-player" media-id="abc123"></wistia-player>

<script>
  const player = document.getElementById('my-player'); // Finds the existing player
  console.log(`This viewer's visitor key is ${player.visitorKey}.`);
  
  // Example output: "This viewer's visitor key is 123_abc."
</script>
import { useRef } from "react";
import { WistiaPlayer } from "@wistia/wistia-player-react";

export default function App() {
  const player = useRef(null);
  
  function handlePlay() {
    if (player.current === null) { return; }
    console.log(`This viewer's visitor key is ${player.visitorKey}.`);
    
    // Example output: "This viewer's visitor key is 123_abc."
  }
  
  return (
    <WistiaPlayer ref={player} mediaId="abc123" onPlay={handlePlay} />
  );
}