s0dz
s0dz

Reputation: 121

Embedding video with Play Framework and JW Player

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:

  1. Retrieve the content of the post (in the case the content will be the path to the video)
  2. Place that into the function.
  3. Which will set the 'file': content.

Any suggestions on how to tackle this?

Upvotes: 4

Views: 609

Answers (1)

msung
msung

Reputation: 3742

Some ideas for tackling the issue:

  1. is the Path visible in the rendered HTML?
  2. is it visible in the generated javascript?
  3. does it need to be escaped correctly? i'd image your var content should be a string?
  4. how does the _post.content get generated? why the underscore? are you doing this from within a play template tag?
  5. is the file accessible via said path, outside of the script?

Hope this helps.

Upvotes: 1

Related Questions