I am trying to embed videos using the Play Framework and JW Player. I can hard code and make it work just fine, but I want to use the model’s class to determine the video file (via path) that will be embedded.
Here is the code I have been playing with, but is not working:
<script src="@{'/public/jwplayer/jwplayer.js'}"></script>
<script>
$(document).ready(function(){
var content = ${_post.content};
setVideo(content)
});
</script>
<script type='text/javascript'>
function setVideo( content )
{
jwplayer('mediaspace').setup({
'flashplayer': "@{'/public/jwplayer/player.swf'}",
'file': content,
'controlbar': 'bottom',
'width': '640',
'height': '480'
});
}
</script>
Honestly, this is probably more of pseudo code at this point… But hopefuly it is clear what I am trying to do here:
- Retrieve the content of the post (in the case the content will be
the path to the video) - Place that into the function.
- Which will set the ‘file’: content.
Any suggestions on how to tackle this?
Some ideas for tackling the issue:
var contentshould be a string?_post.contentget generated? why the underscore? are you doing this from within a play template tag?Hope this helps.