9.10.1 • Published 12 days ago

@weltn24/videoplayer v9.10.1

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

WELT Video Player

This video player is a wrapper for the Bitmovin Player with its own module/plugin system. In production on welt.de.

Architecture

Architecture Schema

Bitmovin

Bitmovin Player Documentation - Often not complete, not up to date.

Bitmovin Slack Support Channel - Ask for help and advice. To get access, ask somebody from the 1UP team.

Axel-Springer & Bitmovin Bugtracking Repo - File an issue or report a bug.

Usage

yarn add @weltn24/videoplayer

To use the video player in your project follow that scheme:

import { VideoPlayerBuilder, VideoPlayer } from '@weltn24/videoplayer';

import { AdvertisementPlayerModule } from '@weltn24/videoplayer/dist/module/advertisement';
import { TrackingPlayerModule } from '@weltn24/videoplayer/dist/module/tracking';

// HTML Element where to render the player
const videoPlayerElement = document.getElementById('video-player-id');

// source configuration (here an example)
const config = {
    title: 'Foo bar title',
    poster: 'https://www.example.com/images/poster.jpg',
    sources: [
        {
            src: 'https://example.com/videos/foo.m3u8',
            extension: 'm3u8'
        },
        {
            src: 'https://example.com/videos/bar.mp4',
            extension: 'mp4'
        }
    ]
};

// modules to apply to the player
const modules = [new AdvertisementPlayerModule('https://www.domain.de/vast-url.vast'), new TealiumTrackingPlayerModule({ id: 'video-id' })];

// Create a new instance.
// The VideoPlayerBuilder handles the whole assembly process of a player instance.
const videoPlayer = new VideoPlayerBuilder(videoPlayerElement, config).withModules(modules).build();

await videoPlayer.init();

// Player controls.
await videoPlayer.play();
videoPlayer.pause();

// Destroying the player instance.
await videoPlayer.destroy();

Modules

Each player module is a class instance located at weltn24/videoplayer/dist/module/<MODULE_NAME>.

Here are some examples:

// basic player modules
import { PlayerExposalPlayerModule } from '@weltn24/videoplayer/dist/module/player-exposal';
import { VRPlayerModule } from '@weltn24/videoplayer/dist/module/virtual-reality';

const playerExposalPlayerModule = new PlayerExposalPlayerModule();
const vrPlayerModule = new VRPlayerModule();

// configurable modules
import { AnalyticsPlayerModule } from '@weltn24/videoplayer/dist/module/analytics';
import { TealiumTrackingPlayerModule } from '@weltn24/videoplayer/dist/module/tealium-tracking';

const analyticsPlayerModule = new AnalyticsPlayerModule('some-video-id');
const trackingPlayerModule = new TealiumTrackingPlayerModule({ id: 'video-id' });

The modules get passed to the VideoPlayerBuilder instance before calling videoPlayerBuilder.build().

Configuration

const config = {
    sources: [], // Mandatory list of playable video sources (URLs).
    apiKey: '', // Optional Bitmovin Player API key.
    title: '', // Optional title of the current video. This is part of the player UI.
    poster: '', // Optional poster image url. Gets displayed at the beginning, in the error and end screens.
    isPreload: false, // Optional flag for preloading the video (before user interacts). Default: false
    isAutoplay: false, // Optional flag for auto playing the video (depends on the browser). Default: false
    isMuted: true, // Optional flag for muting the video. Default: false
    startLivestreamFromBeginning: true // Optional flag for livestreams which should start from the beginning (e.g. for Bundesliga). Default: false
};

API

const videoPlayer = new VideoPlayerBuilder(videoPlayerElement, config).withModules(modules).build();

// Callbacks
videoPlayer.on('paused', event => {});
videoPlayer.off('paused', event => {});
videoPlayer.onPlay(event => {});
videoPlayer.onDestroy(event => {});
videoPlayer.onError(event => {});

// Controls
await videoPlayer.play();
videoPlayer.pause();
await videoPlayer.destroy();
await videoPlayer.scheduleAd({
    url: 'https://www.domain.com/vast.xml',
    type: 'vast',
    scheduleTime: 60
});

// State
const config = videoPlayer.getConfig();
const currentTime = videoPlayer.getCurrentTime();
const duration = videoPlayer.getDuration();
const initialized = videoPlayer.isInitialized();
const playing = videoPlayer.isPlaying();
const autoplay = videoPlayer.isAutoplay();
const fullscreen = videoPlayer.isFullscreen();
const live = videoPlayer.isLive();
const muted = videoPlayer.isMuted();
const adActive = videoPlayer.isAdActive();
const overlayActive = videoPlayer.isOverlayActive();

// UI
videoPlayer.showOverlay(document.getElementById('overlay'));
videoPlayer.closeOverlay();

Player modules

Purpose

Modules are a great way to reduce bundle size, improve loading time and extend the players' functionality. This feature enables the client to load modules dynamically and only when needed, and gain more control over the featureset of the video player.

Location

All player modules are located at:

  • @weltn24/videoplayer/dist/module/ for external usage
  • videoplayer/module/ in the source code

Modules

These are the currently available modules:

  • active-tab-watcher: Pauses video when switching tabs.
  • advertisement: Shows advertisement via Ad Technology (Media Impact).
  • amp: Special amp event mapping module to use the player in <amp-video-iframe> (see /amp.html)
  • analytics: Enables tracking via Bitmovin Analytics.
  • anti-ad-block: Shows advertisement even if an ad blocker is used (Schnee von Morgen).
  • chrome-cast: Enables streaming via Chromecast.
  • end-screen: Shows a screen with related videos after a video has finished playing. The first video will be played automatically after a few seconds if the user does not cancel the process.
  • error-screen: Shows an error screen for the video player when something went wrong.
  • inf-online-measurement-manager: Enables tracking via INFOnline Measurement Manager.
  • nielsen-tracking: Enables tracking via Nielsen.
  • player-exposal: Exposes the video player instances to window.__videoPlayerInstances (e.g. used by A/B testing team).
  • polyfill: Provides JS polyfills, mainly required for IE.
  • tealium-tracking: Enables tracking via Tealium.
  • thumbnail: Shows thumbnails when hovered over the seekbar.
  • unmute-ribbon: Shows a ribbon to unmute the video when it's played automatically and muted.
  • virtual-reality: This is the required core module to play VR/360 videos.
  • welt-plus-end-screen: Shows a Welt Plus screen after a video has finished playing.

Theme

The player provides a WELT specific theme. It can be used in two different ways:

Import

@import 'node_modules/@weltn24/videoplayer/dist/theme/css/welt-videoplayer-theme.css';

Mixin

@use 'node_modules/@weltn24/videoplayer/dist/theme/scss/welt-videoplayer-theme' as theme;

@include theme.create-welt-video-player-theme();

Setup

Node

Run nvm use or install the node version specified in the .nvmrc file from here.

Install

This project uses yarn, you can install it from here. Just run yarn to install all required packages.

Authentication

There are two keys for the bitmovin player. One development key that allows any host URL and should never be published, and one production key that allows only localhost and welt.de. You have to retrieve them from passwords (or from a coworker) and store them in the .env file as shown in the .env.example file.

Tasks

yarn analyze        # Analyze the player and the player modules with the webpack bundle analyzer
yarn start          # Start a webpack dev server on port 9000
yarn build          # Compile all SCSS and Typescript files into the dist folder, used for production
yarn test           # Run all tests with karma and generate a coverage report in /coverage
yarn lint           # Lint all SCSS and Typescript files
yarn release        # Release a new npm package version

The development server starts the test-cockpit which contains the video player and different configuration options for it.

Release

To release a new version to NPM run yarn release and answer the following questions. See release-it docs.

Attention - do not publish the development key! Use the production key only !

9.10.1

12 days ago

9.10.0

16 days ago

9.9.0

19 days ago

9.8.9

3 months ago

9.8.10

3 months ago

9.8.8

5 months ago

9.8.7

6 months ago

9.8.6

6 months ago

9.8.5

6 months ago

9.8.4

6 months ago

9.8.3

6 months ago

9.8.2

6 months ago

9.8.1

6 months ago

9.8.0

6 months ago

9.7.3

7 months ago

9.7.2

7 months ago

9.7.1

7 months ago

9.7.0

8 months ago

9.6.0

9 months ago

9.5.8

10 months ago

9.5.7

10 months ago

9.5.6

10 months ago

9.5.5

10 months ago

9.5.4

10 months ago

9.5.3

10 months ago

9.5.2

10 months ago

9.5.1

10 months ago

9.5.0

10 months ago

9.4.2

1 year ago

9.4.1

1 year ago

9.4.0

1 year ago

9.3.0

1 year ago

9.2.0

1 year ago

9.1.3

1 year ago

9.1.2

1 year ago

9.1.1

2 years ago

9.1.0

2 years ago

9.0.0

2 years ago

8.1.0

2 years ago

8.0.1

2 years ago

8.0.0

2 years ago

7.28.2

2 years ago

7.28.1

2 years ago

7.28.0

2 years ago

7.27.0

2 years ago

7.26.2

2 years ago

7.26.1

2 years ago

7.26.0

2 years ago

7.25.1

2 years ago

7.25.0

2 years ago

7.24.0

2 years ago

7.23.0

2 years ago

7.22.0

2 years ago

7.21.2

3 years ago

7.21.1

3 years ago

7.21.0

3 years ago

7.20.3

3 years ago

7.20.2

3 years ago

7.20.1

3 years ago

7.20.0

3 years ago

7.19.0

3 years ago

7.18.1

3 years ago

7.18.0

3 years ago

7.17.0

3 years ago

7.16.0

3 years ago

7.15.1

3 years ago

7.15.0

3 years ago

7.14.0

3 years ago

7.14.0-beta.2

3 years ago

7.14.0-beta.1

3 years ago

7.14.0-beta.0

3 years ago

7.13.0

3 years ago

7.12.1

4 years ago

7.12.0

4 years ago

7.11.0

4 years ago

7.10.1

4 years ago

7.11.0-alpha.2

4 years ago

7.11.0-alpha.1

4 years ago

7.11.0-alpha.0

4 years ago

7.10.0

4 years ago

7.9.0

4 years ago

7.8.0

4 years ago

7.7.1

4 years ago

7.7.0

4 years ago

7.6.5

4 years ago

7.6.4

4 years ago

7.6.3

4 years ago

7.6.2

4 years ago

7.6.1

4 years ago

7.6.0

4 years ago

7.5.0

4 years ago

7.4.2

4 years ago

7.4.1

4 years ago

7.4.0

5 years ago

7.3.0

5 years ago

7.2.0

5 years ago

7.1.1

5 years ago

7.1.0

5 years ago

7.0.0

5 years ago

6.3.2

5 years ago

6.3.1

6 years ago

6.3.0

6 years ago

6.2.2

6 years ago

6.2.1

6 years ago

6.2.0

6 years ago

6.1.1

6 years ago

6.1.0

6 years ago

6.0.0

6 years ago

5.1.3

6 years ago

6.0.2

6 years ago

5.1.2

6 years ago

5.1.1

6 years ago

5.1.0

6 years ago

5.0.1

6 years ago

5.0.0

6 years ago

4.2.6

6 years ago

4.2.5

6 years ago

4.2.4

7 years ago

4.2.3

7 years ago

4.2.2

7 years ago

4.2.1

7 years ago

4.2.0

7 years ago

4.1.4

7 years ago

4.1.3

7 years ago

4.1.2

7 years ago

4.1.1

7 years ago

4.1.0

7 years ago

4.0.2

7 years ago

4.0.1

7 years ago

4.0.0

7 years ago

3.4.1

7 years ago

3.4.0

7 years ago

3.2.0

7 years ago

3.1.0

7 years ago

3.0.6

7 years ago

3.0.5

7 years ago

3.0.4

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.3.1

7 years ago

2.2.3

7 years ago

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.8

7 years ago

2.1.7

7 years ago

2.1.6

7 years ago

2.1.5

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.1.1

7 years ago

2.0.0

7 years ago

1.1.3

7 years ago

1.1.1

7 years ago