Skip to content

Conversation

@Mansi-mParticle
Copy link
Contributor

Instructions

  1. PR target branch should be against main
  2. PR title name should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-title-check.yml
  3. PR branch prefix should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-branch-check-name.yml

Summary

  • pauseContentDuringAdBreaks renamed to excludeAdBreaksFromContentTime to accurately describe behavior.
    Updated boolean flag usage for clarity.
    Test cases modified to remove flaky timing assertions and ensure correctness.

Testing Plan

  • Tested with sample app

Reference Issue

Copy link

@thomson-t thomson-t left a comment

Choose a reason for hiding this comment

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

Can we update the changelog and Readme as well?

@Mansi-mParticle Mansi-mParticle changed the title fix: implement changes requested in code review for previous PR fix: implement changes requested in code review for previous PR Nov 19, 2025
@Mansi-mParticle Mansi-mParticle changed the title fix: implement changes requested in code review for previous PR fix: adjust ad break exclusion logic Dec 5, 2025
@rmi22186
Copy link
Member

rmi22186 commented Dec 8, 2025

I think the following test makes sense to ensure user pausing and ad break ending is correctly ensuring contentTime is calculated and excluding ad breaks. The scenario is let's say you are watching a youtube video and mid ad, a user pauses, then the ad break ends (perhaps the "skip" button is shown and the user clicks it, creating an ad break end).

@Test
fun testUserPausesDuringAdBreak_DoesNotAutoResume() {
    val mparticle = MockMParticle()
    val mediaSession = MediaSession.builder(mparticle) {
        title = "hello"
        mediaContentId = "123"
        duration = 1000
        excludeAdBreaksFromContentTime = true
    }

    mediaSession.logPlay()
    Thread.sleep(500)
    
    mediaSession.logAdBreakStart { id = "break-1" }
    // User pauses during the ad
    mediaSession.logPause()
    Thread.sleep(500)
    mediaSession.logAdBreakEnd()
    
    val contentTimeAfterAdBreak = mediaSession.mediaContentTimeSpent
    
    // Wait to see if time is incorrectly accumulating
    Thread.sleep(500)
    
    val contentTimeLater = mediaSession.mediaContentTimeSpent
    
    // Content time should NOT have resumed after ad break
    // because user paused during the ad
    assertEquals(contentTimeAfterAdBreak, contentTimeLater, 0.2)
}

Copy link
Member

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

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

2 minor comments

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 8, 2025

@Mansi-mParticle Mansi-mParticle merged commit 84b1493 into main Dec 12, 2025
4 checks passed
@Mansi-mParticle Mansi-mParticle deleted the fix/review-comments-addressed branch December 12, 2025 15:11
mparticle-automation added a commit that referenced this pull request Dec 12, 2025
## [1.7.0](v1.6.0...v1.7.0) (2025-12-12)

### Features

* Update Media Content Time Spent Calculations with Ad Breaks ([#74](#74)) ([c455557](c455557))

### Bug Fixes

* adjust ad break exclusion logic ([#76](#76)) ([84b1493](84b1493))

### Updates & Maintenance

* Migrate from OSSRH to Central Publishing Portal ([#75](#75)) ([ac8de37](ac8de37))
@mparticle-automation
Copy link
Collaborator

🎉 This PR is included in version 1.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants