Exemplo n.º 1
0
    public BufferTask(DownloadFile downloadFile, int position) {
      this.downloadFile = downloadFile;
      this.position = position;
      partialFile = downloadFile.getPartialFile();

      // Calculate roughly how many bytes BUFFER_LENGTH_SECONDS corresponds to.
      int bitRate = downloadFile.getBitRate();
      long byteCount = Math.max(100000, bitRate * 1024 / 8 * BUFFER_LENGTH_SECONDS);

      // Find out how large the file should grow before resuming playback.
      expectedFileSize = partialFile.length() + byteCount;
    }