0

私は以下のコードを持っています:

      <script type="text/javascript">
           jwplayer("container").setup({
           flashplayer: "http://test.captive-portal.com/jwplayer/player.swf",
                        file: "http://content.captive-portal.com/files/video/cirque-du-soleil/mob.mp4",
                        image: "http://content.captive-portal.com/files/video/cirque-du-soleil/mob.jpg",
                        height: 285,
                        width: 480,
           });
      </script>

ページ全体はここにあります (必要な場合に備えて): video page

私がやろうとしているのは、ウィンドウの解像度に応じて、file: (...)、image (...)、height(...)、width (...) の 4 行を変更することです。私はcssでこれを行うことができたので、スタイルは正しく適用されますが、これはjavascriptであり、変更方法がよくわかりません. 1 つのページに 2 つの同様のスクリプトを div に配置し、大きな画面の場合は小さなスクリプトを非表示にするか、小さな画面の場合は大きなスクリプトを非表示にしようとしましたが、うまくいきませんでした。ビデオが再生されませんでした。これは、Flash Player ファイル内のいくつかのスクリプトが原因である可能性があります。

画面の解像度に応じて、これらの 4 行の条件を設定する方法はありますか? よろしくお願いいたします。

4

1 に答える 1

1

これらのパラメーターは単なるオブジェクトです。

したがって、jwplayer 呼び出しからそのオブジェクトを作成し、単純に渡すことができるはずです。

var params = {};
params.flashplayer = "http://test.captive-portal.com/jwplayer/player.swf";
if(!mobile){ //you need to handle checking for mobile devices
    params.file = "http://content.captive-portal.com/files/video/cirque-du-soleil/desktop.mp4";
    params.image = "http://content.captive-portal.com/files/video/cirque-du-soleil/desktop.jpg";
    params.height = 570;
    params.width = 960;
}else{
    //set params in same way but with mobile settings
}

jwplayer("container").setup(params);

後でプレーヤーのサイズを変更したい場合。JwPlayer には、呼び出すことができる「サイズ変更」関数があります。jwplayer.resize(width,height)

于 2013-01-28T10:28:08.973 に答える