jellyfin-archive / jellyfin-android-original

Android Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
271 stars 65 forks source link

Add orientation plugin to support screen rotation #248

Closed TheBosZ closed 4 years ago

TheBosZ commented 4 years ago

Adds the Screen Orientation plugin to make screen.orientation.lock work.

Closes #241

TheBosZ commented 4 years ago

Easy answers: yes and yes.

Longer answers: I just jumped on the Jellyfin wagon this weekend and noticed that the Android app didn't auto-rotate. I decided to look into the code (since it's open source, right?) and saw that it's Cordova-based.

I've got quite a bit of experience with Cordova so I figured I could sit down and come up with a solution. Today I had some free time at work and decided to jump in.

First I thought that I would have to bind to some event coming from jellyfin-web. In the course of chasing that down, I noticed that the playback module actually had rotation code. I built a dev copy of the app and ran it on my phone and used Chrome DevTools to debug it.

It reported that the rotation stuff wasn't available.

I quickly read up on the Cordova rotation plugin and saw that it works by enabling the same functionality used by jellyfin-web.

A simple cordova plugin add cordova-plugin-screen-orientation, a quick build and it works as expected!