Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

AddOns

Sharing Plugin Reference

The purpose of this guide is to be a reference for you as you get started with the latest version of the Sharing plugin for the JW Player.

Introduction

The sharing plugin works in both Flash and HTML5 mode. It provides a dialog window with two input fields:

Below the input fiels, shortcuts are provided for sharing the video link on Facebook and Twitter

The sharing plugin in action

Note that, with Facebook, it is possible to share an inline video player by setting some meta tags in the <head> of your page.

Configuration Options

The plugin is loaded with the plugins=sharing-3 option in the JW Player. This ensures you load version 3 of the plugin, which includes HTML5 support. In addition to the plugin assignor, two dedicated flashvars are supported:

sharing.link ( undefined )
URL to display in the Video Link field of the plugin, for example http://example.com/videos/12345/.
If no link is set, the URL of the current page is automatically used.
sharing.code ( undefined )
Embed code to display in the Embed Code field of the plugin. If no code is set, the field is not shown. Example code:
<embed 
  src="http://example.com/player.swf" 
  width="480" 
  height="270" 
  allowfullscreen="true" />

Since the embed code may contain special characters like <, " or &, you should URIEncode the string in the embed code of your player. The JW Player will automatically decode your string when it is loaded. See the beginning of this guide for more info.

Example

Here is a basic embed code example of a player using the sharing plugin. This example uses the JW Embedder:

<p id="container">The player will be placed here</p>

<script type="text/javascript">
 jwplayer("container").setup({
   file: "/static/video/1775.mp4",
   flashplayer: "player.swf",
   height: 270,
   plugins: {
     "sharing-3": {
       code: "%3Cembed src%3D%22http%3A%2F%2Fexample.com%2Fembeds%2F123.swf
              %22width%3D%22320 %2F%3E",
       link: "http://www.website.com/videos/1775/"
     }
   },
   width: 480
 });
</script>

Using Playlists

In addition to setting them in the embed code, the two sharing options can also be set per playlist entry. This works for both inline playlists and XML playlists.

Since none of the XML playlist formats define elements for setting sharing links and codes, the two options should be set using the JWPlayer XML namespace. In practice, the namespace is enabled by:

Example

Here is a basic example; an RSS playlist with one entry that has both a sharing.link and sharing.code defined.

<rss version="2.0" xmlns:jwplayer="http://developer.longtailvideo.com/">
 <channel>
   <title>Example RSS playlist with sharing options</title>

   <item>
     <title>Both code and link</title>
     <enclosure url="http://content.bitsontherun.com/videos/nPripu9l.mp4" />
     <jwplayer:sharing.link>http://example.com/1234/</jwplayer:sharing.link>
     <jwplayer:sharing.code>
       <![CDATA[
         <embed src="http://example.com/players/nPripu9l-ALJ3XQCI.swf" 
           width="480" height="270" allowfullscreen="true" />
       ]]>
     </jwplayer:sharing.code>
   </item>

 </channel>
</rss>
Since the embed code may contain special characters like <, " or &, you should enclose it in CDATA tags in the playlist, as displayed in the above example. Otherwise, the XML syntax of the playlist will be broken. See the playlist support guide for more info.

Rendering Modes

All functionalities of the plugin are available in both Flash and HTML5 mode, except for the Copy buttons on top of the input fields. Since JavaScript does not provide any clipboard functionalities, viewers have to manually select and copy the text in the field.

Playlists, both inline and RSS, are fully supported in HTML5.

When using this plugin in HTML5 mode, it is best to use <iframe> embed codes instead of <embed> embed codes, since some HTML5 devices (like the iPad) do not support Flash. Please see our Setting clean embed codes guide for more info.

Changelog

Version 3.0