Sharing

You want your videos to reach audiences beyond your own site? - No problem. Flowplayer features a share menu out of the box. With one click viewers can

  • share your videos on the Twitter and Facebook social networks
  • embed your videos in their own site

Let your videos go viral with Flowplayer!

Twitter

When the viewer clicks on the "twitter" icon in the share menu, the Twitter share window pops up. If confirmed, by default the video content is shared and played in the current Flowplayer setup, including the hlsjs plugin on Twitter.

Alternatively you can configure a share URL.

Facebook

When the viewer clicks on the "facebook" icon in the share menu, the Facebook share window pops up. If confirmed, by default the current page's URL will be shared on Facebook. Open Graph meta tags in the page's HEAD section will be evaluated.

Note: Facebook, contrary to Twitter, so far does not allow sharing of HTML5 media players; therefore Facebook sharing is disabled by default.

Alternatively you can configure a share URL.

Embedding

When the end user clicks the "embed" icon in the share menu, the embed code is copied to the clipboard and the user notified of this fact.

This can be pasted into any website's source code, and the player will work in place. The embed code has the following features:

  1. The layout of the embedded player is responsive by default. The embedded player adapts its width to the parent element on the embedding page, and the height is determined by the value of original ratio option as recommended in the instructions for player size.
  2. If the hlsjs plugin is loaded it will also be enabled in the embedded players.
  3. If Google Analytics is enabled the embedded players will also track to your Analytics account.
  4. Embedded players can be further embedded.

How does it look?

Embed code taken from this player.

Custom branding and returning visitors

A commercially licensed player propagates the commercial configuration to draw traffic to your site.

If you configured your own logo it will be displayed in all embedded players:

flowplayer.conf.logo = '//mydomain.com/logo.png';

JavaScript

When the user clicks the logo she will be redirected to the originating page on your site. The same applies to the brand field in the controlbar if configured.

HTTPS

As you have no control where the player will be shared/embedded make sure that both the Flowplayer assets and the videos are accessible via HTTPS by configuring them independently of the access protocol.

If that is not possible because of differing locations for HTTP and HTTPS you must hard code the HTTPS locations to avoid errors.

  • Important HTTP only embed offers are not reliable.

Disabling sharing

To prevent your content from propagating simply set the share option to false.

For example you can prevent the embed offer for all players on the page in the global configuration:

flowplayer.conf.share = false;

JavaScript

The boolean version can also be applied in HTML syntax as data-share="false" to specific VIDEO tag based installations.

Configuration

Player options

On the player level sharing is governed by the following options:

propertytypedescription
embedBooleanIf true (the default), the offered embed code will generate a player with your setup on the embedding page.
If set to false, embedding is disabled, and the "embed" entry does not appear in the share menu.
embedObjectIf configured in JSON the embedded player setup can be customized or extended with embed options to fine tune the embedding feature.
facebookBooleanIf false (the default), sharing to Facebook is disabled and the "facebook" entry does not appear in the share menu.
If set to true, the current page will be shared on Facebook. If the page features appropriate Open Graph meta tags, video content will be shared like at this demo page.
facebookStringIf configured as string, sets the URL of a page to share on Facebook. This page can feature Open Graph meta tags to share video content.
shareBooleanIf true (the default), sharing is enabled and the share menu is shown.
If set to false, sharing is disabled entirely, and the share menu is not available.
twitterBooleanIf true (the default), the video content and player setup will be shared on Twitter with a player card created on the fly.
If set to false, sharing to Twitter is disabled, and the "twitter" entry does not appear in the share menu.
twitterStringIf configured as string, sets the URL of a page to share on Twitter. This page can feature player card meta tags which will share the video in a Flowplayer setup like this demo page.

Embed options

By default the embed feature loads the embed script and Flowplayer assets from our CDN. This can be customized in the embed configuration object if you prefer to host the files yourself.

When specified as object embed accepts the following properties:

optiondefault valuedescription
heightHeight of embedded player. Default is responsive, according to the embedded player's aspectRatio or ratio settings.
iframeURL of IFRAME used for embedding.
library//releases.flowplayer.org/7.0.2/flowplayer.min.jsURL of the Flowplayer API library script.
script//embed.flowplayer.org/7.0.2/embed.min.jsURL of the embed script.
skin//releases.flowplayer.org/7.0.2/skin/skin.cssURL of skin for embedding.
swf//releases.flowplayer.org/7.0.2/flowplayer.swfURL of SWF file for embedding.
swfHls//releases.flowplayer.org/7.0.2/flowplayerhls.swfURL of Flash HLS SWF file for embedding.
width100%Width of embedded player. Default is responsive, filling the parent element's width.

The global configuration is a good place to configure embedding because it applies to all players on your page. Example:

flowplayer.conf = {
embed: {
library: "//mydomain.com/js/flowplayer.min.js",
script: "//mydomain.com/js/embed.min.js",
skin: "//mydomain.com/css/functional.css",
swf: "//mydomain.com/swf/flowplayer.swf",
swfHls: "//mydomain.com/swf/flowplayerhls.swf"
}
};

JavaScript

Note: The locations must not be paths but full URLs.

This way you can for instance propagate your own customized skin. Note: In this case make sure that the skin fonts are served with the appropriate cross-origin policy (CORS).

Ideally you want to make all required Flowplayer assets available via both the http: and https: protocols. As with the default locations this can be achieved by simply omitting the protocol from the URL - as long as the files are available at that location via both protocols. If not you should use a secure location because modern browsers become ever stricter when it comes to loading from insecure locations into a secure page.

Iframe embedding

Offering an IFRAME for embedding allows to propagate more involved setups. Check out the quality selector demo, and try its embed code.

  • Important To enable the embedded player to go fullscreen the fullscreen and native_fullscreen player options must be set explicitly to true.

See this demo and its embed result for details.

  • Tip On the IFRAME page add overflow: hidden CSS rules to avoid scrollbars around the embedded player.

JavaScript API

Properties

propertytypedescription
embedCodefunctionExposes the embedCode() method for customization in the global API setup.

This allows you to offer an embed code entirely tailored to your needs in a mini plugin:

flowplayer(function (api) {
api.embedCode = function () {
// your own embed code
return '<div>My Embed Code</div>';
};
});

JavaScript

Take the default embedCode function as inspiration.

Methods

The embedding extension provides the following API method:

methoddescription
embedCode()Returns the complete embed code offered by this player.
Note that this method therefore cannot return the API.
tweet()Opens the Twitter share popup window for this player.