Skip to content
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

Some simple refactors & beginning of kotlin conversions of the player classes #11965

Open
wants to merge 12 commits into
base: refactor
Choose a base branch
from

Conversation

Profpatsch
Copy link
Contributor

@Profpatsch Profpatsch commented Jan 27, 2025

First few commits are from #11829 (merge first & rebase)
This partially conflicts with #9592

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • record videos
  • create clones
  • take over the world

Before/After Screenshots/Screen Record

  • Before:
  • After:

Fixes the following issue(s)

  • Fixes #

Relies on the following changes

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

And simplify the code a little
In Kotlin, dealing with nulls works better so we don’t need optional.
The new implementation would throw `ConcurrentModificationExceptions`
when destroying the UIs. So let’s play it safe and put the list behind
a mutex.

Adds a helper class `GuardedByMutex` that can be wrapped around a
property to force all use-sites to acquire the lock before doing
anything with the data.
No adjustments done yet; only change is that I added an upper bound
on `PlayerUi` to the `PlayerUiList` functions, so “everything” is now
`null` in `destroyAll`.
This removes a bunch of unncessary checks.

We forgo setting player to `null` in onDestroy, because shutting it
down and when the service stops should be enough to free it for
garbage collection.
Because the class is final, protected does not make sense (Android
Studio auto-suggestions)
The `R.id` link from the comment cannot be resolved, so let’s not link
it for now.

We are using some exoplayer2 resources, let’s silence the warning.
It’s only used in this one place.
@github-actions github-actions bot added the size/giant PRs with more than 750 changed lines label Jan 27, 2025
@ShareASmile ShareASmile added codequality Improvements to the codebase to improve the code quality rewrite Issues and PRs related to rewrite player Issues related to any player (main, popup and background) labels Jan 27, 2025
@Isira-Seneviratne
Copy link
Member

Might be a good idea to look into migrating to Media3: https://developer.android.com/media/media3/exoplayer

@Profpatsch
Copy link
Contributor Author

@Isira-Seneviratne that’s exactly what newPlayer does. This is the initial work to integrate NewPlayer into NewPipe

@Profpatsch
Copy link
Contributor Author

i.e. adjust all the interfaces in a way that we can slot in NewPlayer easily into the existing player logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codequality Improvements to the codebase to improve the code quality player Issues related to any player (main, popup and background) rewrite Issues and PRs related to rewrite size/giant PRs with more than 750 changed lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants