Skip to content

Commit

Permalink
wasPaused > autoPlay
Browse files Browse the repository at this point in the history
makes it clearer what this is for
  • Loading branch information
terminal-overflow committed Mar 5, 2025
1 parent f901e7a commit d8893e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/playercomponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function PlayerComponent(
}

function genericAudioDescribedSwitch(enable) {
const wasPaused = isPaused()
const autoPlay = !isPaused()
const presentationTimeInSeconds = getCurrentTime()
const availabilityTimeInMilliseconds = presentationTimeToAvailabilityTimeInMilliseconds(
presentationTimeInSeconds,
Expand All @@ -150,7 +150,7 @@ function PlayerComponent(
)

tearDownMediaElement()
loadMedia(mediaMetaData.type, presentationTimeInSeconds, wasPaused)
loadMedia(mediaMetaData.type, presentationTimeInSeconds, autoPlay)
})
.catch(() => {
bubbleFatalError(false, {
Expand Down Expand Up @@ -408,8 +408,8 @@ function PlayerComponent(
}
}

function loadMedia(type, presentationTimeInSeconds, thenPause) {
playbackStrategy?.load(type, presentationTimeInSeconds, !thenPause)
function loadMedia(type, presentationTimeInSeconds, autoPlay = true) {
playbackStrategy?.load(type, presentationTimeInSeconds, autoPlay)

if (mediaSources.isAudioDescribedEnabled()) {
audioDescribedCallback(true)
Expand Down
8 changes: 4 additions & 4 deletions src/playercomponent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ describe("Player Component", () => {
await jest.advanceTimersByTimeAsync(10000)

expect(mockStrategy.load).toHaveBeenCalledTimes(2)
expect(mockStrategy.load).toHaveBeenCalledWith("application/dash+xml", 100, true)
expect(mockStrategy.load).toHaveBeenCalledWith("application/dash+xml", 100, false)

expect(mockMediaSources.failover).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down Expand Up @@ -997,7 +997,7 @@ describe("Player Component", () => {
await jest.advanceTimersByTimeAsync(20000)

expect(mockStrategy.load).toHaveBeenCalledTimes(2)
expect(mockStrategy.load).toHaveBeenCalledWith("application/dash+xml", 100, true)
expect(mockStrategy.load).toHaveBeenCalledWith("application/dash+xml", 100, false)

expect(mockMediaSources.failover).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down Expand Up @@ -1028,7 +1028,7 @@ describe("Player Component", () => {
await jest.advanceTimersByTimeAsync(5000)

expect(mockStrategy.load).toHaveBeenCalledTimes(2)
expect(mockStrategy.load).toHaveBeenCalledWith("application/dash+xml", 100, true)
expect(mockStrategy.load).toHaveBeenCalledWith("application/dash+xml", 100, false)

expect(mockMediaSources.failover).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down Expand Up @@ -1134,7 +1134,7 @@ describe("Player Component", () => {
await jest.advanceTimersByTimeAsync(20000)

expect(mockStrategy.load).toHaveBeenCalledTimes(2)
expect(mockStrategy.load).toHaveBeenNthCalledWith(2, "application/dash+xml", 100 - 20, true)
expect(mockStrategy.load).toHaveBeenNthCalledWith(2, "application/dash+xml", 100 - 20, false)
})

it("should fire error cleared on the plugins when failover completes", async () => {
Expand Down

0 comments on commit d8893e5

Please sign in to comment.