share

The share plugin aims to provide a simple API for sharing accross different social networks: Facebook, twitter, tumblr and Google+.
State can be shared via share params that are added to the query string.

Example

// Share to twitter via API
player.share.share('twitter', {
    description: 'Check out this cool video!',
    tags: '@ekovideo #EkoMade'
});

// You can also trigger share by triggering an event
player.trigger('share', 'facebook', {
    description: 'I clicked the button and something weird happened..',
    image: 'https://url-to-an-image.jpg'
});

Init Options

options : object

Initialization options for the share plugin.

options.shortUrl : boolean
property

When set to true the plugin might shorten to URL to goeko.co.

Default: true
Example

// playerOptions.json
{
    "plugins": {
        "share": {
            "shortUrl": false
        }
    }
}

options.cacheKiller : boolean
property

When set to true the plugin will add a timestamp to each shared URL to prevent caching. While it is useful for development and testing, it should not be used in production environments.

Default: false
Example

// playerOptions.json
{
    "plugins": {
        "share": {
            "cacheKiller": true
        }
    }
}

Properties

player.share.version : string
propertyreadonly

The share plugin’s version string.

Example

console.log('The share plugin version is', player.share.version);

Methods

player.share.setShareParams(params)
method

Custom share can be achieved via share params - a set of params that will be added to the query string of the shared URL.

Param Type Description
params * an object of params to be added to the shared URL.

Example

// This will share https://myprojecturl.com?candidate=hilary&topic=economy
player.share.setShareParams({
    candidate: 'hilary',
    topic: 'economy'
});

player.share.updateOptions(options)
method

Update the plugin’s options and re-render the overlay. The provided options will be merged to the current options provided on the plugin’s init.
This method is usualy used to provide a share overlay after the share plugin was already initialized.

Param Type Description
options * Initialization options object. See the init options.

Example

// Use an overlay with id 'myshareOverlay' as the share overlay
player.share.updateOptions({
    overlayId: 'myshareOverlay'
});

player.share.share(platform, [options])
method

Share the video to a specific platform. While standard sharing meta data is usualy provided via tags in the page (e.g. og tags, twitter cards, schema.org) this function allows overriding the default values. This can be used to create a share experience that is personalized and relates to what the viewer achieved in the video.

See: share.beforeshare, share.aftershare

Param Type Description
platform string The platform to which the project will be shared: facebook, twitter, tumblr or googleplus.
[options] object An optional options object.
[options.title] string Override the default title (Facebook and Tumblr).
[options.description] string Tweet content or post’s description (All except Google+).
[options.caption] string Override the default caption (Facebook).
[options.image] string Override the default image (Facebook).
[options.tags] string Tags and mentions to add to the tweet (Twitter).
[options.disableShareParams] boolean Should the share params functionality be disbaled. Default is false.

Example

// Share to twitter
player.share.share('twitter', {
    description: 'Check out this cool video!',
    tags: '@ekovideo #EkoMade'
});

// You can also trigger share by triggering an event
player.trigger('share', 'facebook', {
    description: 'I clicked the button and something weird happened..',
    image: 'https://url-to-an-image.jpg'
});

Events

“share.beforeshare”
event

Triggered before sharing, allowing listeners to set share params.

See: share, setShareParams

Param Type
platform string

Example

player.on('share.beforeshare', function(platform) {
    player.share.setShareParams({
        candidate: 'hilary'
    });
});

“share.aftershare”
event

Triggered after sharing.

See: share

Param Type Description
platform string
url string the actual url that was shared (might include share params)
success boolean

Example

player.on('share.aftershare', function(platform, url, success) {
    if (!success) {
        console.log('failed sharing ' + url + ' to ' + platform);
    }                     
});
Rate this page: X
Tell us more!