3.0.0 • Published 1 year ago

videojs-logo v3.0.0

Weekly downloads
1,724
License
MIT
Repository
github
Last release
1 year ago

videojs-logo

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

  • Abundant customization options
  • TypeScript support

video-js-logo-sample

If you think it's good, give me a star! :star:

Table of Contents

Installation

Using npm:

npm install videojs-logo

Using yarn:

yarn add videojs-logo

Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/videojs-logo@latest/dist/videojs-logo.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/videojs-logo@latest/dist/videojs-logo.css">

Using unpkg CDN:

<script src="https://unpkg.com/videojs-logo@latest/dist/videojs-logo.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/videojs-logo@latest/dist/videojs-logo.css">

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.

<!-- include stylesheets -->
<link href="//path/to/video-js.min.css" rel="stylesheet">
<link href="//path/to/videojs-logo.css" rel="stylesheet">

<!-- include scripts -->
<script src="//path/to/video.min.js"></script>
<script src="//path/to/videojs-logo.min.js"></script>

<!-- initialize videojs-logo -->
<script>
  var player = videojs('my-video');

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

ES Modules

Install videojs-logo via npm and import the plugin as you would any other module. \ You will also need to import the stylesheet in some way.

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';
import 'videojs-logo/dist/videojs-logo.css';

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

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

CommonJS

Install videojs-logo via npm and require the plugin as you would any other module. \ You will also need to import the stylesheet in some way.

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');
require('videojs-logo/dist/videojs-logo.css);

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

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

TypeScript

When using with TypeScript, you can use the VideoJsLogo namespace.

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

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

Compatibility

videojs-logo vs video.js

videojs-logovideo.js
v3.xv8.x
v2.xv7.x

License

MIT. Copyright (c) tapioca24

3.0.0

1 year ago

2.1.6

3 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago