NewPipe
NewPipe copied to clipboard
Player-related code that should be improved
I and Stypox noticed some strange things while reviewing/refactoring the player https://github.com/TeamNewPipe/NewPipe/pull/8170 (which were also there before the refactoring):
- [ ] When the playerservice is removed the complete app is killed (not gracefully terminated) by calling
Runtime.getRuntime().halt(0): https://github.com/TeamNewPipe/NewPipe/pull/8170#discussion_r865168043 - [ ] https://github.com/TeamNewPipe/NewPipe/pull/8170#discussion_r915709223 - here somehow a velocity is set to a position.
- [ ] https://github.com/TeamNewPipe/NewPipe/blob/d9af7885140560a6373c1a8863aa381cdd8ed170/app/src/main/java/org/schabi/newpipe/player/Player.java#L2584 should be addressed (or removed) https://github.com/TeamNewPipe/NewPipe/pull/8170#discussion_r917277853
- [ ] https://github.com/TeamNewPipe/NewPipe/blob/e9e9e8096ca6838a259250ed0f83d3c986dc64b2/app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java#L70 should be addressed (or removed) https://github.com/TeamNewPipe/NewPipe/pull/8678#discussion_r928249638
Other things to do:
- [x] Add an UI that handles setting up a media session to send media information to the system, and try to fix the various issues with the player notification (e.g. wrong thumbnail, non-seekable current time, ...): #8678
- [ ] Properly implement a Picture In Picture popup: #8750
- [ ] Make the playback parameters menu show up even when in popup mode
- [ ] https://github.com/TeamNewPipe/NewPipe/pull/8170#issuecomment-1228887994
- [ ] Refactor how the player is started or changed: #7673
I think I have a decent explanation for what item 2 is/does:
- For a given
velocityXandvelocityYof a popup: - if the Magnitude of either is greater than
TOSS_FLING_VELOCITY: - for each that is greater, set the axial position of the popup (
playerUi.popupLayoutParams.*) to the rounded Value of its co-axial velocity (velocity*) - clamp popup position into
popupLayoutParamswidth/height
What this does, for a well chosen TOSS_FLING_VELOCITY that:
- As a velocity is high, but attainable
- As a position lies outside the
popupLayoutParamswidth/height when either negative or positive
is to snap a flung popup to the edge of what popupLayoutParams says is the available space in the (approximate) direction it was sent.