Embedding videos in the Play Framework and JW Player

I am trying to embed a video using Play Framework and JW Player. I can hard code and do it very well, but I want to use the model class to define the video file (via the path) that will be embedded.

Here is the code that I played with but doesn't work:

<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 pseudo-code at the moment ... But hopefully it is clear what I am trying to do here:

  • Get the content of the message (in case the content is the path to the video)
  • Put this in a function.
  • Which will install the contents of the "file" :.

Any suggestions on how to handle this?

+4
source share
1 answer

Some ideas to solve the problem:

  • is the path visible in rendered HTML?
  • is it visible in generated javascript?
  • Do I need to run correctly? I would like to have your var content was a line?
  • How is _post.content generated? why underline? do you do this from a game template tag?
  • is a file accessible via the specified path, outside the script?

Hope this helps.

+1
source

Source: https://habr.com/ru/post/1415292/


All Articles