78
rated 0 times
[
83]
[
5]
/ answers: 1 / hits: 15551
/ 12 Years ago, thu, november 22, 2012, 12:00:00
So following JW Player's I can get a video to load (obviously) it looks like this:
<script type=text/javascript src=/scripts/jwplayer.js></script>
<div id=myElement>Loading the player ...</div>
<script type=text/javascript>
jwplayer(myElement).setup({
file: /uploads/example.mp4,
height: 360,
image: /uploads/example.jpg,
width: 640
});
</script>
I'm trying to accomplish something to this effect to load a video inside of a modal once that modal is triggered (using jQuery):
$(body).on('click', '[data-toggle=modal]', function(e){
var vid = $(this).attr('data-video');
jwplayer(videoElement).setup({ file: vid, width: 540 });
jwplayer(videoElement).play();
});
However I'm getting the error: Uncaught TypeError: Cannot call method 'setup' of null
I've tried the other following (probably horrible) ideas I've had:
$(#videoElement).jwplayer.setup({ file: vid, width: 540 });
and
var $jwplayer = jwplayer();
$(body).on('click', '[data-toggle=modal]', function(e){
$jwplayer(videoElement).setup({ file: vid, width: 540 });
}
However all yield the same result of Cannot call method 'setup' of null
Any pointers would be greatly appreciated.
More From » jquery