danikula / danikula/AndroidVideoCache

Preloading only a part of videos

Abierto
#123 14 comentarios 0 reacciones 0 asignados Ver en GitHub
question
Lenguaje dominante
Java
Estrellas
5.5k
Forks
1.2k
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Comienza rastreando HttpProxyCacheServer.getProxyUrl(String), la ruta de FileNameGenerator compartida y la interacción con MediaPlayer descrita en el issue. Reproduce la reproducción con la caché .download parcial y determina si el flujo de caché existente admite la reproducción inmediata mientras se descarga; se considera terminado cuando haya un comportamiento claramente compatible o una limitación y una ruta de uso documentadas.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
android, java
Área
mobile, performance
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.