Skip to content

Conversation

@sebastianpiq
Copy link

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @sebastianpiq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new sample application that showcases a 'Listen Mode' for alternative media presentations within a DASH stream. This mode allows for flexible insertion of alternative content into a live stream, initially without a fixed duration. The key innovation is the ability to later send a status update to the manifest, dynamically adding a maxDuration attribute to the ReplacePresentation event, which then signals the player to return to the original content. This provides a powerful mechanism for managing dynamic content insertions in live streaming scenarios.

Highlights

  • New Sample: Listen Mode for Alternative MPD: Introduces a new sample demonstrating a 'Listen Mode' for alternative media presentations, allowing for dynamic insertion and removal of alternative content in a live DASH stream.
  • Dynamic Manifest Modification: The sample showcases how to dynamically modify the Media Presentation Description (MPD) using a response interceptor to insert and update ReplacePresentation events.
  • Flexible Content Insertion: Demonstrates the ability to insert alternative content without an initial maxDuration, and then later update the event with a maxDuration (or maxDuration="0") to signal the player to return to the original stream.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a 'Listen Mode' sample for Alternative Media Presentations, which is a valuable addition. The implementation effectively uses a manifest response interceptor to dynamically manage events. My review includes suggestions for improving robustness and maintainability, such as adding input validation for user-provided values, ensuring unique event IDs, removing unused code, and refactoring duplicated logic for event creation. These changes will make the sample more resilient and easier to maintain.

function loadPlayer() {
const manifestUrl = document.getElementById('manifestUrl').value;
const alternativeUrl = document.getElementById('alternativeUrl').value;
const timeOffset = parseInt(document.getElementById('timeOffset').value);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The value from the timeOffset input is parsed with parseInt without validation. If a user enters non-numeric text (e.g., 'abc'), parseInt will return NaN. This NaN value is then used to calculate presentationTime, which also becomes NaN, causing the event logic to fail. You should validate the parsed value to ensure it's a number and handle the invalid input case gracefully.

Suggested change
const timeOffset = parseInt(document.getElementById('timeOffset').value);
const timeOffset = parseInt(document.getElementById('timeOffset').value, 10);
if (isNaN(timeOffset)) {
showStatus('Invalid Time Offset. Please enter a valid number.', 'danger');
return;
}

let eventId = 0;
const DEFAULT_DURATION = 10000; // 10 seconds
const DEFAULT_RETURN_OFFSET = 10000; // 10 seconds
const DEFAULT_MAX_DURATION = 10000; // 10 seconds

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The constant DEFAULT_MAX_DURATION is defined but never used in the script. It can be safely removed to improve code clarity.

statusDiv.style.display = 'block';
}

function updateManifestViewer() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for creating the alternative MPD event is duplicated in updateManifestViewer() (which builds an XML string for display) and addManifestResponseInterceptor() (which builds DOM elements to inject into the manifest). This can lead to inconsistencies if one is updated and the other is not.

Consider refactoring this into a single function that creates the event structure as DOM elements. addManifestResponseInterceptor can then directly use these elements, and updateManifestViewer can serialize and highlight them. This would centralize the event creation logic and improve maintainability.

showStatus(`Status update sent. Main content will return soon.`, 'warning');
}

function addManifestResponseInterceptor(manifestUrl) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The manifestUrl parameter is passed to the addManifestResponseInterceptor function but it is not used within the function. It can be removed from the function signature and from the call at line 343 to simplify the code.

Suggested change
function addManifestResponseInterceptor(manifestUrl) {
function addManifestResponseInterceptor() {

const presentationTime = Date.now() + (timeOffset * 1000);

replaceEvent = {
id: eventId,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The eventId is always assigned the value 0. If the player is reloaded by clicking the button again, a new event will be created with the same ID. While this might work in this specific sample because the old event stream is removed before adding a new one, it's better practice to ensure unique event IDs per the DASH-IF specification. Consider incrementing eventId after each use to guarantee uniqueness.

Suggested change
id: eventId,
id: eventId++,

@cotid-qualabs cotid-qualabs merged commit 36d6359 into feature/alternative-media-presentations Oct 15, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants