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
06ffd23c
authored
Dec 20, 2019
by
bachinger
Committed by
Oliver Woodman
Dec 20, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
make removeMediaItem return void
PiperOrigin-RevId: 286551438
parent
8c0f22c9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
14 deletions
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java
View file @
06ffd23c
...
@@ -486,10 +486,8 @@ public interface ExoPlayer extends Player {
...
@@ -486,10 +486,8 @@ public interface ExoPlayer extends Player {
* Removes the media item at the given index of the playlist.
* Removes the media item at the given index of the playlist.
*
*
* @param index The index at which to remove the media item.
* @param index The index at which to remove the media item.
* @return The removed {@link MediaSource} or null if no item exists at the given index.
*/
*/
@Nullable
void
removeMediaItem
(
int
index
);
MediaSource
removeMediaItem
(
int
index
);
/**
/**
* Removes a range of media items from the playlist.
* Removes a range of media items from the playlist.
...
...
library/core/src/main/java/com/google/android/exoplayer2/ExoPlayerImpl.java
View file @
06ffd23c
...
@@ -368,10 +368,8 @@ import java.util.concurrent.TimeoutException;
...
@@ -368,10 +368,8 @@ import java.util.concurrent.TimeoutException;
}
}
@Override
@Override
public
MediaSource
removeMediaItem
(
int
index
)
{
public
void
removeMediaItem
(
int
index
)
{
List
<
Playlist
.
MediaSourceHolder
>
mediaSourceHolders
=
removeMediaItemsInternal
(
/* fromIndex= */
index
,
/* toIndex= */
index
+
1
);
removeMediaItemsInternal
(
/* fromIndex= */
index
,
/* toIndex= */
index
+
1
);
return
mediaSourceHolders
.
isEmpty
()
?
null
:
mediaSourceHolders
.
get
(
0
).
mediaSource
;
}
}
@Override
@Override
...
@@ -956,7 +954,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -956,7 +954,7 @@ import java.util.concurrent.TimeoutException;
return
holders
;
return
holders
;
}
}
private
List
<
Playlist
.
MediaSourceHolder
>
removeMediaItemsInternal
(
int
fromIndex
,
int
toIndex
)
{
private
void
removeMediaItemsInternal
(
int
fromIndex
,
int
toIndex
)
{
Assertions
.
checkArgument
(
Assertions
.
checkArgument
(
fromIndex
>=
0
&&
toIndex
>=
fromIndex
&&
toIndex
<=
mediaSourceHolders
.
size
());
fromIndex
>=
0
&&
toIndex
>=
fromIndex
&&
toIndex
<=
mediaSourceHolders
.
size
());
int
currentWindowIndex
=
getCurrentWindowIndex
();
int
currentWindowIndex
=
getCurrentWindowIndex
();
...
@@ -965,8 +963,7 @@ import java.util.concurrent.TimeoutException;
...
@@ -965,8 +963,7 @@ import java.util.concurrent.TimeoutException;
Timeline
oldTimeline
=
getCurrentTimeline
();
Timeline
oldTimeline
=
getCurrentTimeline
();
int
currentMediaSourceCount
=
mediaSourceHolders
.
size
();
int
currentMediaSourceCount
=
mediaSourceHolders
.
size
();
pendingOperationAcks
++;
pendingOperationAcks
++;
List
<
Playlist
.
MediaSourceHolder
>
removedHolders
=
removeMediaSourceHolders
(
fromIndex
,
/* toIndexExclusive= */
toIndex
);
removeMediaSourceHolders
(
fromIndex
,
/* toIndexExclusive= */
toIndex
);
Timeline
timeline
=
Timeline
timeline
=
maskTimelineAndWindowIndex
(
currentWindowIndex
,
currentPositionMs
,
oldTimeline
);
maskTimelineAndWindowIndex
(
currentWindowIndex
,
currentPositionMs
,
oldTimeline
);
// Player transitions to STATE_ENDED if the current index is part of the removed tail.
// Player transitions to STATE_ENDED if the current index is part of the removed tail.
...
@@ -987,7 +984,6 @@ import java.util.concurrent.TimeoutException;
...
@@ -987,7 +984,6 @@ import java.util.concurrent.TimeoutException;
listener
.
onPlayerStateChanged
(
currentPlayWhenReady
,
STATE_ENDED
);
listener
.
onPlayerStateChanged
(
currentPlayWhenReady
,
STATE_ENDED
);
}
}
});
});
return
removedHolders
;
}
}
private
List
<
Playlist
.
MediaSourceHolder
>
removeMediaSourceHolders
(
private
List
<
Playlist
.
MediaSourceHolder
>
removeMediaSourceHolders
(
...
...
library/core/src/main/java/com/google/android/exoplayer2/SimpleExoPlayer.java
View file @
06ffd23c
...
@@ -1290,9 +1290,9 @@ public class SimpleExoPlayer extends BasePlayer
...
@@ -1290,9 +1290,9 @@ public class SimpleExoPlayer extends BasePlayer
}
}
@Override
@Override
public
MediaSource
removeMediaItem
(
int
index
)
{
public
void
removeMediaItem
(
int
index
)
{
verifyApplicationThread
();
verifyApplicationThread
();
return
player
.
removeMediaItem
(
index
);
player
.
removeMediaItem
(
index
);
}
}
@Override
@Override
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/StubExoPlayer.java
View file @
06ffd23c
...
@@ -190,7 +190,7 @@ public abstract class StubExoPlayer extends BasePlayer implements ExoPlayer {
...
@@ -190,7 +190,7 @@ public abstract class StubExoPlayer extends BasePlayer implements ExoPlayer {
}
}
@Override
@Override
public
MediaSource
removeMediaItem
(
int
index
)
{
public
void
removeMediaItem
(
int
index
)
{
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
...
...
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