Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
69e51505
authored
Nov 12, 2019
by
bachinger
Committed by
Oliver Woodman
Nov 15, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
use getPeriodByUid when searching for subsequent period of seek timeline
Issue: #6641 PiperOrigin-RevId: 279963739
parent
abe0330f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
3 deletions
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImplInternal.java
View file @
69e51505
...
...
@@ -1444,6 +1444,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* @throws IllegalSeekPositionException If the window index of the seek position is outside the
* bounds of the timeline.
*/
@Nullable
private
Pair
<
Object
,
Long
>
resolveSeekPosition
(
SeekPosition
seekPosition
,
boolean
trySubsequentPeriods
)
{
Timeline
timeline
=
playbackInfo
.
timeline
;
...
...
@@ -1479,11 +1480,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
}
if
(
trySubsequentPeriods
)
{
// Try and find a subsequent period from the seek timeline in the internal timeline.
@Nullable
Object
periodUid
=
resolveSubsequentPeriod
(
periodPosition
.
first
,
seekTimeline
,
timeline
);
if
(
periodUid
!=
null
)
{
// We found one.
Map the SeekPosition onto the corresponding default position
.
// We found one.
Use the default position of the corresponding window
.
return
getPeriodPosition
(
timeline
,
timeline
.
getPeriod
(
periodIndex
,
period
).
windowIndex
,
C
.
TIME_UNSET
);
timeline
,
timeline
.
getPeriod
ByUid
(
periodUid
,
period
).
windowIndex
,
C
.
TIME_UNSET
);
}
}
// We didn't find one. Give up.
...
...
library/core/src/test/java/com/google/android/exoplayer2/ExoPlayerTest.java
View file @
69e51505
...
...
@@ -2169,6 +2169,70 @@ public final class ExoPlayerTest {
}
@Test
public
void
testInvalidSeekFallsBackToSubsequentPeriodOfTheRemovedPeriod
()
throws
Exception
{
Timeline
timeline
=
new
FakeTimeline
(
/* windowCount= */
1
);
CountDownLatch
sourceReleasedCountDownLatch
=
new
CountDownLatch
(
/* count= */
1
);
MediaSource
mediaSourceToRemove
=
new
FakeMediaSource
(
timeline
)
{
@Override
protected
void
releaseSourceInternal
()
{
super
.
releaseSourceInternal
();
sourceReleasedCountDownLatch
.
countDown
();
}
};
ConcatenatingMediaSource
mediaSource
=
new
ConcatenatingMediaSource
(
mediaSourceToRemove
,
new
FakeMediaSource
(
timeline
));
final
int
[]
windowCount
=
{
C
.
INDEX_UNSET
};
final
long
[]
position
=
{
C
.
TIME_UNSET
};
ActionSchedule
actionSchedule
=
new
ActionSchedule
.
Builder
(
"testInvalidSeekFallsBackToSubsequentPeriodOfTheRemovedPeriod"
)
.
pause
()
.
waitForTimelineChanged
()
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
SimpleExoPlayer
player
)
{
mediaSource
.
removeMediaSource
(
/* index= */
0
);
try
{
// Wait until the source to be removed is released on the playback thread. So
// the timeline in EPII has one window only, but the update here in EPI is
// stuck until we finished our executable here. So when seeking below, we will
// seek in the timeline which still has two windows in EPI, but when the seek
// arrives in EPII the actual timeline has one window only. Hence it tries to
// find the subsequent period of the removed period and finds it.
sourceReleasedCountDownLatch
.
await
();
}
catch
(
InterruptedException
e
)
{
throw
new
IllegalStateException
(
e
);
}
player
.
seekTo
(
/* windowIndex= */
0
,
/* positionMs= */
1000L
);
}
})
.
waitForSeekProcessed
()
.
executeRunnable
(
new
PlayerRunnable
()
{
@Override
public
void
run
(
SimpleExoPlayer
player
)
{
windowCount
[
0
]
=
player
.
getCurrentTimeline
().
getWindowCount
();
position
[
0
]
=
player
.
getCurrentPosition
();
}
})
.
play
()
.
build
();
new
ExoPlayerTestRunner
.
Builder
()
.
setMediaSource
(
mediaSource
)
.
setActionSchedule
(
actionSchedule
)
.
build
(
context
)
.
start
()
.
blockUntilActionScheduleFinished
(
TIMEOUT_MS
)
.
blockUntilEnded
(
TIMEOUT_MS
);
// Expect the first window to be the current.
assertThat
(
windowCount
[
0
]).
isEqualTo
(
1
);
// Expect the position to be in the default position.
assertThat
(
position
[
0
]).
isEqualTo
(
0L
);
}
@Test
public
void
testRecursivePlayerChangesReportConsistentValuesForAllListeners
()
throws
Exception
{
// We add two listeners to the player. The first stops the player as soon as it's ready and both
// record the state change events they receive.
...
...
@@ -2992,7 +3056,7 @@ public final class ExoPlayerTest {
new
PlayerRunnable
()
{
@Override
public
void
run
(
SimpleExoPlayer
player
)
{
player
.
setMediaItem
(
mediaSource
,
/*
p
ositionMs= */
5000
);
player
.
setMediaItem
(
mediaSource
,
/*
startP
ositionMs= */
5000
);
player
.
prepare
();
}
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment