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
581e543d
authored
Jun 14, 2021
by
jinpark
Committed by
Oliver Woodman
Jun 15, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add toBundle(boolean excludeMediaItems) to Timeline.
Add MediaItem.EMPTY. PiperOrigin-RevId: 379273172
parent
8777146e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
14 deletions
library/common/src/main/java/com/google/android/exoplayer2/MediaItem.java
library/common/src/main/java/com/google/android/exoplayer2/Timeline.java
library/common/src/main/java/com/google/android/exoplayer2/MediaItem.java
View file @
581e543d
...
@@ -1203,6 +1203,9 @@ public final class MediaItem implements Bundleable {
...
@@ -1203,6 +1203,9 @@ public final class MediaItem implements Bundleable {
*/
*/
public
static
final
String
DEFAULT_MEDIA_ID
=
""
;
public
static
final
String
DEFAULT_MEDIA_ID
=
""
;
/** Empty {@link MediaItem}. */
public
static
final
MediaItem
EMPTY
=
new
MediaItem
.
Builder
().
build
();
/** Identifies the media item. */
/** Identifies the media item. */
public
final
String
mediaId
;
public
final
String
mediaId
;
...
...
library/common/src/main/java/com/google/android/exoplayer2/Timeline.java
View file @
581e543d
...
@@ -440,18 +440,11 @@ public abstract class Timeline implements Bundleable {
...
@@ -440,18 +440,11 @@ public abstract class Timeline implements Bundleable {
private
static
final
int
FIELD_LAST_PERIOD_INDEX
=
12
;
private
static
final
int
FIELD_LAST_PERIOD_INDEX
=
12
;
private
static
final
int
FIELD_POSITION_IN_FIRST_PERIOD_US
=
13
;
private
static
final
int
FIELD_POSITION_IN_FIRST_PERIOD_US
=
13
;
/**
private
final
Bundle
toBundle
(
boolean
excludeMediaItem
)
{
* {@inheritDoc}
*
* <p>It omits the {@link #uid} and {@link #manifest} fields. The {@link #uid} of an instance
* restored by {@link #CREATOR} will be a fake {@link Object} and the {@link #manifest} of the
* instance will be {@code null}.
*/
// TODO(b/166765820): See if missing fields would be okay and add them to the Bundle otherwise.
@Override
public
Bundle
toBundle
()
{
Bundle
bundle
=
new
Bundle
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putBundle
(
keyForField
(
FIELD_MEDIA_ITEM
),
mediaItem
.
toBundle
());
bundle
.
putBundle
(
keyForField
(
FIELD_MEDIA_ITEM
),
excludeMediaItem
?
MediaItem
.
EMPTY
.
toBundle
()
:
mediaItem
.
toBundle
());
bundle
.
putLong
(
keyForField
(
FIELD_PRESENTATION_START_TIME_MS
),
presentationStartTimeMs
);
bundle
.
putLong
(
keyForField
(
FIELD_PRESENTATION_START_TIME_MS
),
presentationStartTimeMs
);
bundle
.
putLong
(
keyForField
(
FIELD_WINDOW_START_TIME_MS
),
windowStartTimeMs
);
bundle
.
putLong
(
keyForField
(
FIELD_WINDOW_START_TIME_MS
),
windowStartTimeMs
);
bundle
.
putLong
(
bundle
.
putLong
(
...
@@ -472,6 +465,19 @@ public abstract class Timeline implements Bundleable {
...
@@ -472,6 +465,19 @@ public abstract class Timeline implements Bundleable {
}
}
/**
/**
* {@inheritDoc}
*
* <p>It omits the {@link #uid} and {@link #manifest} fields. The {@link #uid} of an instance
* restored by {@link #CREATOR} will be a fake {@link Object} and the {@link #manifest} of the
* instance will be {@code null}.
*/
// TODO(b/166765820): See if missing fields would be okay and add them to the Bundle otherwise.
@Override
public
Bundle
toBundle
()
{
return
toBundle
(
/* excludeMediaItem= */
false
);
}
/**
* Object that can restore {@link Period} from a {@link Bundle}.
* Object that can restore {@link Period} from a {@link Bundle}.
*
*
* <p>The {@link #uid} of a restored instance will be a fake {@link Object} and the {@link
* <p>The {@link #uid} of a restored instance will be a fake {@link Object} and the {@link
...
@@ -1309,14 +1315,17 @@ public abstract class Timeline implements Bundleable {
...
@@ -1309,14 +1315,17 @@ public abstract class Timeline implements Bundleable {
* <p>The {@link #getWindow(int, Window)} windows} and {@link #getPeriod(int, Period) periods} of
* <p>The {@link #getWindow(int, Window)} windows} and {@link #getPeriod(int, Period) periods} of
* an instance restored by {@link #CREATOR} may have missing fields as described in {@link
* an instance restored by {@link #CREATOR} may have missing fields as described in {@link
* Window#toBundle()} and {@link Period#toBundle()}.
* Window#toBundle()} and {@link Period#toBundle()}.
*
* @param excludeMediaItems Whether to exclude all {@link Window#mediaItem media items} of windows
* in the timeline.
*/
*/
@Override
public
final
Bundle
toBundle
(
boolean
excludeMediaItems
)
{
public
final
Bundle
toBundle
()
{
List
<
Bundle
>
windowBundles
=
new
ArrayList
<>();
List
<
Bundle
>
windowBundles
=
new
ArrayList
<>();
int
windowCount
=
getWindowCount
();
int
windowCount
=
getWindowCount
();
Window
window
=
new
Window
();
Window
window
=
new
Window
();
for
(
int
i
=
0
;
i
<
windowCount
;
i
++)
{
for
(
int
i
=
0
;
i
<
windowCount
;
i
++)
{
windowBundles
.
add
(
getWindow
(
i
,
window
,
/* defaultPositionProjectionUs= */
0
).
toBundle
());
windowBundles
.
add
(
getWindow
(
i
,
window
,
/* defaultPositionProjectionUs= */
0
).
toBundle
(
excludeMediaItems
));
}
}
List
<
Bundle
>
periodBundles
=
new
ArrayList
<>();
List
<
Bundle
>
periodBundles
=
new
ArrayList
<>();
...
@@ -1346,6 +1355,18 @@ public abstract class Timeline implements Bundleable {
...
@@ -1346,6 +1355,18 @@ public abstract class Timeline implements Bundleable {
}
}
/**
/**
* {@inheritDoc}
*
* <p>The {@link #getWindow(int, Window)} windows} and {@link #getPeriod(int, Period) periods} of
* an instance restored by {@link #CREATOR} may have missing fields as described in {@link
* Window#toBundle()} and {@link Period#toBundle()}.
*/
@Override
public
final
Bundle
toBundle
()
{
return
toBundle
(
/* excludeMediaItems= */
false
);
}
/**
* Object that can restore a {@link Timeline} from a {@link Bundle}.
* Object that can restore a {@link Timeline} from a {@link Bundle}.
*
*
* <p>The {@link #getWindow(int, Window)} windows} and {@link #getPeriod(int, Period) periods} of
* <p>The {@link #getWindow(int, Window)} windows} and {@link #getPeriod(int, Period) periods} of
...
...
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