I'm new to angular. I want to know how to integrate JWPlayer in my angular 4 project.I have already imported src of jwplayer.js in .angular-cli.json. Thank You.
First you have to make it visible in your Angular project by adding a type definition:
declare var jwplayer: any;
You can add this type definition either in the component ts-file or in the typings.d.ts file.
Then add the div to your component like that:
<div id="myDiv">This text will be replaced with a player.</div>
Then in the component add the code e.g. in the ngOnInit function:
jwplayer("myDiv").setup({
"file": "http://example.com/myVideo.mp4",
"image": "http://example.com/myImage.png",
"height": 360,
"width": 640
});
If the import through angular-cli.json does not work you can also add a script tag to the head area of your index.html and load it there directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With