An easily configured CDN hosted version of JWPlayer using your own license.
NOTE: This version only works with JWPlayer v7. They changed their CDN URL after v6. If you need the old version, use v6.0.0 of this package.
meteor add jeremy:jwplayer
The standard JW Player CDN hosted library provided to you in your account will have a unique token in the URL. It should look like the following:
<script src="https://content.jwplatform.com/libraries/YOUR_KEY_HERE.js"></script>
Simply grab the YOUR_KEY_HERE
section and pass that into the JWPlayer.load()
call in this plugin and the CDN hosted script will be added to your <head>
.
Load globally:
// anywhere on client
JWPlayer.load('YOUR_KEY_HERE');
Or only on specific routes:
// Iron Router
Router.onBeforeAction(function() {
JWPlayer.load('YOUR_KEY_HERE');
this.next();
}, { only: ['route1', 'route2'] });
// Flow Router
FlowRouter.triggers.enter([JWPlayer.load('YOUR_KEY_HERE')], {
only: ['route1', 'route2']
});
Just add an empty div with a unique id to any template:
<template name="myTemplate">
<div id="playa"></div>
</template>
and then configure your player:
// use JWPlayer.loaded() to reactively check that the lib is ready
Template.myTemplate.onRendered(function() {
this.autorun(function() {
if (JWPlayer.loaded()) {
jwplayer('playa').setup({
file: 'http://example.com/my-video.mp4',
width: '100%',
aspectratio: '16:9',
autostart: true
});
}
});
});