Force HTML5 video to use NPAPI?
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.
This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.
Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.
This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.
Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
-
jobbautista9
- Board Warrior

- Posts: 1037
- Joined: 2020-11-03, 06:47
- Location: Philippines
Force HTML5 video to use NPAPI?
I noticed when I disable WebM support and then try to play a WebM video directly, the browser offers me an option to play it with the VLC Web Plugin. I wonder how feasible it would be to force all <video>s (as well as <audio>s) to be handled by NPAPI instead of the browser. Would such a behavior even be compliant with the HTML5 spec?

"Destroying things, smartly!" - IJN Samidare, probably
Avatar artwork by ebifurya: https://www.pixiv.net/artworks/85379109
XUL add-ons developer. You can find a list of add-ons I manage at http://rw.rs/~job/software.html.
-
moonbat
- Knows the dark side

- Posts: 5689
- Joined: 2015-12-09, 15:45
Re: Force HTML5 video to use NPAPI?
Can you post a sample link to try this? Also what version of VLC are you using? I have 3.0.20 on Linux and there's no NPAPI included.
"One hosts to look them up, one DNS to find them and in the darkness BIND them."

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
Jabber: moonbat@hot-chili.net

KDE Neon on a Slimbook Excalibur (Ryzen 7 8845HS, 64 GB RAM)
AutoPageColor|PermissionsPlus|PMPlayer|Pure URL|RecordRewind|TextFX
Jabber: moonbat@hot-chili.net
-
UCyborg
- Astronaut

- Posts: 541
- Joined: 2019-01-10, 09:37
- Location: Slovenia
-
jobbautista9
- Board Warrior

- Posts: 1037
- Joined: 2020-11-03, 06:47
- Location: Philippines
Re: Force HTML5 video to use NPAPI?
Sample VP9 WebM: https://base-n.de/webm/out9.webm
I have VLC 3.0.21 on Windows, which includes an NPAPI plugin versioned 3.0.3.0. I think for Linux you might have to recompile VLC with the NPAPI plugin enabled in the build config.
Unfortunately it doesn't work with VORAPIS... Either VORAPIS will have to make their custom video player more compatible with YouTube's or ViewTube will have to target VORAPIS's player too.
Anyway I am aware of the ViewTube userscript (and I have used it before VORAPIS became a thing), but I would like something more universal... I'm thinking of writing a global userscript that converts all <video>s and <audio>s to <embed>s. It would still be nice if the browser itself offers the usage of NPAPI when it encounters an HTML5 video or audio in a webpage it can't play though.

"Destroying things, smartly!" - IJN Samidare, probably
Avatar artwork by ebifurya: https://www.pixiv.net/artworks/85379109
XUL add-ons developer. You can find a list of add-ons I manage at http://rw.rs/~job/software.html.
-
UCyborg
- Astronaut

- Posts: 541
- Joined: 2019-01-10, 09:37
- Location: Slovenia
Re: Force HTML5 video to use NPAPI?
I see, everything being wrapped in layers of JavaScript makes things difficult. I haven't experimented with this for a while. When I did try it, I didn't like that it didn't blend in as smoothly as expected. VLC may also not be the most optimal video player in general.
-
jobbautista9
- Board Warrior

- Posts: 1037
- Joined: 2020-11-03, 06:47
- Location: Philippines
Re: Force HTML5 video to use NPAPI?
FWIW I've found that I can use Greasemonkey to force audio and video accessed via top-level navigation to be played via an NPAPI plugin. It's cool to see userscripts even working for a page generated by the browser itself!
While it targets all webpages (it will check first if the document head has a stylesheet for top-level video though before executing the rest of the script), it will not affect local files (file:///) opened in the browser. You can force Greasemonkey to apply the userscript to file:/// URLs by toggling extensions.greasemonkey.fileIsGreaseable to true in about:config, but I don't recommend doing this as you're setting yourself up to malicious userscripts trying to steal the contents of your filesystem. You're better off using a proper media player for local files.
Code: Select all
// ==UserScript==
// @name NPAPI for top level audio and video
// @namespace job.tilde.team
// @include *
// @version 1.1
// @grant none
// ==/UserScript==
if (document.querySelector("link[href^='resource://'][href$='TopLevelVideoDocument.css']")) {
const html5Media = document.querySelector("video")
const npapiMedia = document.createElement("embed");
npapiMedia.src = window.location.pathname;
npapiMedia.type = "application/x-vlc-plugin";
if (html5Media.getAttribute("style")) {
npapiMedia.style = html5Media.getAttribute("style"); /* match audio's inline style */
} else { /* video does not have inline style */
npapiMedia.width = html5Media.videoWidth;
npapiMedia.height = html5Media.videoHeight;
}
const npapiStyle = document.createElement("style");
document.head.appendChild(npapiStyle);
npapiStyle.sheet.insertRule("embed {\
position:absolute;\
top: 0;\
right: 0;\
bottom: 0;\
left: 0;\
margin: auto;\
max-width: 100%;\
max-height: 100%;\
user-select: none;\
}");
document.body.replaceChild(npapiMedia, html5Media);
}

"Destroying things, smartly!" - IJN Samidare, probably
Avatar artwork by ebifurya: https://www.pixiv.net/artworks/85379109
XUL add-ons developer. You can find a list of add-ons I manage at http://rw.rs/~job/software.html.