Skip to content

Conversation

@sebastianpiq
Copy link
Contributor

Description

Implementation of Alternative Media Presentations as defined in DASH 6 specification. This PR adds support for two new event types that enable dynamic content switching during playback:

  • Replace: Replaces main content with alternative content
  • Insert: Inserts alternative content, then returns to the same point in main content

Changes

Alternative Events Attributes Support

  • earliestResolutionTimeOffset: Time before event trigger when alternative media resolution begins
  • maxDuration: Maximum duration for alternative content
  • noJump: Prevents skipping of events
  • clip: Limits alternative content duration to main content duration
  • startAtPlayhead: Used with non-clip content, alternative content starts offset by the delay from event trigger
  • returnOffset: Offset applied when returning to main content after alternative content ends

Core Changes

  • EventController: Added support for events with earliestResolutionTimeOffset, noJump, and re-triggerable events
  • MediaPlayer: Extended API to support video element assignment for alternative media
  • AlternativeMediaController (new): Controller to manage alternative events
  • MediaManager (new): Module to handle multiple dash instances and video elements

New Events

  • alternativeContentStart: Fired when alternative content starts playing
  • alternativeContentEnd: Fired when alternative content finishes playing

Implemented Use Cases

  • VOD to VOD (insert and replace)
  • Live to VOD (replace)
  • Live to Live (replace)

Listen Mode Implementation

Using events with 'update' status, the duration of alternative content can be dynamically modified to extend or end earlier than originally planned.

Testing

Unit Tests:

  • EventController
  • AlternativeMediaController
  • MediaManager

Functional Tests:

  • Basic Alternative Media Presentations - Insert and Replace
  • Alternative Media Presentations with clip attribute
  • Alternative Media Presentations with noJump attribute
  • Alternative Media Presentations with earliestResolutionTimeOffset
  • Alternative Media Presentations with maxDuration
  • Alternative Media Presentations with startAtPlayhead attribute
  • Alternative Media Presentations - Listen Mode (update events)
  • Alternative Media Presentations - Live to Live
  • Alternative Media Presentations - Live to VOD
  • Alternative Media Presentations - Multiple alternative presentations
  • Alternative Media Presentations - Re-triggerable events

Sample Pages

Three example pages have been created to demonstrate the implementation:

  • alternative-media-presentations.html: General usage examples
  • live-to-live.html: Live content with alternative live content
  • listen-mode.html: Listen mode demonstration

Known Issues

This solution uses the preload() method, which has issues with multi-period assets. Therefore, alternative content cannot be multi-period.

sebastianpiq and others added 30 commits November 5, 2024 14:56
cotid-qualabs and others added 28 commits September 23, 2025 11:53
…ack-to-main-content

Media manager unit test: switch back to main content
…ve-media-presentations/media-manager-unit-tests
…media-manager-unit-tests

Alternative media presentations: media manager unit tests
…live-to-live-switch-back

feat: Implement live to live switch back
* alternative clip functional test vod to vod

* small refacotr alternative replace live functional test

* add clip live to live test case

* fix clip for live to live

* Update test/functional/test/feature-support/alternative/alternative-mpd-clip-vod.js

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* remove comment

* Update src/streaming/controllers/AlternativeMediaController.js

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* rename deltaTime

* remove comments

* add missing clear timeouts

* add missing done

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…in EventController and AlternativeMediaController
…update-and-listen-mode

Add Alternative event update and listen mode
…validity-expiration

Revert "Feature MPD  update on validity expiration"
…listen-mode-sample-page

Add Listen Mode sample and update samples.json with new entry
@dsilhavy dsilhavy added this to the 5.2.0 milestone Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.