-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Some simple refactors & beginning of kotlin conversions of the player classes #11965
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
Conversation
|
Might be a good idea to look into migrating to Media3: https://developer.android.com/media/media3/exoplayer |
|
@Isira-Seneviratne that’s exactly what newPlayer does. This is the initial work to integrate NewPlayer into NewPipe |
|
i.e. adjust all the interfaces in a way that we can slot in NewPlayer easily into the existing player logic |
Stypox
left a comment
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.
Generally looks good to me, thanks! You can probably ignore my comments in PlayerService since it will be quite different after the Android Auto PR anyway.
HatakeKakashri
left a comment
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.
Just a few minor comments to look into
app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java
Show resolved
Hide resolved
5a2047f to
31ade7c
Compare
|
Rebased on top of #11829 I removed the “lateinit” commit for |
31ade7c to
b537be8
Compare
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.
After you fix the artifacts from the conversion to Kotlin feel free to merge this (or ask me for approval). Thanks!
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.
I think the Kotlin code style in this class can be improved, e.g. the Consumers can be replaced with just lambdas I believe, and a lot of !! can be removed or replaced with ? or reworked in general
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.
Yupp, Can convert all Consumer and BiConsumer to lambdas
| if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction()) | ||
| && (player == null || player.getPlayQueue() == null)) { | ||
| if (Intent.ACTION_MEDIA_BUTTON == intent.action && | ||
| (player == null || player!!.playQueue == null) |
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.
| (player == null || player!!.playQueue == null) | |
| (player?.playQueue == null) |
| if (onPlayerStartedOrStopped != null) { | ||
| // notify that the player is being destroyed |
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.
| if (onPlayerStartedOrStopped != null) { | |
| // notify that the player is being destroyed | |
| // notify that the player is being destroyed | |
| onPlayerStartedOrStopped?.accept(null) |
b537be8 to
8d0249b
Compare
HatakeKakashri
left a comment
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.
Only few comments in Kotlin conversion. You can fix those and go ahead with merge.
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 a bit unwieldy in places, but should improve the safety of the code in the face of possible race conditions.
We directly call the `getService` function after receiving the argument, so resolving the WeakPointer should never return `null` in our case. Of course there could be a race condition in theory, but I feel like if that happens we have bigger problems?
|
@snaik20 btw if you have some nitpicks/trivial improvements, it’s fine if you add a commit and push that directly on the branch; I’m guessing you have the editor open anyway and it prevents a bunch of back-and-forth |
31ca1c5 to
73fef26
Compare
|



What is it?
Description of the changes in your PR
First few commits are from #11829 (merge first & rebase)
This partially conflicts with #9592
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