JW播放器通过变量分配文件

JW player assign file through variable

playlist: [{

        "sources": [{"type": "video/mp4", "label": "SD", "file": "src.mp4"}] 
}],

如何像

一样使用js变量给视频文件src赋值
playlist: [{
"sources": [{"type": "video/mp4", "label": "SD", "file": myvariable    }] 
}],

file的值是一个表示文件位置的字符串。通常是绝对 url。由于某些原因,该演示在 SO 上不起作用 ✎,但它作为 PLUNKER

注:我用的是ES6Template Literal instead of the usual String Literal. If you intend to cater to IE users, you'll have to use String Literal

演示PLUNKER

Demo STACK(不起作用,请查看 PLUNKER

<!doctype html>
<html>

<head>
  <meta charset="utf-8">
  <title></title>
  <script src="http://p.jwpcdn.com/6/12/jwplayer.js"></script>
</head>

<body>
  <div id="x">...</div>
  <script>
    var file = '023642.mp4';

    var jwp = jwplayer('x');
    jwp.setup({
      playlist: [{
        file: `http://media6000.dropshots.com/photos/1381926/20170326/${file}`
      }],
      width: 320,
      height: 180
    });
  </script>

</body>

</html>

✎ 与 OP 无关,但关于此 Stack 的功能,请参阅 @TinyGiant detailed answer