Skip to content

Support all video formats inside in-app and inbox players#981

Open
piyush-kukadiya wants to merge 1 commit intotask/release/8.1.0from
fix/inapps_inbox/exoplayer_support_all_video_format
Open

Support all video formats inside in-app and inbox players#981
piyush-kukadiya wants to merge 1 commit intotask/release/8.1.0from
fix/inapps_inbox/exoplayer_support_all_video_format

Conversation

@piyush-kukadiya
Copy link
Copy Markdown
Contributor

@piyush-kukadiya piyush-kukadiya commented Apr 2, 2026

Replace hardcoded HlsMediaSource.Factory with DefaultMediaSourceFactory in all 4 ExoPlayer/Media3 handle files (inapps + inbox). This enables auto-detection of video format (MP4, HLS, DASH, etc.) from URI, aligning with PIP player behavior. Existing HLS streams continue to work since the HLS module dependencies are still included.

Summary by CodeRabbit

  • Refactor
    • Modernized video playback infrastructure across in-app and inbox video components to streamline media source initialization and configuration.

Replace hardcoded HlsMediaSource.Factory with DefaultMediaSourceFactory
in all 4 ExoPlayer/Media3 handle files (inapps + inbox). This enables
auto-detection of video format (MP4, HLS, DASH, etc.) from URI, aligning
with PIP player behavior. Existing HLS streams continue to work since
the HLS module dependencies are still included.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

Walkthrough

The PR refactors ExoPlayer initialization across 4 video handling files by replacing HLS-specific media source construction with a generic DefaultMediaSourceFactory approach and setting MediaItem directly instead of pre-built HLS media sources, while consolidating initialization logic.

Changes

Cohort / File(s) Summary
inapps video handlers
clevertap-core/src/main/java/com/clevertap/android/sdk/video/inapps/ExoplayerHandle.kt, Media3Handle.kt
Replaced explicit HlsMediaSource creation with DefaultMediaSourceFactory(dataSourceFactory) wired into the player, switching from setMediaSource(hlsMediaSource) to setMediaItem(mediaItem) pattern.
inbox video handlers
clevertap-core/src/main/java/com/clevertap/android/sdk/video/inbox/ExoplayerHandle.kt, Media3Handle.kt
Consolidated bandwidth meter, user-agent, and data source factory initialization from startPlaying() into initExoplayer(), then wired DefaultMediaSourceFactory into player builder. Media source setup now uses setMediaItem() instead of explicit HLS source construction.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • PR #770: Modifies the context passed into initExoplayer(), directly related to the media-source and data-source setup refactoring in this PR.

Suggested reviewers

  • CTLalit
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing hardcoded HLS media source factories with a generic DefaultMediaSourceFactory to support all video formats (MP4, HLS, DASH, etc.) in four handler files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/inapps_inbox/exoplayer_support_all_video_format

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@francispereira
Copy link
Copy Markdown

francispereira commented Apr 2, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@Anush-Shand
Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
clevertap-core/src/main/java/com/clevertap/android/sdk/video/inbox/ExoplayerHandle.kt (1)

52-54: Consider future-proofing VideoLibChecker for format-agnostic video support detection.

VideoLibChecker.kt currently requires HlsMediaSource class presence to validate video player availability (lines 45 and 71 for exoplayer and media3 respectively). Since this PR adds multi-format support (DASH, MP4), a future enhancement would be to make the library detection format-agnostic—checking for core ExoPlayer classes rather than HLS-specific ones. This prevents false negatives if HLS module dependencies are eventually removed.

Not a concern for this PR, as HLS module dependencies remain included.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@clevertap-core/src/main/java/com/clevertap/android/sdk/video/inbox/ExoplayerHandle.kt`
around lines 52 - 54, VideoLibChecker currently detects player availability by
checking for HlsMediaSource presence, which can yield false negatives when HLS
module is absent; update VideoLibChecker to detect core player classes instead
(e.g., com.google.android.exoplayer2.ExoPlayer or
androidx.media3.exoplayer.ExoPlayer / androidx.media3.common.Player or
DefaultMediaSourceFactory) rather than HlsMediaSource so detection becomes
format-agnostic; modify the checks around the current HlsMediaSource lookups
(the checks referenced in VideoLibChecker at the locations that now reference
HlsMediaSource for ExoPlayer and media3) to attempt Class.forName on these core
ExoPlayer/Media3 player or factory classes and fall back appropriately.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@clevertap-core/src/main/java/com/clevertap/android/sdk/video/inbox/ExoplayerHandle.kt`:
- Around line 52-54: VideoLibChecker currently detects player availability by
checking for HlsMediaSource presence, which can yield false negatives when HLS
module is absent; update VideoLibChecker to detect core player classes instead
(e.g., com.google.android.exoplayer2.ExoPlayer or
androidx.media3.exoplayer.ExoPlayer / androidx.media3.common.Player or
DefaultMediaSourceFactory) rather than HlsMediaSource so detection becomes
format-agnostic; modify the checks around the current HlsMediaSource lookups
(the checks referenced in VideoLibChecker at the locations that now reference
HlsMediaSource for ExoPlayer and media3) to attempt Class.forName on these core
ExoPlayer/Media3 player or factory classes and fall back appropriately.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 23f274d7-312c-4068-8d9d-9a87239385cb

📥 Commits

Reviewing files that changed from the base of the PR and between cc4310f and e607b73.

📒 Files selected for processing (4)
  • clevertap-core/src/main/java/com/clevertap/android/sdk/video/inapps/ExoplayerHandle.kt
  • clevertap-core/src/main/java/com/clevertap/android/sdk/video/inapps/Media3Handle.kt
  • clevertap-core/src/main/java/com/clevertap/android/sdk/video/inbox/ExoplayerHandle.kt
  • clevertap-core/src/main/java/com/clevertap/android/sdk/video/inbox/Media3Handle.kt

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