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

Can the hs.webview display local videos? #1421

Open
Ninlives opened this issue May 11, 2017 · 7 comments
Open

Can the hs.webview display local videos? #1421

Ninlives opened this issue May 11, 2017 · 7 comments

Comments

@Ninlives
Copy link

Well I just want to make something like a dynamic wallpaper and I tried to use hs.webview, these html can play local videos in Safari

  <html>
  <video src="/path/to/local/video" id="vi" autoplay="autoplay"></video>
  </html>

but in hs,webview the video didn't show up. Is there any way to do this?

@latenitefilms
Copy link
Contributor

You could try this?

#1236 (comment)

@Ninlives
Copy link
Author

It works but the display feels laggy, and It eats a lot of CPU, maybe Hammerspoon is not good at this kind of task.:)
Anyway, thanks!

@asmagill
Copy link
Member

I experimented with a module for the AVPlayerView object a while back as an additional type for a canvas... trying to tie the two together I ran into a number of issues that would require a complete rethinking of how Hammerspoon handles view objects, so I kind of put it on hold. However, if there is interest, I think I could have an independent AVPlayerView module available in a few days... it wouldn't integrate with canvas and would be in its own window (though like webview, I'd add methods to choose the window decorations, resizability, etc.)

@Ninlives
Copy link
Author

@asmagill Thanks for the quick response :)
And I found it weird that the display is not laggy actually, it's because I turn off the sound then it will pause a while after a few seconds then continue playing..if I turn on the sound it works great, is this a bug?

@asmagill
Copy link
Member

No clue... Does that seem to make a difference when you play it through Safari? (or another web browser, but Safari is probably going to be the closest comparison to the WKWebView object we use since they're both provided by Apple and both WebKit based)

A completely off-the-top-of-my-head-no-real-evidence-to-support-it theory might be that turning audio off changes the playback buffer cache size and since Hammerspoon does 90%+ of its work on the main thread in the main queue the new cache isn't big enough... but this doesn't get us any closer to a fix since WKWebview doesn't allow us to modify cache sizes and if it's a plugin handling the playback, we have even less control, so...

I'm going to see if I can resurrect my avplayer module this weekend and maybe we can see if it fairs any better.

@Ninlives
Copy link
Author

Ninlives commented May 12, 2017

Works fine in Safari.

@asmagill
Copy link
Member

If you want to take a look at an avplayer module, check out https://github.com/asmagill/hammerspoon_asm/tree/master/avplayer

I've not had the chance to test it beyond loading a local file and playing it, so if you do use it, please let me know if you run into anything that doesn't work as expected.

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