Share plugin
With the Share plugin, you can add a share menu to the player that gives you the ability to share a link to your video. A share button can enhance user engagement and distribution while driving more traffic to your sites. To see the Share plugin in action, you can view this demo.
Available share menu option are summarized in the following table.
Share option | Description |
---|---|
Link | Copies a link to clipboard. |
Opens a Facebook share popup. | |
Opens a twitter tweet popup. |
Before you start
Before you use this plugin with the standalone player, we recommend the following steps:
- Read about embedding the core player in your site by adding the minimum CSS and JavaScript player components.
- Make sure you have a player token. For more, see Token configuration . Tokens aren't needed for local development.
- The instructions on this page generally assume you're using the Wowza Flowplayer CDN to embed the player in your site. If you're using npm, see our npm instructions or our TypeScript guide .
Install the plugin
To install the Share plugin, load it next to the core player:
<!-- Load standard player skin -->
<link rel="stylesheet" href="https://cdn.flowplayer.com/releases/native/3/stable/style/flowplayer.css">
<!-- Load player script -->
<script src="//cdn.flowplayer.com/releases/native/3/stable/flowplayer.min.js"></script>
<!-- Load plugin -->
<script src="//cdn.flowplayer.com/releases/native/3/stable/plugins/share.min.js"></script>
<!-- Optionally include the Message overlays plugin in to falsh message on the player when text is copied to the clipboard -->
<script src="//cdn.flowplayer.com/releases/native/3/stable/plugins/message.min.js"></script>
// Import player library and basic CSS for player
import flowplayer from "@flowplayer/player";
import "@flowplayer/player/flowplayer.css";
// Import share plugin and optional plugins
import Share from "@flowplayer/player/plugins/share";
import Message from "@flowplayer/player/plugins/message";
Add HTML elements
Add the HTML components to render the player elements on your page:
<div id="player"></div>
Configure the plugin
The plugin can be set up at the top-level configuration under the share
namespace. Configuration properties are outlined in the following table.
Property | Description |
---|---|
facebook boolean |
Determines whether to show the Facebook option. Value of link is used to determine what to share. |
iframe boolean or string |
If a string value is used, sets the iframe's src attribute based on the string. If a boolean is used and set to true , the link value serves as the source for the iframe. |
link boolean or string |
If a string value is used, can include URL to be shared or copied. When a boolean is used and set to true , returns the current URL of the webpage as a string, as in window.location.toString() . |
twitter boolean |
Determines whether to show the Twitter option. Value of link is used to determine what to share. |
Example
An example configuration for the Share plugin looks similar to this:
const player = flowplayer("#player", {
src: "//edge.flowplayer.org/drive.mp4",
token: "[your-player-token]",
share: {
link: true,
facebook: true,
twitter: false,
iframe: "https://example.com/iframe.html",
}
});