Customized media data sources
xfirefly opened this issue · 2 comments
xfirefly commented
Does this player support custom media data sources?
like this in ijkplayer:
public interface IMediaDataSource {
int readAt(long var1, byte[] var3, int var4, int var5) throws IOException;
long getSize() throws IOException;
void close() throws IOException;
}
public class FileMediaDataSource implements IMediaDataSource {
private RandomAccessFile mFile;
private long mFileSize;
public FileMediaDataSource(File file) throws IOException {
mFile = new RandomAccessFile(file, "r");
mFileSize = mFile.length();
}
@Override
public int readAt(long position, byte[] buffer, int offset, int size) throws IOException {
if (mFile.getFilePointer() != position)
mFile.seek(position);
if (size == 0)
return 0;
return mFile.read(buffer, 0, size);
}
@Override
public long getSize() throws IOException {
return mFileSize;
}
@Override
public void close() throws IOException {
mFileSize = 0;
mFile.close();
mFile = null;
}
}
pingkai commented
我不确定java层有没有加,c++层肯定是支持的,你可以加个接口,如果你们是跨平台方案,可以直接用c++做个datasource的插件,全部平台都解决了
xfirefly commented
thanks a lot