OpencastInitParams
The OpencastInitParams interface extends the standard Paella Player initialization parameters with Opencast-specific options.
OpencastInitParams Interface
Section titled “OpencastInitParams Interface”export interface OpencastInitParams extends InitParams { opencast?: { presentationUrl?: string | null auth?: OpencastAuth | null videoId?: string | null paellaConfig?: string | Partial<Config> | null episode?: string | null }}Properties
Section titled “Properties”presentationUrl
Section titled “presentationUrl”presentationUrl?: string | nullBase URL of the Opencast presentations server. This URL is used to construct all relative URLs to Opencast services.
Example:
presentationUrl: 'https://opencast.example.com'auth?: OpencastAuth | nullCustom authentication system instance. If not provided, OpencastAuthDefaultImpl is used.
videoId
Section titled “videoId”videoId?: string | nullIdentifier of the video/event to play. If not provided, it attempts to get it from:
- URL parameter
id - URL hash
fallbackIdfrom configuration
paellaConfig
Section titled “paellaConfig”paellaConfig?: string | Partial<Config> | nullPaella Player configuration. Can be:
- String: JSON string that will be parsed
- Object: Partial configuration object
- null: Will be loaded from configuration file
episode
Section titled “episode”episode?: string | nullEvent data in JSON string format. If provided, it’s used directly without making additional requests to the server.
Helper functions
Section titled “Helper functions”defaultLoadConfigFunc
Section titled “defaultLoadConfigFunc”export async function defaultLoadConfigFunc(configUrl: string, player: Paella): Promise<Config>Default function for loading Paella Player configuration from Opencast.
Behavior:
- If
paellaConfigis a string, parses it as JSON - If
paellaConfigis an object, uses it directly - If there’s no
paellaConfig, loads from the provided URL - Builds relative URLs using
presentationUrl
defaultGetVideoIdFunc
Section titled “defaultGetVideoIdFunc”export async function defaultGetVideoIdFunc(config: Config, player: Paella): Promise<string | null>Default function for getting the video ID.
Priority order:
videoIdfromOpencastInitParams- URL parameter
id fallbackIdfrom configuration- Throws error if no ID is found
defaultLoadVideoManifestFunc
Section titled “defaultLoadVideoManifestFunc”export async function defaultLoadVideoManifestFunc(_manifestUrl: string, _config: Config, player: Paella): Promise<Manifest>Default function for loading the video manifest from Opencast.
Behavior:
- If there’s data in
episode, uses it directly - If not, makes request to
/search/episode.json?id=${videoId} - Auto-discovers if it’s search API or external API
- Converts data to Paella
Manifestformat
Automatic configuration
Section titled “Automatic configuration”When creating an OpencastPaellaPlayer, default functions are automatically configured:
const player = new OpencastPaellaPlayer('container', { // Automatically configured: // loadConfigFunc: defaultLoadConfigFunc // getVideoIdFunc: defaultGetVideoIdFunc // loadVideoManifestFunc: defaultLoadVideoManifestFunc});Usage examples
Section titled “Usage examples”Basic configuration
Section titled “Basic configuration”const player = new OpencastPaellaPlayer('player-container', { opencast: { presentationUrl: 'https://opencast.example.com', videoId: 'event-123' }});With custom configuration
Section titled “With custom configuration”const player = new OpencastPaellaPlayer('player-container', { opencast: { presentationUrl: 'https://opencast.example.com', videoId: 'event-123', paellaConfig: { // Specific player configuration plugins: { // plugin configuration } } }});With predefined event data
Section titled “With predefined event data”const eventData = JSON.stringify({ // Opencast event data mediapackage: { id: 'event-123', title: 'My event' // ... more data }});
const player = new OpencastPaellaPlayer('player-container', { opencast: { presentationUrl: 'https://opencast.example.com', episode: eventData }});With custom authentication
Section titled “With custom authentication”import { OpencastAuth } from '@asicupv/paella-opencast-core';
class CustomAuth implements OpencastAuth { // Custom implementation}
const player = new OpencastPaellaPlayer('player-container', { opencast: { presentationUrl: 'https://opencast.example.com', videoId: 'event-123', auth: new CustomAuth() }});API auto-discovery
Section titled “API auto-discovery”The system can automatically work with two types of Opencast APIs:
-
Search API (Engage Service)
When making a request to
/search/episode.json, the converter automatically detects the format and usesEngageEventConversor. -
External API
If data comes from the external API,
APIEventConversoris automatically used.