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

Using nwjs #78

Open
jdauthre opened this issue Nov 27, 2020 · 1 comment
Open

Using nwjs #78

jdauthre opened this issue Nov 27, 2020 · 1 comment

Comments

@jdauthre
Copy link

Not so much an issue, more a how to, I would like to use mpv.js with nwjs but I can find no examples or explanation on how to do this, examples seem to always use electron. There was a non react example in the issues but it just produced a "plugin not supported" error Any help appreciated
Thanks

@sirisian
Copy link

sirisian commented Feb 5, 2021

See this: #76 (comment) for building the latest mpv.js compatible with the latest mpv dll. (You have to follow the build steps in the mpv.js README first to setup the environment). This might be fixed sometime, but I'm leaving this here to know that the latest mpv libraries weren't compatible with mpv.js at the time of this comment.

In nw.js you need to register the pepper plugin in your package.json.

"chromium-args": "--register-pepper-plugins='./node_modules/mpv.js/build/Release/mpvjs.node;application/x-mpvjs'"

Then in your program you use it:

const mpv = document.createElement('object');
mpv.type = 'application/x-mpvjs';
mpv.width = width;
mpv.height = height;
mpv.addEventListener('message', msg => {
	if (msg.data.type === 'ready') {
		// this.setProperty(..., ...); to set mpv properties
		this.setProperty('pause', false);
		
		// For blackmagic you'd call like:
		this.setPropertyString('demuxer', 'lavf');
		const avOptions = `video_size=${inputwidth}x${inputheight}:pixel_format=${inputpixelformat}:framerate=${inputframerate}:rtbufsize=702000k`;
		this.setPropertyString('demuxer-lavf-o', avOptions);
		this.runCommand('loadfile', 'av://dshow:video=Decklink Video Capture:audio=Decklink Audio Capture');
		// For RTSP you can just call
		this.runCommand('loadfile', url);
	}
});

There's a lot of various mpv settings for different scenarios. (Like turning on subtitles). You can also setup a socket and listen for logs from mpv.

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

2 participants