Jwplayer视频播放器无法正常工作
Jwplayer video player not working
我正在尝试设置 Jwplayer 视频播放器,但没有任何显示,根本没有显示视频播放器。我在设置中做错了什么,因为我按照说明进行操作,但视频文件来自数据库并且 mysqli 绝对正确:
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Preview Video</title>
<script type="text/javascript" src="jquery/jwplayer.js"></script>
</head>
<body>
<?php
$getvideo = 'VideoFiles/' . $_GET['filename'];
$videoquery = "SELECT VideoFile FROM Video WHERE (VideoFile = ?)";
if (!$videostmt = $mysqli->prepare($videoquery)) {
// Handle errors with prepare operation here
}
// Bind parameter for statement
$videostmt->bind_param("s", $getvideo);
// Execute the statement
$videostmt->execute();
if ($videostmt->errno)
{
// Handle query error here
}
$videostmt->fetch();
$videostmt->close();
?>
<div id="myElement">Loading the player...</div>
<script type="text/javascript">
jwplayer("myElement").setup({
file: "<php echo $getvideo ?>",
image: "/uploads/example.jpg",
});
</script>
**UPDATE:**
Current code:
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Preview Video</title>
<script type="text/javascript" src="jquery/jquery-1.7.min.js"></script>
<script type="text/javascript" src="jquery/jwplayer.js"></script>
</head>
<body>
<?php
$getvideo = 'VideoFiles/' . $_GET['filename'];
$videoquery = "SELECT VideoFile FROM Video WHERE (VideoFile = ?)";
if (!$videostmt = $mysqli->prepare($videoquery)) {
// Handle errors with prepare operation here
}
// Bind parameter for statement
$videostmt->bind_param("s", $getvideo);
// Execute the statement
$videostmt->execute();
if ($videostmt->errno)
{
// Handle query error here
}
$videostmt->bind_result($dbVideoFile);
$videostmt->fetch();
$videoPath='http://domain.com/videos/'.$dbVideoFile;
$videostmt->close();
?>
<div id="myElement">Loading the player...</div>
<script type="text/javascript">
jwplayer("myElement").setup({
file: "<php echo $videoPath ?>",
image: "example.jpg",
});
</script>
</body>
好的,正在发生的事情是,当我使用 $GET 方法从上一页(使用超链接)获取视频的文件名时,它会打开一个新页面,网址如下:
http://helios.hud.ac.uk/u05454444/Mobile_app/previewvideo.php?filename=sample_mpeg4_5.mp4
当我尝试检索视频文件时,在数据库中,它以VideoFiles/sample_mpeg4_5.mp4
的形式存储在数据库中。
这是因为视频存储在VideoFiles
文件夹中
现在它显示一个黑色方块,视频播放器应该在其中显示:
Error loading player:
No playable sources found
我是否需要包含jwplayer.html5.js
的js文件,我是否缺少可能需要的任何其他文件,还是其他问题所在?
萤火虫:
使用Firebug,我在下面有以下HTML,其中包含视频播放器显示位置的html:
<div style="position: absolute;">
<object id="_GPL_swf" width="1" height="1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
<param value="http://shoppingside-a.akamaihd.net/items/it/swf/f.swf" name="movie">
<param value="high" name="quality">
<param value="transparent" name="wmode">
<param value="always" name="allowScriptAccess">
<param value="keywordsURL=http%3A//i.trkjmp.com/kwd%3Fc%3DOjo6aGVsaW9zLmh1ZC5hYy51azp6LTEyMjItMTIwODcw%26cb%3D_GPL.items.a652c.displayKeywords&keywords=error%20loading%20player%7Cno%20playable%20sources%20found"
name="flashVars">
<object id="_GPL_swf" width="1" height="1" type="application/x-shockwave-flash"
data="http://shoppingside-a.akamaihd.net/items/it/swf/f.swf">
<param value="high" name="quality">
<param value="transparent" name="wmode">
<param value="always" name="allowScriptAccess">
<param value="keywordsURL=http%3A//i.trkjmp.com/kwd%3Fc%3DOjo6aGVsaW9zLmh1ZC5hYy51azp6LTEyMjItMTIwODcw%26cb%3D_GPL.items.a652c.displayKeywords&keywords=error%20loading%20player%7Cno%20playable%20sources%20found"
name="flashVars">
</object>
</object>
</div>
<div id="_GPL_e6a00_parent_div" style="position: absolute; top: 0px; left: 0px; width: 1px; height: 1px; z-index: 2147483647;">
<object id="_GPL_e6a00_swf" width="1" height="1" type="application/x-shockwave-flash"
data="http://shoppingside-a.akamaihd.net/items/e6a00/storage.swf">
<param name="wmode" value="transparent">
<param name="allowscriptaccess" value="always">
<param name="flashvars" value="logfn=_GPL.items.e6a00.log&onload=_GPL.items.e6a00.onload&onerror=_GPL.items.e6a00.onerror&LSOName=gpl">
</object>
</div>
<div id="myElement" style="width: 480px; height: 270px; background-color: rgb(0, 0, 0); color: rgb(255, 255, 255); display: table; opacity: 1;">
<p style="vertical-align: middle; text-align: center; display: table-cell; font: 15px/20px Arial,Helvetica,sans-serif;">Error loading player:
<br>No playable sources found</p>
</div>
<script type="text/javascript">
jwplayer("myElement").setup({
file: "<php echo $videoPath ?>",
image: "example.jpg",
});
图像:
下面是显示的图像代码:
如果我选择一个称为 Tulips_3.png
的超链接,则 url 中显示的是这样的:
http://helios.hud.ac.uk/u05545444/Mobile_app/previewimage.php?filename=Tulips_3.jpg
然而,我所做的只是使用 get 方法检索文件名,在数据库中查找图像,其目录在前面ImageFiles/
因为数据库中的图像被保存为 ImageFiles/Tulips_3.png
,然后使用 source 显示图像,代码如下:
<body>
<?php
$getimage = 'ImageFiles/' . $_GET['filename'];
$imagequery = "SELECT ImageFile FROM Image WHERE (ImageFile = ?)";
if (!$imagestmt = $mysqli->prepare($imagequery)) {
// Handle errors with prepare operation here
}
// Bind parameter for statement
$imagestmt->bind_param("s", $getimage);
// Execute the statement
$imagestmt->execute();
if ($imagestmt->errno)
{
// Handle query error here
}
$imagestmt->bind_result($dbImageFile);
$imagestmt->fetch();
$imagestmt->close();
?>
<p><img alt="<?php echo $dbImageFile; ?>" height="200" width="200" src="<?php echo $dbImageFile; ?>"></p>
</body>
更新 2:
<script type="text/javascript">
jwplayer("myElement").setup({
file: "<?php echo $dbVideoFile; ?>",
image: "example.jpg",
});
</script>
echo 'this is $dbVideoFile: '.$dbVideoFile;
输出:这是$dbVideoFile:视频文件s/sample_mpeg4_5.mp4'
希望对您有所帮助。
脚本中有拼写错误:
<script type="text/javascript">
jwplayer("myElement").setup({
file: "<php echo $videoPath ?>",
image: "example.jpg",
});
</script>
应该是:
<script type="text/javascript">
jwplayer("myElement").setup({
file: "<?php echo $videoPath ?>",
image: "example.jpg",
});
</script>
请注意起始 php 标签中额外的问号 "?"。
- Javascript:selenium Web驱动程序isDisplayed()不工作
- jQuery UI自动完成突然停止工作
- AngularJS UI路由器不能像ng路由器那样工作
- HTML5音频加载和播放获胜'我不能在iPad上工作
- JavaScript打印功能使日历停止工作
- Javascript.getHours()工作不正常
- 为什么这在IE中的工作方式与在Firefox中不同
- 视频HTML没有'无法在Internet Explorer 11上工作
- 扩展移相器按钮类不工作
- Firebase迁移-简单的Firebase.set没有'不再工作了——旧的还是新的
- 谷歌地图不是以HTML显示,而是在JS Fiddle上工作
- 正在尝试使用if和else添加类,但无法正常工作
- Jquery FadeIn FadeOut 只工作一次
- Foreach无法在Typescript中工作
- 另一个ajax调用中的Jquery ajax调用在for循环中没有按预期工作
- 为什么不是't窗口.恢复正常工作吗?(javascript/jquery)
- JS可以在Chrome中工作,但不能在Firefox中工作
- 最大高度转换不;不工作,工作缓慢
- Gulp-rev:不是第一次工作,而是在第一次工作之后工作
- JQuery - Ajax: encodeUriComponent不工作(EncodeUri工作)