Socket
Socket
Sign inDemoInstall

@wistia/wistia-player

Package Overview
Dependencies
4
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @wistia/wistia-player

An embeddable wistia-player web component and React wrapper to add responsive, lightweight, and SEO-friendly videos to your site.


Version published
Weekly downloads
11K
decreased by-14.57%
Maintainers
2
Install size
9.63 MB
Created
Weekly downloads
 

Readme

Source

Wistia Player Web Component & React Wrapper

<wistia-player> is Wistia's embeddable web component and React wrapper which can be used to add responsive, lightweight, and SEO-friendly videos to your site.

Getting started

npm install @wistia/wistia-player

Web Component

Simple player

The only required attribute is media-id, the ID of the media that will be embedded.

import '@wistia/wistia-player';

<wistia-player media-id="abc123"></wistia-player>

Player with embed options

import '@wistia/wistia-player';

<wistia-player
  media-id="abc123"
  player-color="1e64f0"
></wistia-player>

React

Simple player

The only required prop is mediaId, the ID of the media that will be embedded.

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

<WistiaPlayer mediaId="abc123" />	

Player with embed options and event callback

The <WistiaPlayer> component takes the same options (as React props) which one can set on the <wistia-player> web component. There is a list at the Embed options support page. The only difference here is that numbers, booleans, etc are expected to be JS values of those types rather than strings. Event callbacks can also be added, formatted in a way which is familiar React development (e.g. the play event would become onPlay).

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

<WistiaPlayer	
  mediaId="abc123"	
  playerColor="1e64f0"	
  onPlay={() => console.log("Wistia video is playing!")}	
/>	

Additional Options

Avoiding layout shifts

The player will automatically load in a lightweight placeholder "swatch" image as soon as possible. However, in certain cases (such as server-side rendering) there can still be a slight layout shift while we wait for that placeholder. In order to avoid shift completely, you can explicitly set the aspect of your video:

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

<WistiaPlayer mediaId="abc123" aspect={16 / 9} />	
Fixed-size Embeds

The player is responsive by default. If a fixed-size player is better for your use-case, you can pass in width and height values instead:

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

<WistiaPlayer	
  mediaId="abc123"	
  style={{	
    width: '640px',	
    height: '360px',	
  }}	
/>	
Popovers

Wistia’s “popovers” are video embeds that open in modal overlays when a target element is clicked. For these embeds, there is an explicit, required wistiaPopover prop (true/false) as well as an optional popoverContent prop. If left undefined, the default popoverContent value is thumbnail. For popovers with popoverContent="link, the <WistiaPlayer> component expects to have children.

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

<WistiaPlayer mediaId="abc123" wistiaPopover={true} popoverContent="link">	
  <span>Popover Link</span>	
</WistiaPlayer>	

Keywords

FAQs

Last updated on 30 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc