Skip to content

Implement CMCD custom events & custom keys #7886

Description

@cotid-qualabs

Is your feature request related to a problem? Please describe.

The CMCD v2 implementation added in #7725 delegates all reporting to CmcdReporter from @svta/cml-cmcd, which natively supports two capabilities that are not accessible from hls.js's public API:

1. Custom keys. The CMCD spec allows players to include proprietary key-value pairs in reports using a reverse-DNS naming convention (e.g. com.example-myKey). The CmcdReporter supports this via reporter.update(), but there is currently no way to pass custom data through the hls.js config or API.

This matters for teams that want to include contextual data alongside standard CMCD fields. Some of these values are static; others need to be computed at the time of each request.

2. Custom events. CmcdReporter supports CmcdEventType.CUSTOM_EVENT, which allows players to send named events to an event-mode endpoint. hls.js currently only fires events internally (play state changes, bitrate changes, fatal errors). The CmcdReporter also supports custom events via reporter.recordEvent(), but there is currently no way to report custom events through the hls.js config or API.

Describe the solution you'd like

Currently there is no way to inject application-defined CMCD keys or fire CMCD v2 event reports after the player is initialized.

Expose update() and recordEvent() as public methods on CMCDController, delegating directly to the underlying CmcdReporter. The controller instance is accessible via hls.cmcdController, which becomes a public property.

This keeps the Hls class API surface clean (CMCD is optional), while giving integrators direct access to the CML reporter at runtime:

hls.cmcdController?.update({ 'com.myco-adBreak': true });
hls.cmcdController?.recordEvent('ce', { cen: 'chapter-change' });

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions