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

JSMpeg.Player is much slower than HTML version #154

Open
tsunamilx opened this issue Apr 11, 2017 · 4 comments
Open

JSMpeg.Player is much slower than HTML version #154

tsunamilx opened this issue Apr 11, 2017 · 4 comments

Comments

@tsunamilx
Copy link

tsunamilx commented Apr 11, 2017

When I use the HTML version:

<div class="jsmpeg" data-url="<url>"></div>

It looks very good!

Then I want to control the video by API, so I changed to JS version

var player = new JSMpeg.Player(url [, options]);

But it is very slow and laggy, my browser is Chrome. Why is that?

BTW, if I use the HTML version, can I get the instance from HTML element, so I can control via the API? Something like:

var player = document.querySelector('.jsmpeg');
player.play();
player.stop();
@phoboslab
Copy link
Owner

There shouldn't be any performance difference when instantiating JSMpeg directly in JavaScript. After all, the HTML tag uses it internally. Are there any errors in your browser's console?

A way to get the player instance from the HTML tag is a good idea, though. I'll implement this.

@phoboslab
Copy link
Owner

phoboslab commented May 10, 2017

You can now get a reference to the player from the HTML element through element.playerInstance. Note that the players are created in the DOMContentLoaded event - they will not be accessible before that.

document.addEventListener('DOMContentLoaded', function(){
	var player = document.querySelector('.jsmpeg').playerInstance;
	player.play();
});

@tsunamilx
Copy link
Author

There shouldn't be any performance difference when instantiating JSMpeg directly in JavaScript. After all, the HTML tag uses it internally.

Yeah, I agree, I also checked the code, there shouldn't be any difference. But it is actually different when I watch the video. I look closely, the visual size of the video of the js version is somehow bigger than the html version (it's like cover vs contain in css background size).
I can upload a screencast here later if you want.

And thanks for the player instance in html version, will be very useful.

@luizj
Copy link

luizj commented May 11, 2017

@phoboslab you have changed min.js version with more than one change, the another code added not work.

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