danikula / danikula/AndroidVideoCache

Preloading only a part of videos

Đang mở
#123 14 bình luận 0 reaction 0 người được giao Xem trên GitHub
question
Ngôn ngữ chính
Java
Star
5.5k
Fork
1.2k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hi guys, I'm currently using this awesome library for my app.

Nowaday, I want to do preloading: while users is watching a video, I start downloading a part of each upcoming videos.

For example, my videos are about 12MB in size on average, I want to preload only 5MB of each video, so that users will not have to wait for loading.

```
FileOutputStream fileOutputStream = new FileOutputStream(filePath);
URL url = new URL(videoUrl);
is = url.openStream();
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];

int lengthInByte;
int readByteCount = 0;
while ((lengthInByte = is.read(buffer)) != -1) {
readByteCount += lengthInByte;
fileOutputStream.write(buffer, 0, lengthInByte);
if (readByteCount >= MAX_FILE_SIZE_TO_PRELOAD_IN_BYTE) {
break;
}
}
```
The `videoUrl` here is the original one, not the one from `HttpProxyCacheServer.getProxyUrl(String)`
The `videoPath` is the same as the path that the library will use to storage the cache file, because I'm using the same `FileNameGenerator` to build up the path, with the `.download` postfix also.
I will stop downloading when the cached file length is bigger than the maximum size I want to cache.

Everything works just fine, the library will append to my preloaded file instead of downloading a new one.

Except that, each time I play a video, it seems that the MediaPlayer has to wait before the library can connect to the remote file, instead of getting access to the cached file immediately.

Is that right? If yes, anyway that I can customize to open the cached file and play the video immediately while the library continue downloading?

Thank you.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu bằng cách lần theo HttpProxyCacheServer.getProxyUrl(String), đường dẫn FileNameGenerator dùng chung và tương tác với MediaPlayer được mô tả trong issue. Tái hiện việc phát với cache .download chưa hoàn tất và xác định xem luồng cache hiện tại có hỗ trợ phát ngay trong khi đang tải xuống hay không; được coi là hoàn thành khi có hành vi được hỗ trợ rõ ràng hoặc có giới hạn và cách sử dụng được ghi chép.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
android, java
Lĩnh vực
mobile, performance
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.