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

Fix crash when starting player where playback controller may be null #3232

Merged

Conversation

nielsvanvelzen
Copy link
Member

Changes
This code is messy but basically we do a lot of magic to send the "PlaybackController" instance from the CustomPlaybackOverlayFragment to LeanbackOverlayFragment. This happened in two ways: via the PlaybackControllerContainer and the initFromView function. Then both classes contained a (m)playbackController variable to store the value.

In this PR I did a few things:

  • Removed the local (m)playbackController variables
  • Changed the initFromView function to not take a playback controller instance
  • Check if the playback controller is null in LeanbackOverlayFragment.onCreate - which can happen when the video player in rare instances (empty queue / no audio manager in the android system)
  • Always get the controller from the container

While I cannot reproduce the issue and thus have no idea if this fixes it, this PR does give the 🍝 a bit more 🌶️.

Issues

Hopefully fixes #3231

@nielsvanvelzen nielsvanvelzen added bug Something isn't working crash Bug causing app crashes labels Dec 16, 2023
@nielsvanvelzen nielsvanvelzen added this to the v0.16.1 milestone Dec 16, 2023

playerAdapter = new VideoPlayerAdapter(playbackController, this);
playerGlue = new CustomPlaybackTransportControlGlue(getContext(), playerAdapter, playbackController);
playerGlue.setHost(new CustomPlaybackFragmentGlueHost(this));
}

public void initFromView(PlaybackController playbackController, CustomPlaybackOverlayFragment customPlaybackOverlayFragment) {
this.playbackController = playbackController;
public void initFromView(CustomPlaybackOverlayFragment customPlaybackOverlayFragment) {

Check notice

Code scanning / Android Lint

Unknown nullness

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations
@nielsvanvelzen nielsvanvelzen merged commit 32849f5 into jellyfin:master Dec 17, 2023
@nielsvanvelzen nielsvanvelzen deleted the nvv-playback-controller-null branch December 18, 2023 21:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash Bug causing app crashes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fire Stick crash while playback
1 participant