Rollback of 9961d918a9
*** Original commit *** Rollback of8d9c4f4774
*** Original commit *** Rollback of43b796b64d
*** Original commit *** Rollback of08c5b1cb0a
*** Original commit *** PiperOrigin-RevId: 430905772
This commit is contained in:
parent
1bc4ba29f5
commit
bbfeb27600
@ -2,6 +2,16 @@
|
|||||||
|
|
||||||
### dev-v2 (not yet released)
|
### dev-v2 (not yet released)
|
||||||
|
|
||||||
|
* Core library:
|
||||||
|
* Enable support for Android platform diagnostics via
|
||||||
|
`MediaMetricsManager`. ExoPlayer will forward playback events and
|
||||||
|
performance data to the platform, which helps to provide system
|
||||||
|
performance and debugging information on the device. This data may also
|
||||||
|
be collected by Google
|
||||||
|
[if sharing usage and diagnostics data is enabled](https://support.google.com/accounts/answer/6078260)
|
||||||
|
by the user of the device. Apps can opt-out of contributing to platform
|
||||||
|
diagnostics for ExoPlayer with
|
||||||
|
`ExoPlayer.Builder.setUsePlatformDiagnostics(false)`.
|
||||||
* Track selection:
|
* Track selection:
|
||||||
* Flatten `TrackSelectionOverrides` class into `TrackSelectionParameters`,
|
* Flatten `TrackSelectionOverrides` class into `TrackSelectionParameters`,
|
||||||
and promote `TrackSelectionOverride` to a top level class.
|
and promote `TrackSelectionOverride` to a top level class.
|
||||||
|
@ -458,6 +458,7 @@ public interface ExoPlayer extends Player {
|
|||||||
/* package */ long releaseTimeoutMs;
|
/* package */ long releaseTimeoutMs;
|
||||||
/* package */ long detachSurfaceTimeoutMs;
|
/* package */ long detachSurfaceTimeoutMs;
|
||||||
/* package */ boolean pauseAtEndOfMediaItems;
|
/* package */ boolean pauseAtEndOfMediaItems;
|
||||||
|
/* package */ boolean usePlatformDiagnostics;
|
||||||
/* package */ boolean buildCalled;
|
/* package */ boolean buildCalled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -498,6 +499,7 @@ public interface ExoPlayer extends Player {
|
|||||||
* <li>{@code releaseTimeoutMs}: {@link #DEFAULT_RELEASE_TIMEOUT_MS}
|
* <li>{@code releaseTimeoutMs}: {@link #DEFAULT_RELEASE_TIMEOUT_MS}
|
||||||
* <li>{@code detachSurfaceTimeoutMs}: {@link #DEFAULT_DETACH_SURFACE_TIMEOUT_MS}
|
* <li>{@code detachSurfaceTimeoutMs}: {@link #DEFAULT_DETACH_SURFACE_TIMEOUT_MS}
|
||||||
* <li>{@code pauseAtEndOfMediaItems}: {@code false}
|
* <li>{@code pauseAtEndOfMediaItems}: {@code false}
|
||||||
|
* <li>{@code usePlatformDiagnostics}: {@code true}
|
||||||
* <li>{@link Clock}: {@link Clock#DEFAULT}
|
* <li>{@link Clock}: {@link Clock#DEFAULT}
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
@ -643,6 +645,7 @@ public interface ExoPlayer extends Player {
|
|||||||
clock = Clock.DEFAULT;
|
clock = Clock.DEFAULT;
|
||||||
releaseTimeoutMs = DEFAULT_RELEASE_TIMEOUT_MS;
|
releaseTimeoutMs = DEFAULT_RELEASE_TIMEOUT_MS;
|
||||||
detachSurfaceTimeoutMs = DEFAULT_DETACH_SURFACE_TIMEOUT_MS;
|
detachSurfaceTimeoutMs = DEFAULT_DETACH_SURFACE_TIMEOUT_MS;
|
||||||
|
usePlatformDiagnostics = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1003,6 +1006,27 @@ public interface ExoPlayer extends Player {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the player reports diagnostics data to the Android platform.
|
||||||
|
*
|
||||||
|
* <p>If enabled, the player will use the {@link android.media.metrics.MediaMetricsManager} to
|
||||||
|
* create a {@link android.media.metrics.PlaybackSession} and forward playback events and
|
||||||
|
* performance data to this session. This helps to provide system performance and debugging
|
||||||
|
* information for media playback on the device. This data may also be collected by Google <a
|
||||||
|
* href="https://support.google.com/accounts/answer/6078260">if sharing usage and diagnostics
|
||||||
|
* data is enabled</a> by the user of the device.
|
||||||
|
*
|
||||||
|
* @param usePlatformDiagnostics Whether the player reports diagnostics data to the Android
|
||||||
|
* platform.
|
||||||
|
* @return This builder.
|
||||||
|
* @throws IllegalStateException If {@link #build()} has already been called.
|
||||||
|
*/
|
||||||
|
public Builder setUsePlatformDiagnostics(boolean usePlatformDiagnostics) {
|
||||||
|
checkState(!buildCalled);
|
||||||
|
this.usePlatformDiagnostics = usePlatformDiagnostics;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link Clock} that will be used by the player. Should only be set for testing
|
* Sets the {@link Clock} that will be used by the player. Should only be set for testing
|
||||||
* purposes.
|
* purposes.
|
||||||
|
@ -56,6 +56,7 @@ import com.google.android.exoplayer2.PlayerMessage.Target;
|
|||||||
import com.google.android.exoplayer2.Renderer.MessageType;
|
import com.google.android.exoplayer2.Renderer.MessageType;
|
||||||
import com.google.android.exoplayer2.analytics.AnalyticsCollector;
|
import com.google.android.exoplayer2.analytics.AnalyticsCollector;
|
||||||
import com.google.android.exoplayer2.analytics.AnalyticsListener;
|
import com.google.android.exoplayer2.analytics.AnalyticsListener;
|
||||||
|
import com.google.android.exoplayer2.analytics.MediaMetricsListener;
|
||||||
import com.google.android.exoplayer2.analytics.PlayerId;
|
import com.google.android.exoplayer2.analytics.PlayerId;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
||||||
@ -306,7 +307,11 @@ import java.util.concurrent.TimeoutException;
|
|||||||
playbackInfoUpdateHandler.post(() -> handlePlaybackInfo(playbackInfoUpdate));
|
playbackInfoUpdateHandler.post(() -> handlePlaybackInfo(playbackInfoUpdate));
|
||||||
playbackInfo = PlaybackInfo.createDummy(emptyTrackSelectorResult);
|
playbackInfo = PlaybackInfo.createDummy(emptyTrackSelectorResult);
|
||||||
analyticsCollector.setPlayer(this.wrappingPlayer, applicationLooper);
|
analyticsCollector.setPlayer(this.wrappingPlayer, applicationLooper);
|
||||||
PlayerId playerId = Util.SDK_INT < 31 ? new PlayerId() : Api31.createPlayerId();
|
PlayerId playerId =
|
||||||
|
Util.SDK_INT < 31
|
||||||
|
? new PlayerId()
|
||||||
|
: Api31.registerMediaMetricsListener(
|
||||||
|
applicationContext, /* player= */ this, builder.usePlatformDiagnostics);
|
||||||
internalPlayer =
|
internalPlayer =
|
||||||
new ExoPlayerImplInternal(
|
new ExoPlayerImplInternal(
|
||||||
renderers,
|
renderers,
|
||||||
@ -3063,9 +3068,17 @@ import java.util.concurrent.TimeoutException;
|
|||||||
private Api31() {}
|
private Api31() {}
|
||||||
|
|
||||||
@DoNotInline
|
@DoNotInline
|
||||||
public static PlayerId createPlayerId() {
|
public static PlayerId registerMediaMetricsListener(
|
||||||
// TODO: Create a MediaMetricsListener and obtain LogSessionId from it.
|
Context context, ExoPlayerImpl player, boolean usePlatformDiagnostics) {
|
||||||
return new PlayerId(LogSessionId.LOG_SESSION_ID_NONE);
|
@Nullable MediaMetricsListener listener = MediaMetricsListener.create(context);
|
||||||
|
if (listener == null) {
|
||||||
|
Log.w(TAG, "MediaMetricsService unavailable.");
|
||||||
|
return new PlayerId(LogSessionId.LOG_SESSION_ID_NONE);
|
||||||
|
}
|
||||||
|
if (usePlatformDiagnostics) {
|
||||||
|
player.addAnalyticsListener(listener);
|
||||||
|
}
|
||||||
|
return new PlayerId(listener.getLogSessionId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user