문제

Is there any way we can make the JW Player auto resizable when it loads?

Like, for instance, if the movie file is smaller in dimensions than the player,then there is black background it. I want the movie to spread all over the black color.

Thanks in advance.

도움이 되었습니까?

해결책

There are a couple of stretching options that can be set via flashvar. These include none (no stretching), exactfit (disproportionate), uniform (stretch with black borders) or fill (uniform, but completely fill the display). They're all listed on our flashvars page.

If you're looking to update the size of the player within the DOM, it may be possible, but it's certainly not recommended, as this would cause Flash to reload the player.

Best,

Zach

Developer, LongTail Video

다른 팁

The following works for me:

<html>
<script type="text/javascript" src="jwplayer.js"></script>
<script type="text/javascript">jwplayer.key="LicenceCodeGoesHere";</script>
<div id="container">This'll be the player</div>

<script type="text/javascript">
jwplayer("container").setup({
    file:"http://videoURLGoesHere",
    autostart:true,
    width: "100%",
    height: "98%",
ratio: "100%",
responsive: true,
    events:{
        onComplete: function() {
            window.location = "http://redirectGoesHere";
        }
    }

});

</script>
<a href="http://UrlGoesHere">Please click here to skip the video and load the main site</a> 
</html>

Hope this helps!

As far as resizing the player itself, as opposed to scaling the content inside it, JW Player has a resize function now, which you can combine with the onMeta event to resize the player to match the video dimensions. Note that I've only tried this on streaming video, so I'm not 100% sure the meta event works the same on file-based playback.

You might want to use the onMeta event to calculate the correct size, but wait until an onPlay event to actually call resize() - if you've got a still image loaded before playback begins, it'll still be up when you resize on the onMeta event, and it'll stretch but look a little weird for a second. This still happens at onPlay but it's faster.

In your jwplayer('video_id').setup() function, just include something like this in the options:

        events: {
          onMeta: function(event) {
            if(event.metadata.width != undefined && event.metadata.height != undefined && event.metadata.width != 0) {
              var playerWidth = 700;
              var playerHeight = (event.metadata.height/event.metadata.width)*playerWidth;
              jwplayer("video_id").resize(playerWidth, playerHeight);
            }
          }
        }

That's assuming you want to keep the width at 700 but scale the height of the player to fit the media file, and of course that your player has id "video_id" in the DOM.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top