BrightDV / BoxBox

Unofficial Android and web app for Formula 1 and Formula E fans!
https://codeberg.org/BrightDV/BoxBox
GNU General Public License v3.0
105 stars 10 forks source link

Offline capability (videos, audio, news, etc.) when connection lacks #155

Closed serrq closed 3 months ago

serrq commented 5 months ago

Use case: the internet connection lacks for any reason (airplane mode included).

Box, box automatically downloads only the heavy data (for example videos) that I effectively seen: news data are always got because they are light.

Optionally you could adding an on/off switch in settings for this feature.

1000109728

BrightDV commented 5 months ago

So you mean: downloading a video for a future watching or caching the whole video while watching it in case of an internet connection error? The first case could be a really nice feature to add (dedicated section with video/article saves), the second one could be easily added with a setting to choose the cache size (in seconds) of the video player.

serrq commented 5 months ago

"Caching the whole video while watching" always, even if connection is excellent.

This idea is taken from another app, called ViMusic (fdroid). It put aside (for future offline use) all that I listen, even mistakenly.

Do you want delete an already downloaded music track?

Go to "download" tab and delete what you want.

To do this please add a download "folder" limit, for example max 5 gb or max 3 months, or a combination of both, in order to not consume excessive resources.

News download all. They are few megabytes (pictures and audio included).

serrq commented 5 months ago

What you mean is even another feature, that we can calling "favorites" section or "archive" section.

An user can going on a video and then push "send to archive" or "add to favorites".

BrightDV commented 5 months ago

"Caching the whole video while watching" always, even if connection is excellent.

That should be doable. I limited the cache to ~30 seconds because the player can lag (crash?) on devices without a lot of RAM.

This idea is taken from another app, called ViMusic (fdroid). It put aside (for future offline use) all that I listen, even mistakenly.

Do you want delete an already downloaded music track?

Go to "download" tab and delete what you want.

To do this please add a download "folder" limit, for example max 5 gb or max 3 months, or a combination of both, in order to not consume excessive resources.

I agree for the music player, but is it really useful for a video player? For example, you can listen to a music several times, but I don't guess that you would watch the same video more than 3 to 4 different times (and offline).

News download all. They are few megabytes (pictures and audio included).

That's seems a good idea, I will see how I can implement it (images and text first).

What you mean is even another feature, that we can calling "favorites" section or "archive" section.

An user can going on a video and then push "send to archive" or "add to favorites".

Yes, that was the idea; I will open different issues to track the progress of the features' implementation.

serrq commented 5 months ago

I have a Senna docufilm put aside. Eh eh eh.

Okay dev, you are the best. I put my wishes in your hands.

serrq commented 5 months ago

I agree for the music player, but is it really useful for a video player? For example, you can listen to a music several times, but I don't guess that you would watch the same video more than 3 to 4 different times (and offline).

My approach is different: in my idea I haven't to think about anything. Download just happen automatically.

In your approach you have to push physically the "download" button, and what if the connection lack when you return to see that video again? Maybe you travel in a train that day... but you forgot to push "download"...

serrq commented 5 months ago

Or maybe both the ideas "automatically" (caching) and "watch later".

serrq commented 5 months ago

I limited the cache to ~30 seconds because the player can lag (crash?) on devices without a lot of RAM.

We can adding an on/off caching switch (for less gifted devices).

BrightDV commented 5 months ago

I agree for the music player, but is it really useful for a video player? For example, you can listen to a music several times, but I don't guess that you would watch the same video more than 3 to 4 different times (and offline).

My approach is different: in my idea I haven't to think about anything. Download just happen automatically.

In your approach you have to push physically the "download" button, and what if the connection lack when you return to see that video again?

Yes: you download a video for a future use, but you need to tap on the download button. Then you can watch it later.

Or maybe both the ideas "automatically" (caching) and "watch later".

I limited the cache to ~30 seconds because the player can lag (crash?) on devices without a lot of RAM.

We can adding an on/off full caching switch (for less gifted devices).

I think I will add a setting to manually set the cache time, so you would be able to set it to 1 hour.

The point that I want to understand is whether the video should still be available, even after closing the player or the app. The cache is only used when you are watching the video, like ViMusic does. However, ViMusic keeps the file in the storage after the playing, so you can listen later to the song, but Box, Box! deletes the cache when you exit the player. The download should save the video in the storage.

My point is that with your approach, all the videos you have seen will be saved on your device, but you may only watch a few of them again. With a download, you only save offline what you want to see.

For example, when you see a post-race interview of a particular driver, you will not watch it a lot of time. However, race highlights may be saved. That's why a non-automatic approach seems the best to me.

serrq commented 5 months ago

My solution to get the best of two worlds (automatic and based on push) is setting a double trap:

• all those videos automatically downloaded are subject to two rules simultaneously:

  1. Max 5gb (caching of all videos)
  2. Max 3 weeks

Then Box box automatically delete when they expire or they reach the volume limit.

Do you want store "forever" a particular video? Send to archive (manually).

• Based on manual push: manual download is subject on same above rules or send (it directly) to archive to store the video permanently.

BrightDV commented 5 months ago

Ok, that's seems to be the best solution. I will add different settings to that. Now it is the harder part, because I have to implement a download system ;)

serrq commented 5 months ago

Okay dev, my philosophy (thinking) is ended. Now it begins the code time. And afterwards we can celebrate the result. 🤓

serrq commented 5 months ago

Changed logic in "manual push". Tell me if you approve. Read my edited message above.

https://github.com/BrightDV/BoxBox/issues/155#issuecomment-2101229499

In this way the download (manual or automatic) always has the same behavior.

Same for the "send to archive" function (basically it says to the app "avoid the download rules" and store the media content permanently).

Basically "send to archive" becomes something like "sanctify this video". Make it immortal. 🤣

BrightDV commented 3 months ago

So I have been working on this for some days now in #163. What I have added yet is the "send to archive" as you said. You can download videos and articles. There is a proper Downloads screen with running and finished downloads, you can pause/resume/delete downloads from there or from the per-download notification. However, after some thinking, I decided not to add the autodownloader soon. It would need a huge amount of work to create the logic, and there are still missing features/bugs in the app that I want to address first.

I think that the current implementation is the best for a newsreader/video player. (I will attach screenshots soon!)

serrq commented 3 months ago

Excellent!

BrightDV commented 3 months ago

So here are some screenshots of the download component:

serrq commented 3 months ago

You are a kind man. This is a great work!

BrightDV commented 3 months ago

So I just merged the PR! If you want, you can try the debug build from here (app-release.apk at the bottom), but if so, you will have to delete your already installed app.

serrq commented 3 months ago

I don't see any apk. Don't worry dev, I wait the fdroid update.

PS: what does it mean "debug" version?

1000113826

BrightDV commented 3 months ago

You have to be logged in to be able to download the file.

PS: what does it mean "debug" version?

Here I am wrong because it is more a prereleae than a debug version. Anyway, the debug version is a version of the app which logs everything while active, so it is very useful to find bugs, add new features... but not made for production/public releases.