That fuck shit the fascists are using
1package org.tm.archive.video;
2
3import android.media.MediaDataSource;
4
5import androidx.annotation.RequiresApi;
6
7import java.io.IOException;
8
9@RequiresApi(23)
10public class ByteArrayMediaDataSource extends MediaDataSource {
11
12 private byte[] data;
13
14 public ByteArrayMediaDataSource(byte[] data) {
15 this.data = data;
16 }
17
18 @Override
19 public int readAt(long position, byte[] buffer, int offset, int size) throws IOException {
20 if (data == null) throw new IOException("ByteArrayMediaDataSource is closed");
21
22 long bytesAvailable = getSize() - position;
23 int read = Math.min(size, (int) bytesAvailable);
24 if (read <= 0) return -1;
25
26 if (buffer != null) {
27 System.arraycopy(data, (int) position, buffer, offset, read);
28 }
29
30 return read;
31 }
32
33 @Override
34 public long getSize() throws IOException {
35 if (data == null) throw new IOException("ByteArrayMediaDataSource is closed");
36 return data.length;
37 }
38
39 @Override
40 public void close() throws IOException {
41 data = null;
42 }
43}