コード例 #1
0
 @Override
 public void load() throws IOException, InterruptedException {
   // We always load from the beginning, so reset the sampleSize to 0.
   sampleSize = 0;
   try {
     // Create and open the input.
     dataSource.open(new DataSpec(uri));
     // Load the sample data.
     int result = 0;
     while (result != C.RESULT_END_OF_INPUT) {
       sampleSize += result;
       if (sampleSize == sampleData.length) {
         sampleData = Arrays.copyOf(sampleData, sampleData.length * 2);
       }
       result = dataSource.read(sampleData, sampleSize, sampleData.length - sampleSize);
     }
   } finally {
     dataSource.close();
   }
 }