Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Load new video

2 replies [Last post]
Reply

Hi,

I have the following code, which loads a new video when a button si clicked. The thing is that the script is not very good and I am tring to find a different and better solution to do this.

The videos names are passed trough value attribute.But this loads a new flash player every time I click a button.

<div id='mediaspace'>This text will be replaced</div>

<script type='text/javascript'>
$(document).ready(function(){
$(".video").click(function(){
var selected=$(this).attr("value");

  jwplayer('mediaspace').setup({
    'flashplayer': 'player.swf',
    'file': selected,
    'streamer': 'rtmp://myserver/folder',
    'controlbar': 'bottom',
    'width': '470',
    'height': '290'
  });

  });
});
</script>

<a href="javascript:void(0);"><img src="btn1.jpg" width="71" height="106" class="video" value="video.mp4"/></a>

<a href="javascript:void(0);"><img src="btn2.jpg" width="71" height="106"  class="video" value="video2.mp4"/></a>

Thanks.

Reply

why not use the load feature of the JWPlayer.

For example

onclick="$jw('div1').load({image:'images/image.jpg',levels:[{file: 'video/Jelly Trip.mp4'},{file: 'video/Jelly Trip.ogv'}]}).play();"

from the above example:

  1. the player id is div1
  2. an image is loaded
  3. loads the video files via the level statment
  4. and optional if you want to start to play using the API .play(); this would superced or using the autostart if wanted
Reply

Post new comment

  • Allowed HTML tags: <code> <blockquote> <em> <strong> <strike> <ul> <li> <ol>
  • You may post code using <code>...</code> .
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options