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

[Bug]: ApiVideoPlayer IFRAME steals focus for key presses when autoplay property is set to false. #21

Closed
will-grange-inclusive opened this issue Jun 13, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@will-grange-inclusive
Copy link

will-grange-inclusive commented Jun 13, 2024

Version

@api.video/[email protected]

Environment that reproduces the issue

Windows Chrome, but this appears to be common accross all browsers/devices tested so far.

Is it reproducible in the example application?

Yes

Reproduction steps

Clone and run the source code from the demo available here. See instructions in the README.md
https://bitbucket.org/inclusive/api-video-taking-focus/src/master/

The demo sets up the ApiVideoPlayer with autoplay=true and autoplay=false depending on what is passed in the URL to show different behavior.

Key presses are being made to unpause the video which pauses automatically again after 3 seconds by design. When autoplay=false, it can clearly be seen that the IFRAME steals focus and therefor the containing window cannot recieve keyDown or keyUp events. Clicking into the parent window again will refocus the parent and keypresses can be used again.

Scenario functioning correctly

  1. Launch the demo with autoplay enabled (true)
  2. Press a key
  3. Press the video will play
  4. Press a key
  5. Press the video will play again

Scenario functioning incorrectly

  1. Launch the demo with autoplay disabled (false)
  2. Press a key
  3. Press the video will play
  4. No further key-presses can be received by the top level document as the IFRAME has focus

Expected result

Parent window can recieve keyUp and keyDown events, without the IFRAME taking focus when autoplay=false.

Actual result

No keyUp and keyDown events received because the IFRAME has focus after the first keypress.

Additional context

No response

Relevant logs output

No response

@will-grange-inclusive will-grange-inclusive added the bug Something isn't working label Jun 13, 2024
@will-grange-inclusive
Copy link
Author

Screenshot from our bug demo where the IFRAME has stolen focus and no keypresses are being received:

image

@will-grange-inclusive
Copy link
Author

will-grange-inclusive commented Jun 13, 2024

Screenshot from our bug demo where autoplay is enabled and focus is not being stolen:

image

@will-grange-inclusive
Copy link
Author

will-grange-inclusive commented Jun 13, 2024

This is still a bug the the api.video player but a workaround can be a applied where the autoplay prop is set to true and the video is paused in response to the onReady callback. This will reproduce the effective autoplay=false behavior but the main window still has focus and keyUp/keyDown events etc can be received.

@will-grange-inclusive
Copy link
Author

will-grange-inclusive commented Jun 14, 2024

The above workaround (setting autoplay to true and pausing the video) did not help the situation on iPad Chrome and iPad Edge as this resulted in the audio not playing - see bug reported #22

Instead we have to detect that the window has blured, then take the focus back after a few miliseconds. We then simulate the keyUp even that we missed. The inputs/access then works as expected. Clearly this workaround is not ideal.

@olivierapivideo
Copy link
Member

Hi @will-grange-inclusive
Thanks you for this detailed feedback. That is due to the accessibility features of the player that keeps the focus to capture key presses. We'll add an option to disable it. That will fix your issue. The updated version will be released today or tomorrow.

olivierapivideo added a commit that referenced this issue Jun 19, 2024
- Add `hotkeys` parameter (#21)
- Add `customDomain` parameter
- Migrate to functionnal component
@olivierapivideo olivierapivideo mentioned this issue Jun 19, 2024
olivierapivideo added a commit that referenced this issue Jun 19, 2024
- Add `hotkeys` parameter (#21)
- Add `customDomain` parameter
- Migrate to functionnal component
olivierapivideo added a commit that referenced this issue Jun 19, 2024
- Add `hotkeys` parameter (#21)
- Add `customDomain` parameter
- Migrate to functionnal component
@olivierapivideo
Copy link
Member

@will-grange-inclusive can you try with the new v1.1.0 version ?

Please note that there is one breaking change with this version. You'll now have to use

const videoRef = useRef<ApiVideoPlayerRef>(null)

instead of:

const videoRef = useRef<ApiVideoPlayer>(null)

To fix the focus issue, you can use the following parameter:

<ApiVideoPlayer
   hotKeys={false}
   // ...

We've also add a new customDomain parameter that you should use:

<ApiVideoPlayer
   customDomain='embed.xxxx.com' // replace with your domain
   // ...
   ```

@will-grange-inclusive
Copy link
Author

@olivierapivideo - I've tested this on a branch of the bug demo app and with the hotKeys={false} property applied, that the key presses are no longer being swallowed by the IFRAME contents. We are mid testing (many videos * platforms * access methods to test), so not applying to our main code base just yet but closing this based on the demo app resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants