Jatin Raikwar
Jatin Raikwar

Reputation: 394

Making JW Player resposive

My code

function get_signed_player($videokey,$playerkey) {
  $path = "players/".$videokey."-".$playerkey.".js";
  $expires = round((time()+3600)/300)*300;
  $secret = "xxxxxxxxxxxxxxxxxxxxx";
  $signature = md5($path.':'.$expires.':'.$secret);
  $url = 'http://cdn.jwplayer.com/'.$path.'?exp='.$expires.'&sig='.$signature;
  return $url;
};

echo "<p>Watch this cool video:</p>";
echo "<script type='text/javascript' src='".get_signed_player('xxxxxxx','xxxxxx')."' width=\"100%\"></script>";

It's working fine. But, it's coming in fixed width.

fixed width image

How can I make it full width and responsive?

Can you help, please

Upvotes: 0

Views: 343

Answers (1)

Todd
Todd

Reputation: 249

Your players/ URL is loading a single-line JW Player embed that takes on all the characteristics of your player as defined in your JW dashboard. You have two options:

1) Edit the cloud-hosted player with player ID $playerkey in the JW dashboard to have desired responsive width and aspect ratio

2) Completely change your JW Player embed method to be completely manual:

  • Load the player library URL on the page with the libraries/ endpoint
  • Include your on the page with a unique ID
  • Call Jwplayer('your_div_id').setup() and pass the desired parameters to load the video (file, image, width, aspectratio, etc)

Please see their documentation at https://developer.jwplayer.com/jw-player/docs/developer-guide/getting-started/add-an-html5-player/ for more details.

Upvotes: 0

Related Questions