mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Playlist API: submit ahead some files of the playlist API CL
PiperOrigin-RevId: 283988536
This commit is contained in:
parent
aa2e9ffc10
commit
f25bcedf72
@ -30,7 +30,6 @@ import java.util.ArrayList;
|
|||||||
private final Timeline.Period period;
|
private final Timeline.Period period;
|
||||||
private final Timeline timeline;
|
private final Timeline timeline;
|
||||||
|
|
||||||
private boolean prepared;
|
|
||||||
@Player.State private int state;
|
@Player.State private int state;
|
||||||
private boolean playWhenReady;
|
private boolean playWhenReady;
|
||||||
private long position;
|
private long position;
|
||||||
@ -48,12 +47,10 @@ import java.util.ArrayList;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Sets the timeline on this fake player, which notifies listeners with the changed timeline. */
|
/** Sets the timeline on this fake player, which notifies listeners with the changed timeline. */
|
||||||
public void updateTimeline(Timeline timeline) {
|
public void updateTimeline(Timeline timeline, @TimelineChangeReason int reason) {
|
||||||
for (Player.EventListener listener : listeners) {
|
for (Player.EventListener listener : listeners) {
|
||||||
listener.onTimelineChanged(
|
listener.onTimelineChanged(timeline, reason);
|
||||||
timeline, prepared ? TIMELINE_CHANGE_REASON_DYNAMIC : TIMELINE_CHANGE_REASON_PREPARED);
|
|
||||||
}
|
}
|
||||||
prepared = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -286,7 +286,9 @@ public class ImaAdsLoaderTest {
|
|||||||
public void onAdPlaybackState(AdPlaybackState adPlaybackState) {
|
public void onAdPlaybackState(AdPlaybackState adPlaybackState) {
|
||||||
adPlaybackState = adPlaybackState.withAdDurationsUs(adDurationsUs);
|
adPlaybackState = adPlaybackState.withAdDurationsUs(adDurationsUs);
|
||||||
this.adPlaybackState = adPlaybackState;
|
this.adPlaybackState = adPlaybackState;
|
||||||
fakeExoPlayer.updateTimeline(new SinglePeriodAdTimeline(contentTimeline, adPlaybackState));
|
fakeExoPlayer.updateTimeline(
|
||||||
|
new SinglePeriodAdTimeline(contentTimeline, adPlaybackState),
|
||||||
|
Player.TIMELINE_CHANGE_REASON_DYNAMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -905,4 +905,50 @@ public abstract class Timeline {
|
|||||||
* @return The unique id of the period.
|
* @return The unique id of the period.
|
||||||
*/
|
*/
|
||||||
public abstract Object getUidOfPeriod(int periodIndex);
|
public abstract Object getUidOfPeriod(int periodIndex);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(@Nullable Object obj) {
|
||||||
|
if (this == obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!(obj instanceof Timeline)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Timeline other = (Timeline) obj;
|
||||||
|
if (other.getWindowCount() != getWindowCount() || other.getPeriodCount() != getPeriodCount()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Timeline.Window window = new Timeline.Window();
|
||||||
|
Timeline.Period period = new Timeline.Period();
|
||||||
|
Timeline.Window otherWindow = new Timeline.Window();
|
||||||
|
Timeline.Period otherPeriod = new Timeline.Period();
|
||||||
|
for (int i = 0; i < getWindowCount(); i++) {
|
||||||
|
if (!getWindow(i, window).equals(other.getWindow(i, otherWindow))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < getPeriodCount(); i++) {
|
||||||
|
if (!getPeriod(i, period, /* setIds= */ true)
|
||||||
|
.equals(other.getPeriod(i, otherPeriod, /* setIds= */ true))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
Window window = new Window();
|
||||||
|
Period period = new Period();
|
||||||
|
int result = 7;
|
||||||
|
result = 31 * result + getWindowCount();
|
||||||
|
for (int i = 0; i < getWindowCount(); i++) {
|
||||||
|
result = 31 * result + getWindow(i, window).hashCode();
|
||||||
|
}
|
||||||
|
result = 31 * result + getPeriodCount();
|
||||||
|
for (int i = 0; i < getPeriodCount(); i++) {
|
||||||
|
result = 31 * result + getPeriod(i, period, /* setIds= */ true).hashCode();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source;
|
|||||||
|
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.Timeline.Window;
|
import com.google.android.exoplayer2.Timeline.Window;
|
||||||
@ -314,7 +315,8 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Dummy placeholder timeline with one dynamic window with a period of indeterminate duration. */
|
/** Dummy placeholder timeline with one dynamic window with a period of indeterminate duration. */
|
||||||
private static final class DummyTimeline extends Timeline {
|
@VisibleForTesting
|
||||||
|
public static final class DummyTimeline extends Timeline {
|
||||||
|
|
||||||
@Nullable private final Object tag;
|
@Nullable private final Object tag;
|
||||||
|
|
||||||
|
@ -141,7 +141,8 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
|
|||||||
pendingSchedule = null;
|
pendingSchedule = null;
|
||||||
}
|
}
|
||||||
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = buildDrmSessionManager(userAgent);
|
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = buildDrmSessionManager(userAgent);
|
||||||
player.prepare(buildSource(host, Util.getUserAgent(host, userAgent), drmSessionManager));
|
player.setMediaItem(buildSource(host, Util.getUserAgent(host, userAgent), drmSessionManager));
|
||||||
|
player.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.google.android.exoplayer2.testutil;
|
||||||
|
|
||||||
|
import com.google.android.exoplayer2.Timeline;
|
||||||
|
import com.google.android.exoplayer2.source.ForwardingTimeline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A timeline which wraps another timeline and overrides all window and period uids to 0. This is
|
||||||
|
* useful for testing timeline equality without taking uids into account.
|
||||||
|
*/
|
||||||
|
/* package */ class NoUidTimeline extends ForwardingTimeline {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance.
|
||||||
|
*
|
||||||
|
* @param timeline The underlying timeline.
|
||||||
|
*/
|
||||||
|
public NoUidTimeline(Timeline timeline) {
|
||||||
|
super(timeline);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Window getWindow(int windowIndex, Window window, long defaultPositionProjectionUs) {
|
||||||
|
timeline.getWindow(windowIndex, window, defaultPositionProjectionUs);
|
||||||
|
window.uid = 0;
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Period getPeriod(int periodIndex, Period period, boolean setIds) {
|
||||||
|
timeline.getPeriod(periodIndex, period, setIds);
|
||||||
|
period.uid = 0;
|
||||||
|
return period;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user