Move ExoPlayer initialization to a Dagger module and optimize its dependencies #4296
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, ExoPlayer is initialized explicitly in
ViewMediaFragment
with all its dependencies, including many that are not useful for viewing Mastodon media attachments.This pull request moves most ExoPlayer initialization and configuration to a new Dagger module, and instead a
Provider<ExoPlayer>
factory is injected in the Fragment so it can create new instances when needed.The following ExoPlayer components will be configured:
CameraMotionRenderer
.The Mastodon documentation mentions the supported media formats for attachments and this covers them and even more. The docs also mentions that the video and audio files are transcoded to MP4 and MP3 upon upload but that was not the case in the past (for example WebM was used) and it could change again in the future.
Specifying these components manually allows reducing the APK size by about 200 KB thanks to R8 shrinking.
There are also a few extra code changes: