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

player.tech().vhs is undefined on Safari #8654

Open
vaclavgreif opened this issue Mar 23, 2024 · 7 comments
Open

player.tech().vhs is undefined on Safari #8654

vaclavgreif opened this issue Mar 23, 2024 · 7 comments

Comments

@vaclavgreif
Copy link

Description

I'm using Amazon S3 as a storage for my videos, and because the medias are not public, I need to presign the URLs to get access to the files. I'm using the following on the onReady hook:

const handlePlayerReady = (player) => {
		playerRef.current = player;

		const playerXhrRequestHook = (options) => {
			const file = options.uri.replace(/^[^:]+:\/\/[^/?#]+\//, '')

			const result = synchronousRequest(addQueryArgs(window.wpify_protected_video.sign_url, {file, bucket}));
			options.uri = JSON.parse(result).uri;
			return options;
		};

		if (playerRef.current.tech().vhs) {
			playerRef.current.tech().vhs.xhr.onRequest(playerXhrRequestHook);
		}
	};

This works great everywhere except on Safari, where I get player.tech().vhs is undefined.

When I set the media to public, the video plays fine even on Safari, but I need to handle the presigning. Is there a way to make this work on Safari?

Reduced test case

https://zitlehce.cz/protected-video/trailer-rosta-vaclavek/

Steps to reproduce

  1. Check the video playing fine on Chrome or Firefox
  2. Check it on Safari and see the JS error.

Errors

TypeError: undefined is not an object (evaluating 'g.current.tech().vhs.xhr')

What version of Video.js are you using?

8.10.2

Video.js plugins used.

No response

What browser(s) including version(s) does this occur with?

Safari

What OS(es) and version(s) does this occur with?

MacOS

@vaclavgreif vaclavgreif added the needs: triage This issue needs to be reviewed label Mar 23, 2024
Copy link

welcome bot commented Mar 23, 2024

👋 Thanks for opening your first issue here! 👋

If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.

@phloxic
Copy link
Contributor

phloxic commented Mar 23, 2024

By default Video.js prefers native HLS playback in Safari.

If you want/need vhs features in Safari, set the vhs overrideNative config option to true.

@vaclavgreif
Copy link
Author

@phloxic Awesome, this seems to work great, thanks!

@vaclavgreif
Copy link
Author

@phloxic Reopening this one, as it does not seem on mobile Safari. Is there any way to make this work on mobile Safari please?

@vaclavgreif vaclavgreif reopened this Mar 27, 2024
@phloxic
Copy link
Contributor

phloxic commented Mar 28, 2024

See @mister-ben's answer here.

It should work on iPad OS, see the VHS docs.

@vaclavgreif
Copy link
Author

@phloxic Thanks. Would you know of any other way to presign the URL on iPhones? Thanks!

@phloxic
Copy link
Contributor

phloxic commented Mar 28, 2024

@vaclavgreif - I haven't got a clue ;-) Sorry.

@mister-ben mister-ben removed the needs: triage This issue needs to be reviewed label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants