Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Overlay events #31

Open
wants to merge 24 commits into
base: development
Choose a base branch
from
Open

Conversation

sebastianpiq
Copy link

@sebastianpiq sebastianpiq commented Nov 27, 2024

This PR implements Overlays

Summary

This PR implements Overlay functionality, enabling the management and rendering of Overlay events within the player. The following changes were introduced:

  • Added parsing logic for events to retrieve and interpret Overlay events.
  • Extended the event controller to recognize and handle Overlay events.
  • Implemented a new method attachOverlayRenderingDiv to assign a dedicated div element for rendering overlays.
  • Created an OverlayController to manage Overlay events:
    • Differentiates between the various overlay event types: start, stop, and extend.
    • Includes a scheduler to manage the lifecycle of overlays, including starting, stopping, and extending them.
    • Applies styles dynamically to the overlay rendering div, video element, and parent element based on the following parameters:
      • ViewPort
      • Size
      • TopLeft
      • SqueezeCurrent

Assumptions

  • Overlay events are triggered only once. Once an overlay is displayed, it will not reappear.
  • Positioning elements at the same level as the video element and the overlay rendering div may lead to unexpected behavior.

Unit Tests

The following unit tests were added to ensure proper functionality:

configureVideoElementForOverlay

  • Test Case 1: Applies the correct style properties to the video element.
  • Test Case 2: Applies the correct style properties to the parent element.

setupOverlayEvents

  • Test Case 1: Executes without throwing errors.
  • Test Case 2: Handles triggering an empty event without errors.
  • Test Case 3: Handles start mode events with video mimetype without errors.
  • Test Case 4: Handles start mode events with iframe mimetype without errors.
  • Test Case 5: Handles extend mode events, ensuring the correct overlay is updated.
  • Test Case 6: Handles stop mode events, ensuring overlays are removed as expected.
    Each test validates that the system processes the corresponding overlay event type correctly without exceptions or unexpected behavior. Example for extend mode:
eventBus.trigger(Constants.OVERLAY.SCHEME_ID, { event: {
    overlay: { mode: Constants.OVERLAY.START_MODE, mimeType: Constants.OVERLAY.VIDEO_MIMETYPE },
    duration: 5, presentationTime: 3000, id: '1234'
}});
eventBus.trigger(Constants.OVERLAY.SCHEME_ID, { event: {
    overlay: { mode: Constants.OVERLAY.EXTEND_MODE, refId: '1234' },
    duration: 10, presentationTime: 4000
}});

Test cases

Assets used to test the different cases:

src/streaming/MediaPlayer.js Show resolved Hide resolved
src/dash/models/DashManifestModel.js Outdated Show resolved Hide resolved
src/streaming/MediaPlayer.js Show resolved Hide resolved
src/streaming/controllers/OverlayController.js Outdated Show resolved Hide resolved
src/streaming/controllers/OverlayController.js Outdated Show resolved Hide resolved
src/streaming/controllers/OverlayController.js Outdated Show resolved Hide resolved
test/unit/mocks/VideoModelMock.js Outdated Show resolved Hide resolved
src/streaming/controllers/OverlayController.js Outdated Show resolved Hide resolved
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.

4 participants