Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
bigscreen-player
Advanced tools
Simplified media playback for bigscreen devices.
The Bigscreen Player is an open source project developed by the BBC to simplify video and audio playback on a wide range of 'bigscreen' devices (TVs, set-top boxes, games consoles, and streaming devices).
$ npm install
Bigscreen Player uses requirejs for managing dependencies. Once you have required the player, a playback session can be initialised by simply calling the init()
function with some initial data.
The player will render itself into a supplied parent element, and playback will begin as soon as enough data has buffered.
// configure the media player that will be used before loading
// see below for further details of ths config
// options are: msestrategy, nativestrategy, hybridstrategy
window.bigscreenPlayer.playbackStrategy = 'msestrategy';
require(
[
'bigscreenplayer/bigscreenplayer',
'bigscreenplayer/windowtypes',
'bigscreenplayer/mediakinds'
],
function (BigscreenPlayer, WindowType, MediaKind) {
var bigscreenPlayer = BigscreenPlayer();
var playbackElement = document.createElement('div');
playbackElement.id = 'BigscreenPlayback';
var body = document.getElementByTagName('body')[0];
body.appendChild(playbackElement);
var minimalData = {
media: {
mimeType: 'video/mp4',
urls: [
{
url: 'https://www.cdn1url.com/reallygoodvideo'
}
]
}
}
var optionalData = {
initialPlaybackTime: 0, // Time (in seconds) to begin playback from
media: {
mimeType: 'video/mp4',
bitrate: 8940, // Displayed by Debug Tool
codec: 'h264',
kind: MediaKind.VIDEO, // Can be VIDEO, or AUDIO
urls: [
// Multiple urls offer the ability to fail-over to another CDN if required
{
url: 'https://www.cdn1url.com/reallygoodvideo',
cdn: 'cdn1' // Displayed by Debug Tool
}, {
url: 'https://www.cdn2url.com/reallygoodvideo',
cdn: 'cdn2'
}
],
captions: [{
url: 'https://www.somelovelycaptionsurl.com/captions/$segment$', // $segment$ required for replacement for live
segmentLength: 3.84, // Required to calculate live subtitle segment to fetch & live subtitle URL.
cdn: 'cdn1' // Displayed by Debug Tool
}, {
url: 'https://www.somelovelycaptionsurl2.com/captions/$segment$',
segmentLength: 3.84,
cdn: 'cdn1'
},
],
captionsUrl: 'https://www.somelovelycaptionsurl.com/captions/', // NB This parameter is being deprecated in favour of the captions array shown above.
subtitlesRequestTimeout: 5000, // Optional override for the XHR timeout on sidecar loaded subtitles
subtitleCustomisation: {
size: 0.75,
lineHeight: 1.10,
fontFamily: 'Arial',
backgroundColour: 'black' // (css colour, hex)
},
playerSettings: { // This currently can be used to customise settings for the msestrategy. It is a pass through of all the dash.js player settings.
streaming: {
bufferToKeep: 8,
...
}
}
}
}
// STATIC for VOD content, GROWING/SLIDING for LIVE content
var windowType = WindowType.STATIC;
var enableSubtitles = false;
bigscreenPlayer.init(playbackElement, optionalData, windowType, enableSubtitles);
}
)
The Bigscreen Player has some global configuration that is needed before initialisation. A playback strategy must be configured:
window.bigscreenPlayer.playbackStrategy = 'msestrategy' // OR 'nativestrategy' OR 'hybridstrategy'
See the configuration wiki page for further details on these strategies.
State changes which are emitted from the player can be acted upon to by registering a callback. The callback will receive all of the following state changes as the state
property of the event:
MediaState.STOPPED
MediaState.PAUSED
MediaState.PLAYING
MediaState.WAITING
MediaState.ENDED
MediaState.FATAL_ERROR
State changes may be registered for before initialisation and will automatically be cleared upon tearDown()
of the player.
var bigscreenPlayer = BigscreenPlayer();
// The token is only required in the case where the function is anonymous, a reference to the function can be stored and used to unregister otherwise.
var stateChangeToken = bigscreenPlayer.registerForStateChanges(function (event) {
if(event.state == MediaState.PLAYING) {
console.log('Playing');
// handle playing event
}
});
bigscreenPlayer.unRegisterForStateChanges(stateChangeToken);
Time updates are emitted multiple times a second. Your application can register to receive these updates. The emitted object contains the currentTime
and endOfStream
properties.
Time updates may be registered for before initialisation and will automatically be cleared upon tearDown()
of the player.
var bigscreenPlayer = BigscreenPlayer();
// The token is only required in the case where the function is anonymous, a reference to the function can be stored and used to unregister otherwise.
var timeUpdateToken = bigscreenPlayer.registerForTimeUpdates(function (event) {
console.log('Current Time: ' + event.currentTime);
});
bigscreenPlayer.unRegisterForTimeUpdates(timeUpdateToken);
This is emitted on every setSubtitlesEnabled
call. The emitted object contains an enabled
property.
This may be registered for before initialisation and will automatically be cleared upon tearDown()
of the player.
var bigscreenPlayer = BigscreenPlayer();
// The token is only required in the case where the function is anonymous, a reference to the function can be stored and used to unregister otherwise.
var subtitleChangeToken = bigscreenPlayer.registerForSubtitleChanges(function (event) {
console.log('Subttiles enabled: ' + event.enabled);
});
bigscreenPlayer.unregisterForSubtitleChanges(subtitleChangeToken);
Plugins can be created to extend the functionality of the Bigscreen Player by adhering to an interface which propagates non state change events from the player. For example, when an error is raised or cleared.
The full interface is as follows:
onError
onFatalError
onErrorCleared
onErrorHandled
onBuffering
onBufferingCleared
onScreenCapabilityDetermined
An example plugin may look like:
function ExamplePlugin (appName) {
var name = appName;
function onFatalError (evt) {
console.log('A fatal error has occured in the app: ' + name);
}
function onErrorHandled (evt) {
console.log('The ' + name + ' app is handling a playback error');
}
return {
onFatalError: onFatalError,
onErrorHandled: onErrorHandled
};
}
var bigscreenPlayer = BigscreenPlayer();
var examplePlugin = ExamplePlugin('myApp');
bigscreenPlayer.registerPlugin(examplePlugin);
// initialise bigscreenPlayer - see above
// you should unregister your plugins as part of your playback cleanup
// calling with no argument will unregister all plugins
bigscreenPlayer.unregisterPlugin(examplePlugin);
The project is fully unit tested using the Jasmine framework. To run the tests:
$ npm run spec
This project currently has unit test coverage but no integration test suite. This is on our Roadmap to address. Quality is ensured via extensive manual testing however.
When writing tests for your application it may be useful to use the mocking functions provided. This creates a fake player with mocking hook functions to simulate real world scenarios.
See here for example usage.
Create a PR.
Label the PR with one of these labels:
semver prerelease
semver patch
semver minor
semver major
along with one of the following:
has a user facing change
has no user facing changes
The labels-checker PR check will let you know if it is correct.
Get a review from the core team.
If the PR checks are green. The core team can merge to master.
Automation takes care of the package versioning.
Publishing to NPM is handled with our Travis CI integration.
The full api is documented here.
See CONTRIBUTING.md
The Bigscreen Player is available to everyone under the terms of the Apache 2.0 open source license. Take a look at the LICENSE file in the code for more information.
FAQs
Simplified media playback for bigscreen devices.
The npm package bigscreen-player receives a total of 6,500 weekly downloads. As such, bigscreen-player popularity was classified as popular.
We found that bigscreen-player demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.