npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@stroeer/stroeer-videoplayer-endcard-plugin

v5.1.4

Published

Ströer Videoplayer Endcard Plugin

Downloads

16

Readme

Stroeer Videoplayer Endcard Plugin


🧑‍💻 Development

Install dependencies via yarn install.

Build via yarn run build:endcard-plugin.

Start local dev environment via: yarn run dev

Start local server with index.html via yarn start

You can use yarn start and yarn watch in different terminals to see saved changes immediately. Important: You have to set the correct url of your API in index.html as data-endcard-url on video element.

Test via yarn run test:endcard-plugin.

For more commands see package.json

👾 Dependencies

This is a plugin for a videoplayer, make sure your videoplayer provide these functions.

The Stroeer Videoplayer Endcard Plugin works with data from a custom API but uses determined keys. So you have to provide these keys or you have to map these in the options object. For more information read next section.

😯 Notable features

The Stroeer Videoplayer Endcard Plugin uses determined data keys. If these keys are named different in your API, you can map as many keys as you like via dataKeyMap in options object.

myvideoplayer.initPlugin('endcard', {
  showEndcard: true,
	dataKeyMap: {
		// key of endcard, key from API
    poster: ‘preview_image’,
    endpoint: ‘endcard_url’,
    image_small: ‘thumbnail’,
    image_medium: ‘preview_image’,
    image_large: ‘preview_image’,
	},
})

API endpoint

These endpoint items are needed for the endcard plugin:

endpoint: string - link to the suggestions for this video

title: string - caption/title of the video

duration: number - duration of the video in seconds

image_small: string - poster image in small size for all images and a browser width less than 769px

image_medium: string - poster image in medium size for all images and a browser min-width: 769px

image_large: string - poster image in large size for the large image and a browser min-width: 769px

poster: string - poster image which will be set in the original video element after the endcard

playlists: array of strings - needed by the video player

An API example could look like this:

[
  {
    "title": "Elden Ring: Fundorte aller 7 legendären Zauber und Anrufungen",
		"duration": 137,
    "image_small": "https://files.giga-video.de/8b/8f/d4/ce5267fe9772673bb448ea25f9_ciAyNDYgMTM4AzhmYzJmNzZiNGFm.jpg",
    "image_medium": "https://files.giga-video.de/8b/8f/d4/ce5267fe9772673bb448ea25f9_ciAyNDYgMTM4AzhmYzJmNzZiNGFm.jpg",
    "image_large": "https://files.giga-video.de/8b/8f/d4/ce5267fe9772673bb448ea25f9_ciAyNDYgMTM4AzhmYzJmNzZiNGFm.jpg",
    "poster": "https://files.giga-video.de/8b/8f/d4/ce5267fe9772673bb448ea25f9_AzhmYzJmNzZiNGFm.jpg",
    "playlists": [
      "https://lx56.spieletips.de/2072001061_v4/playlist.m3u8",
      "https://vid-cdn60.stroeermb.de/2072001061_v4/playlist.m3u8",
      "https://vid-cdn61.stroeermb.de/2072001061_v4/playlist.m3u8"
    ],
    "endpoint": "https://videos-dev.giga.de/suggestions/2072001061"
  },
  {
  ...
  },
]

If there is a problem with the API then the fallback (only replay tile) is shown.

🔌 Options

You can see all available options here.

onLoadedCallback - Function

Callback which is triggered when Endcard is loaded and shown.

onClickToPlayCallback - Function

Callback which is triggered when user clicks on one tile except replay tile.

onClickToReplayCallback - Function

Callback which is triggered when user clicks on replay tile.

onRevolverplayCallback - Function

Callback which is triggered when an endcard video is started by revolverplay.

onRevolverplayPauseCallback - Function

Callback which is triggered when user clicks on "Anhalten"-button.

onPlayCallback - Function

Callback which is triggered when a new video is played no matter via click or via revolverplay

dataKeyMap - Object

Object to map keys of API data structure.

revolverplayTime - number

The number of seconds for the revolverplay countdown. If you set 0 then revolverplay is deactivated.

Default: 5

showFallback - boolean

If set to true the fallback (only replay tile) is shown.

Default: false

transformApiData - Function

A function which gets the current API Data after it got transformed by the dataKeyMap and should return a conformal data object. This function can be used to filter or manipulate the data in an data format compliant way.

Events

  • endcard-plugin:show
  • endcard-plugin:revolverplay-pause
  • endcard-plugin:click-to-replay
  • endcard-plugin:click-to-play
  • endcard-plugin:play
  • endcard-plugin:revolverplay

🌐 Real World Example

You can see a running example also in index.html

The only required data-attribute for the endcard to work is data-endcard-url.

<video id="myvideo" class="stroeervideoplayer" data-endcard-url="http://localhost:5000/">
	<source src="https://vid-cdn60.stroeermb.de/1307753225_v4/playlist.m3u8" type="application/x-mpegURL">
</video>
const myvideoplayer = new StroeerVideoplayer(video)
myvideoplayer.initPlugin('endcard', {
	revolverplayTime: 7,
	dataKeyMap: {
		image_large: 'preview_image',
		image_medium: 'preview_image',
		image_small: 'thumbnail'
	},
	onLoadedCallback: () => {
		console.log('OnLoadedCallback triggered')
 	},
 	onClickToPlayCallback: () => {
		console.log('onClickToPlayCallback triggered')
	},
	onClickToReplayCallback: () => {
		console.log('onClickToReplayCallback triggered')
	},
	onRevolverplayCallback: () => {
		console.log('OnRevolverplayCallback triggered')
 	},
 	onRevolverplayPauseCallback: () => {
		console.log('OnRevolverplayPauseCallback triggered')
	},
})

👗 Style

You have multiple scss variables to style your endcard.

$endcard-plugin-highlight-color: #424242 !default;
$endcard-plugin-bg-color: #000 !default;
$endcard-plugin-tile-border: 2px solid #fff !default;
$endcard-plugin-title-bg: linear-gradient(
  180deg,
  rgba(0, 0, 0, 0) 0%,
  rgba(0, 0, 0, 0.8) 100%
) !default;
$endcard-plugin-spacing-large: 16px !default;
$endcard-plugin-spacing-small: 12px !default;
$endcard-plugin-font-size-small: 12px !default;
$endcard-plugin-font-size-smaller: 10px !default;
$endcard-plugin-font-size-medium: 14px !default;
$endcard-plugin-font-size-large: 16px !default;
$endcard-plugin-text-color: #fff !default;
$endcard-plugin-button-pause-bg-color: rgba(255, 255, 255, 0.4) !default;
$endcard-plugin-button-pause-bg-color-hover: rgba(255, 255, 255, 0.2) !default;
$endcard-plugin-tile-overlay-bg: rgba(0, 0, 0, 0.4) !default;
$endcard-plugin-controlbar-height-mobile: 55px !default;