-
-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add in app download functionality #1404
base: master
Are you sure you want to change the base?
Conversation
So I would call the PR in a beta state. Feature wise, I think it is already at a good point. Adding the view downloads button requires modifying the web app. If something is missing I can still add it, but otherwise next step would be the polish. |
Thank you very much for this PR, it looks very good, I have a few questions to ask you: 1 - This is to download media on the device and watch them locally without internet? |
Yes. Currently downloads are saved using Android's built-in DownloadManager. They are saved in for example the Downloads folder so one can playback the file using VLC. This PR adds the functionality to save the download to the app internal storage making playback from within the app possible.
Video files are usually already very well compressed through the used codecs, adding a conventional lossless compression such as zstandard would barely reduce the size. The next step after this PR could adding functionality to support downloads in different bitrates, enabling smaller downloads. |
While thinking about implementing the ability to download transcoded media (streams), I realized it would be better if ExoPlayer would handle downloading, since it natively supports HLS streams, making future efforts easier. So I rewrote the download logic to utilize ExoPlayers in-buildt download capabilities. Oh yeah this also makes regular video playback use the downloade / cached files if available. |
app/src/main/res/values/strings.xml
Outdated
<string name="view_downloads">View Downloads</string> | ||
<string name="available_downloads">Available downloads</string> | ||
<string name="downloads">Downloads</string> | ||
<string name="downloaded">Downloaded %1$s</string> |
Check warning
Code scanning / Android Lint
Unused resources Warning
app/src/main/res/values/strings.xml
Outdated
<string name="available_downloads">Available downloads</string> | ||
<string name="downloads">Downloads</string> | ||
<string name="downloaded">Downloaded %1$s</string> | ||
<string name="download_finished">Download Finished</string> |
Check warning
Code scanning / Android Lint
Unused resources Warning
app/src/main/res/values/strings.xml
Outdated
<string name="downloaded">Downloaded %1$s</string> | ||
<string name="download_finished">Download Finished</string> | ||
<string name="download_notifications_description">Download notifications</string> | ||
<string name="download_failed">Download failed</string> |
Check warning
Code scanning / Android Lint
Unused resources Warning
app/src/main/res/values/strings.xml
Outdated
<string name="download_finished">Download Finished</string> | ||
<string name="download_notifications_description">Download notifications</string> | ||
<string name="download_failed">Download failed</string> | ||
<string name="failed_subs">Failed to download external subtitles</string> |
Check warning
Code scanning / Android Lint
Unused resources Warning
app/src/main/res/values/strings.xml
Outdated
<string name="download_failed">Download failed</string> | ||
<string name="failed_subs">Failed to download external subtitles</string> | ||
<string name="failed_thumbnail">Failed to download thumbnail</string> | ||
<string name="failed_media">Failed to download media</string> |
Check warning
Code scanning / Android Lint
Unused resources Warning
I would love to test this if you want to post some builds... I have a flight coming up. 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much of the detekt issues blocking the PR seems like quick fixes except for one :/
Looks like we're the unlucky PR that needs that final param and hit the limit! 😆
I've thought of a potential solution but it's by no means perfect.
app/src/main/java/org/jellyfin/mobile/player/source/JellyfinMediaSource.kt
Outdated
Show resolved
Hide resolved
Any chance we could get the workflows approved? |
It would also be nice to be able to select a player app for the files that get listed under downloads. For instance, downloaded HDR videos may not play through the built-in player, but may play ok with VLC... |
This patch should help resolve the detekt failures:
|
Detekt now runs sucessfully |
This is not possible since we do not have access to the files when using ExoPlayer |
If a video is downloaded, playing the video when connected to the network tries to stream the file from the server, instead of preferring the locally downloaded file. Would it be useful to be able to change that? |
For me the cached version is used when playing the video by clicking on the item in the web view. Requirement for this to happen is to use the ExoPlayer in the settings. Can you check if you have selected the ExoPlayer and not the Web Player? |
Ah yes! It was reset to web player when I updated to my locally built version! |
Maybe some sort of |
The PR is already rather large and I'd prefer keeping further improvements to new PRs after this one gets merged
…-------- Original Message --------
On 7/22/24 10:55, Satadru Pramanik, DO, MPH, MEng wrote:
Maybe some sort of if cached && player_not_set_to_exoplayer then notify user logic wold be warranted? (Or offer to use exoplayer to play the file?)
—
Reply to this email directly, [view it on GitHub](#1404 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AKOW3XZWQ5EVXVAQOUDOEVDZNTCJBAVCNFSM6AAAAABIW6QNUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBSGQZTKOBWG4).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
I've been daily driving the latest build. I've noticed the Download All functionality for an entire TV show appears to successfully download one or two eps only to not download any of the remaining eps. If someone can trial this behaviour to test this isn't just my env, that would be great. Otherwise, this might be worth patching. I have yet to test this against other media groups such as download all for a season. |
Also spent the last week using a build of this. I would note that when viewing a cached video offline from the downloads folder, that the watched state/progress doesn't get uploaded back to the jellyfin server once a connection is re-established. Should I make that a separate feature request? |
I'll look into this
Yeah. I am aware of this. This can be added later if you want. Would need to remember the relevant server instance and also verify if play sessions are remembered that long so progress reports can be still made |
Good catch, @satmandu! Personally, I feel that the purpose of this PR: "To add download functionality", has been met. In addition to this, we already have a fairly large PR and I fear for keeping this branch up to date if/when potentially other large PRs get merged upstream. +1 for doing this in a separate PR 👍 |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
The commit I just pushed should fix the problems of dropping downloads when multiple downloads are enqueued. The problem was the small size of the event buffer and the policy to drop old events. Remaining problem is the a bit freaky download notification, when downloading files at the same time. |
Would need to update the getForegroundNotification to consider all pending downloads when building the notification ugh |
I tested the whole pr for a bit and i found a strange bug. Somehow the replacement of the
If you debug into the exoplayer source code you see that in Did i configure something wrong or is it indeed a bug? Ps: To fix it on my device, I just replaced the |
I just tried to replicate this bug. It only seems to appear on some bitrates i.e. 360p. But on higher bitrates, I do not get the exception. |
Commit #7ce600c fixes the HLS content source error. Problem was that the exoplayer cache cached videos when playing them back, this was not intended and let to complication. The commit makes the cache read-only. |
Commit #6db98b7 improves download notification when multiple downloads are in progress. This should fix all current outstanding problems. |
Would it be possible for someone to take a look at this PR and review it please? That'd be great ❤️ |
This PR internalizes the download process.
Changes
Downloads are stored inside the app directory including thumbnail and external subtitle files. MediaSource data is downloaded as well and stored inside the Room Database.
A new Downloads fragment is added to show available downloads. Downloads are played back using the Exoplayer.
What's left
This is not a complete list
Notes
There is still lots of work to do, but it is already working. I new to Android development, so I am really sorry if something is not correct. Furthermore I implement this functionality as part of my Master's degree, so even if for whatever reason this PR is rejected, I will still complete the project to my best ability. I sorry that I changed some ExoPlayer code even though, it is currently reworked, but due to time constraints, I could not wait.
Thanks for any feedback :)