Brightcove Player Pre-releases v6.46.0
The Brightcove Player 6.46.0 is available for early access and testing. Notable changes since 6.45.4 include:
Support for Multilingual Metadata
Multilingual Metadata is a feature of the CMS API that allows you to provide video metadata such as the title and description in multiple languages. If set, these variants
are included in Playback API response that the player uses.
From 6.46.0 forward, when the player loads a new video from a Playback API response, it will look for an entry in the variants
(if any) for one that matches the player's language. If a match is found, that variant will be used in the player UI in the "dock" where the title and description are displayed.
Additionally, any subtitles or captions track that matches the variant language will be selected as the default (unless one is explicitly marked as default already).
catalog.getMetadata
Method
As part of this feature, a new utility method was added to the player: catalog.getMetadata
, which can be used to get an object or array representation of the current video or playlist metadata.
It can be given an options object with up to two possible properties:
lang
This option allows you to get a representation of video or playlist metadata with the matching variant merged into the top-level metadata object.
For example, assume you have a video with metadata in English by default and a Spanish variant. A simplified set of metadata may look something like:
{
"title": "Title of a Video",
"variants": [{
"language": "es",
"title": "Título de un video"
}, {
// This "null" variant is added by the player to represent the default field values!
language: null,
"title": "Title of a Video"
}]
}
Given that, you can retrieve a Spanish representation by:
player.catalog.getMetadata({lang: 'es'});
Which will return something like this where variants
are still included, but the top-level title
matches the Spanish variant:
{
"title": "Título de un video",
"variants": [{
"language": "es",
"title": "Título de un video"
}, {
language: null,
"title": "Title of a Video"
}]
}
In this way, you can easily get the current video metadata as it should be represented for the user's current player language:
var metadata = player.catalog.getMetadata({
lang: player.language()
});
With that, you can do anything you need with metadata
properties knowing that they'll be in the player's language if a variant was available for it!
type
This can be 'video'
(the default) or 'playlist'
.
When type: 'video'
(or no value) is given, metadata for the currently selected video will be returned - regardless of whether the player is playing a single video or playlist.
When type: 'playlist'
is given and a playlist is in use, metadata for the entire playlist - an array - will be returned. If no playlist is available, it will fall back to returning the current video; so, it's a good idea to check the return value type in this case (e.g., using Array.isArray
)!
This option can be combined with the lang
option; so, for example, you can retrieve a translated representation of a playlist with a call like:
var playlistMetadata = player.catalog.getMetadata({
lang: player.language(),
type: 'playlist'
});
Bug Fixes
- Fix cases where
player.language()
returnedundefined
by default. - Fix a case where catalog parameter defaults could conflict between players on the same page.
- This was unlikely to have affected anyone except, perhaps, in rare cases where players from multiple accounts and of the same version were on the same page.