danikula / danikula/AndroidVideoCache

Preloading only a part of videos

オープン
#123 コメント 14 件 リアクション 0 件 担当者 0 名 GitHub で見る
question
主要言語
Java
スター
5.5k
フォーク
1.2k
PR マージ指標
30日以内にマージされた PR はありません

説明

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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

まず HttpProxyCacheServer.getProxyUrl(String)、共有されている FileNameGenerator のパス、および issue で説明されている MediaPlayer との連携を追跡します。不完全な .download キャッシュで再生を再現し、既存のキャッシュフローがダウンロード中の即時再生をサポートしているかを確認します。完了とは、明確にサポートされている動作、または文書化された制限と使用方法が示されていることを意味します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
android, java
領域
mobile, performance
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。