Java Code Examples for com.google.android.exoplayer2.C#PERCENTAGE_UNSET

The following examples show how to use com.google.android.exoplayer2.C#PERCENTAGE_UNSET . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SegmentDownloader.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private float getPercentDownloaded() {
  if (contentLength != C.LENGTH_UNSET && contentLength != 0) {
    return (bytesDownloaded * 100f) / contentLength;
  } else if (totalSegments != 0) {
    return (segmentsDownloaded * 100f) / totalSegments;
  } else {
    return C.PERCENTAGE_UNSET;
  }
}
 
Example 2
Source File: ProgressiveDownloader.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public void onProgress(long contentLength, long bytesCached, long newBytesCached) {
  float percentDownloaded =
      contentLength == C.LENGTH_UNSET || contentLength == 0
          ? C.PERCENTAGE_UNSET
          : ((bytesCached * 100f) / contentLength);
  progessListener.onProgress(contentLength, bytesCached, percentDownloaded);
}
 
Example 3
Source File: SegmentDownloader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final float getDownloadPercentage() {
  // Take local snapshot of the volatile fields
  int totalSegments = this.totalSegments;
  int downloadedSegments = this.downloadedSegments;
  if (totalSegments == C.LENGTH_UNSET || downloadedSegments == C.LENGTH_UNSET) {
    return C.PERCENTAGE_UNSET;
  }
  return totalSegments == 0 ? 100f : (downloadedSegments * 100f) / totalSegments;
}
 
Example 4
Source File: ProgressiveDownloader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public float getDownloadPercentage() {
  long contentLength = cachingCounters.contentLength;
  return contentLength == C.LENGTH_UNSET
      ? C.PERCENTAGE_UNSET
      : ((cachingCounters.totalCachedBytes() * 100f) / contentLength);
}
 
Example 5
Source File: SegmentDownloader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final float getDownloadPercentage() {
  // Take local snapshot of the volatile fields
  int totalSegments = this.totalSegments;
  int downloadedSegments = this.downloadedSegments;
  if (totalSegments == C.LENGTH_UNSET || downloadedSegments == C.LENGTH_UNSET) {
    return C.PERCENTAGE_UNSET;
  }
  return totalSegments == 0 ? 100f : (downloadedSegments * 100f) / totalSegments;
}
 
Example 6
Source File: ProgressiveDownloader.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public float getDownloadPercentage() {
  long contentLength = cachingCounters.contentLength;
  return contentLength == C.LENGTH_UNSET
      ? C.PERCENTAGE_UNSET
      : ((cachingCounters.totalCachedBytes() * 100f) / contentLength);
}
 
Example 7
Source File: SegmentDownloader.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private float getPercentDownloaded() {
  if (contentLength != C.LENGTH_UNSET && contentLength != 0) {
    return (bytesDownloaded * 100f) / contentLength;
  } else if (totalSegments != 0) {
    return (segmentsDownloaded * 100f) / totalSegments;
  } else {
    return C.PERCENTAGE_UNSET;
  }
}
 
Example 8
Source File: ProgressiveDownloader.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onProgress(long contentLength, long bytesCached, long newBytesCached) {
  float percentDownloaded =
      contentLength == C.LENGTH_UNSET || contentLength == 0
          ? C.PERCENTAGE_UNSET
          : ((bytesCached * 100f) / contentLength);
  progessListener.onProgress(contentLength, bytesCached, percentDownloaded);
}
 
Example 9
Source File: SegmentDownloader.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private float getPercentDownloaded() {
  if (contentLength != C.LENGTH_UNSET && contentLength != 0) {
    return (bytesDownloaded * 100f) / contentLength;
  } else if (totalSegments != 0) {
    return (segmentsDownloaded * 100f) / totalSegments;
  } else {
    return C.PERCENTAGE_UNSET;
  }
}
 
Example 10
Source File: ProgressiveDownloader.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onProgress(long contentLength, long bytesCached, long newBytesCached) {
  float percentDownloaded =
      contentLength == C.LENGTH_UNSET || contentLength == 0
          ? C.PERCENTAGE_UNSET
          : ((bytesCached * 100f) / contentLength);
  progessListener.onProgress(contentLength, bytesCached, percentDownloaded);
}
 
Example 11
Source File: DownloadManager.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the estimated download percentage, or {@link C#PERCENTAGE_UNSET} if no estimate is
 * available.
 */
public float getDownloadPercentage() {
  return downloader != null ? downloader.getDownloadPercentage() : C.PERCENTAGE_UNSET;
}
 
Example 12
Source File: DownloadManager.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the estimated download percentage, or {@link C#PERCENTAGE_UNSET} if no estimate is
 * available.
 */
public float getDownloadPercentage() {
  return downloader != null ? downloader.getDownloadPercentage() : C.PERCENTAGE_UNSET;
}