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

Added support for spatial navigation (Navigation using arrow keys) and also support for tv remote keys #1885

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gibahjoe
Copy link
Contributor

@gibahjoe gibahjoe commented Feb 15, 2023

This PR adds support for Spatial navigation which is especially useful when using jellyfin-vue on a TV.

Also support for TV remote keys during playback (Tested with LGTV remote) was also added.

The main focus of this PR is to let TV users select items on their screen using the arrow keys of the remote and also to allow the remote media keys (tested with LGTV magic remote, webOS 5 and 6 but it can be easily expanded for other tv types if their keycodes are different).

@jellyfin-bot jellyfin-bot added this to In progress in Ongoing development Feb 15, 2023
@jellyfin-bot jellyfin-bot added plugins Pull requests that edit or add Nuxt plugins vue Pull requests that edit or add Vue files labels Feb 15, 2023
@sonarcloud
Copy link

sonarcloud bot commented Mar 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@ferferga ferferga added the discussion needed This PR or issue needs discussion before going further label Mar 14, 2023
@jellyfin-bot jellyfin-bot added the merge conflict Something has merge conflicts label Apr 3, 2023
@Ritchie1108
Copy link

so, anybody knows? does this project support smart tv remote?
i want to use it to replace jellyfin-web in jellyfin-tizen

@ThibaultNocchi
Copy link
Member

ThibaultNocchi commented Apr 7, 2023

I haven't yet gone around to review this PR, we had a lot of work with the recent Vue 3 merge.

I don't mind adding support for keys and remotes, what I don't guarantee is that the client will work on smart TVs. We use a pretty recent software stack, with which TVs usually aren't compatible.

But adding support for keys isn't something I'll block, I just need to take some time :)

Also, @gibahjoe , can you resolve the conflicts with the codebase please? :)

@Ritchie1108
Copy link

sorry, im not good at web code, so im not not sure what the browser version this project depends on
maybe chromium m85?

@ThibaultNocchi
Copy link
Member

ThibaultNocchi commented Apr 7, 2023

It seems at least to need Chromium 87, as Vite specifies, and this isn't checking the other modules we use.

@Ritchie1108
Copy link

oops, so sad

@gibahjoe
Copy link
Contributor Author

gibahjoe commented Apr 8, 2023

@ThibaultNocchi The previous vue app worked on TVs (tested on LGTV) but Vite didn't as at 3 months ago when I tested it. I will take a look at it again and resolve these merge conflicts

@ferferga
Copy link
Member

ferferga commented Apr 8, 2023

@gibahjoe Still it's useful if this can be navigated through keyboard for accessibility reasons or TVs that have latest Chromium versions.

There's no harm in supporting as much use cases as possible, as long as the support is good!

@gibahjoe
Copy link
Contributor Author

Update:

I already began work on this a few days back. Unfortunately, the plug-in I used previously doesn't support Vue 3 so I have had to copy over the code and make a couple of adjustments.

Anyway, I should be done by this weekend.

@ferferga
Copy link
Member

@gibahjoe The other day I was thinking about the media type redesign and it came across to my mind again what to do for this PR.

In general, I think we should have three views for libraries: card grid (the only one right now), coverflow one (the current one for fullscreen music player, which is already useful for touch-based units like Echo Show or Android Auto but it also might be a presentation people like for books and TVs) and a list view (specially for music)

For the home sections, music and that hypothetical coverflow view, we already have full keyboard support through swiper.

Why I'm saying all of this? Maybe before you do further work here, perhaps we should gather feedback from people who might benefit from this the most. I'm not a TV user myself, so all I can do is give my review in the impl details, etc, but maybe not much insight in how it should be UX-wise

@gibahjoe gibahjoe closed this Apr 16, 2023
Ongoing development automation moved this from In progress to Done Apr 16, 2023
@jellyfin-bot jellyfin-bot moved this from Done to In progress in Ongoing development Apr 16, 2023
@jellyfin-bot jellyfin-bot removed plugins Pull requests that edit or add Nuxt plugins vue Pull requests that edit or add Vue files labels Apr 16, 2023
… keys on keyboard and remote control. Also add support for play/pause button on webos

# Conflicts:
#	frontend/src/store/playbackManager.ts
@gibahjoe gibahjoe reopened this Apr 16, 2023
@jellyfin-bot jellyfin-bot added vue Pull requests that edit or add Vue files and removed merge conflict Something has merge conflicts labels Apr 16, 2023
@sonarcloud
Copy link

sonarcloud bot commented Apr 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

currentFocusedElement.blur();
}

focusNscroll(elem);

Check warning

Code scanning / CodeQL

Superfluous trailing arguments Warning

Superfluous argument passed to
function focusNscroll
.
return false;
}

focusNscroll(elem);

Check warning

Code scanning / CodeQL

Superfluous trailing arguments Warning

Superfluous argument passed to
function focusNscroll
.
// This might also be split into different directives to handle remove eventlisteners
Vue.directive('focus-events', {
mounted(el, binding) {
for (const [i, key] of Object.keys(binding.value).entries()) {

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable i.
for (const candidate of candidates) {
var rect = getRect(candidate);

if (rect) {

Check warning

Code scanning / CodeQL

Useless conditional Warning

This use of variable 'rect' always evaluates to true.
@jellyfin-bot
Copy link

Cloudflare Pages deployment

Latest commit ba6e882
Status ✅ Deployed!
Preview URL https://jf-vue.pages.dev (https://0d8cb1de.jf-vue.pages.dev)
Type ⚙️ Production

View build logs
View bot logs

@gibahjoe
Copy link
Contributor Author

@ferferga That is fine.

@endrl
Copy link
Contributor

endrl commented Apr 17, 2023

Playground for WebOS and Tizen is now open ;)
#1967

@jellyfin-bot jellyfin-bot added the merge conflict Something has merge conflicts label Apr 28, 2023
@ferferga ferferga force-pushed the master branch 3 times, most recently from 5e698fd to 26d3ab7 Compare May 1, 2023 22:03
@endrl
Copy link
Contributor

endrl commented May 3, 2023

The question is should be "keyboard navigation" with auto focus and highlight a default feature which is always enabled? Or a build flag? Webos, tizen and any other client(*older) that might want to embed jellyfin-vue needs compatibility hacks anyway

Media Keys
Implementing some media keys for the player(s) might be a good thingKeyboardEvent and MultimediaKeys

// code is empty because of windows...?! good to know

KeyboardEvent: key='MediaPlayPause' | code=''
KeyboardEvent: key='MediaTrackNext' | code=''
KeyboardEvent: key='MediaTrackPrevious' | code=''
KeyboardEvent: key='AudioVolumeMute'  | code=''
KeyboardEvent: key='AudioVolumeDown' | code=''
KeyboardEvent: key='AudioVolumeUp' | code=''

I had a look regarding key code mapping.

  • I don't know what jellyfin-web has implemented at this point
  • jellyfin-tizen i found no hacks. See Tizen docs and jellyfin-tizen
  • jellyfin-webos has basic key code mapping. However the media keys and partly the navigation seems to work out of the box

webos and tizen might be able to inject something like this if really required (Not sure if this really works).

// https://stackoverflow.com/questions/8776543/how-to-catch-event-keycode-and-change-it-to-another-keycode
Object.defineProperty(KeyboardEvent.prototype, 'key', {
    get: function() {
        switch (this.keyCode) {
            case 19: return 'MediaPlayPause';
            case 415: return 'MediaPlayPause';
            default: return this.key
        }
    }
})

@ferferga
Copy link
Member

ferferga commented May 4, 2023

Just a heads up for everybody reading: @ThibaultNocchi and me have been discussing this internally.
This might be a good fit to be in core, since key navigation is also important for accesibility concerns. However, in case it gets too "out of scope", I opened a discussion explaining how we want to deal with features that could get too platform/use-case specific.

But again, it might be interesting to have a proof of this wotking in core first (hence all merge conflicts fixed) because it's relevant for desktop users as well.

@ferferga ferferga added the blocked Something depends on another issue or Pull Request label May 4, 2023
@Ritchie1108
Copy link

Ritchie1108 commented May 5, 2023

The question is should be "keyboard navigation" with auto focus and highlight a default feature which is always enabled? Or a build flag? Webos, tizen and any other client(*older) that might want to embed jellyfin-vue needs compatibility hacks anyway

Media Keys Implementing some media keys for the player(s) might be a good thingKeyboardEvent and MultimediaKeys

// code is empty because of windows...?! good to know

KeyboardEvent: key='MediaPlayPause' | code=''
KeyboardEvent: key='MediaTrackNext' | code=''
KeyboardEvent: key='MediaTrackPrevious' | code=''
KeyboardEvent: key='AudioVolumeMute'  | code=''
KeyboardEvent: key='AudioVolumeDown' | code=''
KeyboardEvent: key='AudioVolumeUp' | code=''

I had a look regarding key code mapping.

  • I don't know what jellyfin-web has implemented at this point
  • jellyfin-tizen i found no hacks. See Tizen docs and jellyfin-tizen
  • jellyfin-webos has basic key code mapping. However the media keys and partly the navigation seems to work out of the box

webos and tizen might be able to inject something like this if really required (Not sure if this really works).

// https://stackoverflow.com/questions/8776543/how-to-catch-event-keycode-and-change-it-to-another-keycode
Object.defineProperty(KeyboardEvent.prototype, 'key', {
    get: function() {
        switch (this.keyCode) {
            case 19: return 'MediaPlayPause';
            case 415: return 'MediaPlayPause';
            default: return this.key
        }
    }
})

https://github.com/jellyfin/jellyfin-web/blob/master/src/scripts/keyboardNavigation.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Something depends on another issue or Pull Request discussion needed This PR or issue needs discussion before going further merge conflict Something has merge conflicts vue Pull requests that edit or add Vue files
Projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants