public class PlayerBandwidthMeter
extends java.lang.Object
implements com.google.android.exoplayer2.upstream.BandwidthMeter, com.google.android.exoplayer2.upstream.TransferListener
BandwidthMeter
that tracks the total number of bytes
transferred. By default all work will be delegated to DefaultBandwidthMeter
. The caller
may override the delegate to another instance any time.Modifier and Type | Field and Description |
---|---|
long |
NO_ESTIMATE
Indicates no bandwidth estimate is available.
|
Constructor and Description |
---|
PlayerBandwidthMeter()
Constructs a new instance of the bandwidth meter that will use
DefaultBandwidthMeter
internally to delegate the work. |
PlayerBandwidthMeter(com.google.android.exoplayer2.upstream.BandwidthMeter bandwidthMeter)
Constructs a new instance of the bandwidth meter that will use given bandwidth meter to
delegate the work.
|
PlayerBandwidthMeter(android.content.Context context,
android.os.Handler eventHandler,
com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
Constructs a new instance of the bandwidth meter that will use
DefaultBandwidthMeter
internally to delegate the work. |
PlayerBandwidthMeter(android.os.Handler eventHandler,
com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
Constructs a new instance of the bandwidth meter that will use
DefaultBandwidthMeter
internally to delegate the work. |
Modifier and Type | Method and Description |
---|---|
void |
addEventListener(android.os.Handler eventHandler,
com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener) |
long |
getBitrateEstimate() |
com.google.android.exoplayer2.upstream.BandwidthMeter |
getDelegate()
Gets reference to actual bandwidth meter that is currently being delegated to handle bitrate
estimate calculations.
|
long |
getTotalBytesTransferred()
Gets the total number of bytes transferred so far.
|
com.google.android.exoplayer2.upstream.TransferListener |
getTransferListener() |
void |
onBytesTransferred(com.google.android.exoplayer2.upstream.DataSource source,
com.google.android.exoplayer2.upstream.DataSpec dataSpec,
boolean isNetwork,
int bytesTransferred) |
void |
onTransferEnd(com.google.android.exoplayer2.upstream.DataSource source,
com.google.android.exoplayer2.upstream.DataSpec dataSpec,
boolean isNetwork) |
void |
onTransferInitializing(com.google.android.exoplayer2.upstream.DataSource source,
com.google.android.exoplayer2.upstream.DataSpec dataSpec,
boolean isNetwork) |
void |
onTransferStart(com.google.android.exoplayer2.upstream.DataSource source,
com.google.android.exoplayer2.upstream.DataSpec dataSpec,
boolean isNetwork) |
void |
removeEventListener(com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener) |
PlayerBandwidthMeter |
resetTotalBytesTransferred()
Resets the counter for total number of bytes transferred.
|
void |
setDelegate(com.google.android.exoplayer2.upstream.BandwidthMeter bandwidthMeter)
Sets reference to actual bandwidth meter that must be used to handle bitrate estimate
calculations.
|
public PlayerBandwidthMeter()
DefaultBandwidthMeter
internally to delegate the work.public PlayerBandwidthMeter(@Nullable android.os.Handler eventHandler, @Nullable com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
DefaultBandwidthMeter
internally to delegate the work.eventHandler
- reference to the event handler, if any.eventListener
- reference to the event listener, if any.public PlayerBandwidthMeter(@Nullable android.content.Context context, @Nullable android.os.Handler eventHandler, @Nullable com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
DefaultBandwidthMeter
internally to delegate the work.eventHandler
- reference to the event handler, if any.eventListener
- reference to the event listener, if any.public PlayerBandwidthMeter(@Nullable com.google.android.exoplayer2.upstream.BandwidthMeter bandwidthMeter)
bandwidthMeter
- reference to the bandwidth meter to be used as delegate.public long getBitrateEstimate()
getBitrateEstimate
in interface com.google.android.exoplayer2.upstream.BandwidthMeter
@Nullable public com.google.android.exoplayer2.upstream.TransferListener getTransferListener()
getTransferListener
in interface com.google.android.exoplayer2.upstream.BandwidthMeter
public void addEventListener(android.os.Handler eventHandler, com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
addEventListener
in interface com.google.android.exoplayer2.upstream.BandwidthMeter
public void removeEventListener(com.google.android.exoplayer2.upstream.BandwidthMeter.EventListener eventListener)
removeEventListener
in interface com.google.android.exoplayer2.upstream.BandwidthMeter
@Nullable public com.google.android.exoplayer2.upstream.BandwidthMeter getDelegate()
public void setDelegate(@Nullable com.google.android.exoplayer2.upstream.BandwidthMeter bandwidthMeter)
public void onTransferInitializing(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork)
onTransferInitializing
in interface com.google.android.exoplayer2.upstream.TransferListener
public void onTransferStart(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork)
onTransferStart
in interface com.google.android.exoplayer2.upstream.TransferListener
public void onBytesTransferred(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork, int bytesTransferred)
onBytesTransferred
in interface com.google.android.exoplayer2.upstream.TransferListener
public void onTransferEnd(com.google.android.exoplayer2.upstream.DataSource source, com.google.android.exoplayer2.upstream.DataSpec dataSpec, boolean isNetwork)
onTransferEnd
in interface com.google.android.exoplayer2.upstream.TransferListener
public long getTotalBytesTransferred()
public PlayerBandwidthMeter resetTotalBytesTransferred()