Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including videojs-logo with all npm packages installed. Try it out:

var videojsLogo = require("videojs-logo")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

videojs-logo v2.1.0

A video.js plugin to display a logo image on the player.

videojs-logo

A video.js plugin to display a logo image on the player.

  • Abundant customization options
  • TypeScript support

video-js-logo-sample

Table of Contents

## Installation
npm install --save videojs-logo

Usage

To include videojs-logo on your website or web application, use any of the following methods.

<script> Tag

This is the simplest case. Get the script in whatever way you prefer and include the plugin after you include video.js, so that the videojs global is available.

<script src="//path/to/video.min.js"></script>
<script src="//path/to/videojs-logo.min.js"></script>
<script>
  var player = videojs('my-video');

  player.logo({
    image: 'my_logo.png'
  });
</script>

Browserify/CommonJS

When using with Browserify, install videojs-logo via npm and require the plugin as you would any other module.

var videojs = require('video.js');

// The actual plugin function is exported by this module, but it is also
// attached to the `Player.prototype`; so, there is no need to assign it
// to a variable.
require('videojs-logo');

var player = videojs('my-video');

player.logo({
  image: 'my_logo.png'
});

Browserify/ES6

When using with Browserify, install videojs-logo via npm and import the plugin as you would any other module.

import videojs from 'video.js';

// The actual plugin function is exported by this module, but it is also
// attached to the `Player.prototype`; so, there is no need to assign it
// to a variable.
import 'videojs-logo';

const player = videojs('my-video');

player.logo({
  image: 'my_logo.png'
});

RequireJS/AMD

When using with RequireJS (or another AMD library), get the script in whatever way you prefer and require the plugin as you normally would:

require(['video.js', 'videojs-logo'], function(videojs) {
  var player = videojs('my-video');

  player.logo({
    image: 'my_logo.png'
  });
});

TypeScript

When using with TypeScript, install videojs-logo via npm and import the plugin as you would any other module.
You can use the VideoJsLogo namespace.

import videojs, { VideoJsLogo } from 'video.js';
import 'videojs-logo';

const player = videojs('my-video');

const options: VideoJsLogo.Options = {
  image: 'my_logo.png'
};
player.logo(options);

Configuration

PropertyAttributesTypeDefault valueDescription
imageRequiredStringThe URL to the logo image.
urlOptionalStringA url to be linked to from the logo. If the user clicks the logo the link will open in a new window.
positionOptionalString"top-right"The location to place the logo (top-left, top-right, bottom-left, or bottom-right).
offsetHOptionalNumber0Horizontal offset (px) from the edge of the video.
offsetVOptionalNumber0Vertical offset (px) from the edge of the video.
widthOptionalNumberThe width of the logo image (px). If not specified, it will be the width of the original image.
heightOptionalNumberThe height of the logo image (px). If not specified, it will be the height of the original image.
paddingOptionalNumber5Padding around the logo image (px).
fadeDelayOptionalNumber, Null5000Time until fade-out begins (msec). If null is specified, automatic fade-out is not performed.
hideOnReadyOptionalBooleanfalseDo not show the logo image when the player is ready.
opacityOptionalBoolean1The opacity of the logo (from [0, 1]). If not specified, it will default to 1

Methods

You can also manually show / hide the logo image at any time.

// To show the logo image on the player's play event:
player.on('play', () => {
  player.logo().show();
});
MethodDescription
show()Show the logo image
hide()Hide the logo image

License

MIT. Copyright (c) tapioca24

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free