mirror of
https://github.com/zhigang1992/AndroidVideoCache.git
synced 2026-01-25 12:57:54 +08:00
🎉 VideoCache 1.0 released
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.danikula.videocache;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
/**
|
||||
* Simple memory based {@link Source} implementation.
|
||||
*
|
||||
* @author Alexey Danilov (danikula@gmail.com).
|
||||
*/
|
||||
public class ByteArraySource implements Source {
|
||||
|
||||
private final byte[] data;
|
||||
private ByteArrayInputStream arrayInputStream;
|
||||
|
||||
public ByteArraySource(byte[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] buffer) throws ProxyCacheException {
|
||||
return arrayInputStream.read(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws ProxyCacheException {
|
||||
return data.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(int offset) throws ProxyCacheException {
|
||||
arrayInputStream = new ByteArrayInputStream(data);
|
||||
arrayInputStream.skip(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws ProxyCacheException {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user