这就是到目前为止我在下面所做的。如果我在函数中硬编码file: media/video2.mp4,它可以工作,但当我把它变成一个变量时,它不能正确传递它,因为我总是得到这个错误:
Error loading player: No playable sources found代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My JWPlayer</title>
<script type="text/javascript" src="jwplayer/jwplayer.js" ></script>
<script type="text/javascript">
function changeVideo(filename) {
jwplayer("video").setup({
file: " + filename + ",
height: 360,
width: 640,
});
jwplayer('video').load();
}
</script>
</head>
<body>
<div id="video">Loading the player ...</div>
<script type="text/javascript">
jwplayer("video").setup({
file: "media/video1.mp4",
height: 360,
width: 640
});
</script>
<p><a href="javascript:void();" onclick="javascript:changeVideo('media/video2.mp4');">Play Video 2</a></p>
</body>
</html>发布于 2013-06-10 21:47:23
这是因为您将变量filename作为字符串文字放置在脚本中。
只需更改此行即可
file: " + filename + ",至
file: filename,而且它会工作得很好!
https://stackoverflow.com/questions/17024840
复制相似问题