简体   繁体   English

视频在 Chrome 但不是 Firefox 中工作

[英]Video working in Chrome but not Firefox

I can get videos to play in Chrome with the embed tags towards the bottom of the page, I have them commented out.我可以使用页面底部的嵌入标签在 Chrome 中播放视频,我已将它们注释掉。 Anyway, it doesn't work for Firefox and I can't find another way to get it to display and play my video from the database.无论如何,它对 Firefox 不起作用,我找不到另一种方法让它从数据库中显示和播放我的视频。

Within the div tag, myElement , if I type the location of the video on my computer, it'll load right up, but I'm wanting to get the video off my db by $url and every time I try, it says 'A plugin is needed to display this content or No video found.'在 div 标签myElement ,如果我在计算机上输入视频的位置,它会立即加载,但我想通过$url将视频从我的数据库中取出,每次尝试时,它都会显示“需要一个插件来显示此内容或未找到视频。

I've also tried using <video> , didn't seem to work either.我也试过使用<video> ,似乎也没有用。

<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
 <title>Watch</title>
<script src="http://jwpsrv.com/library/6QVxzPkvEeSkJwp+lcGdIw.js"></script>
<script src="jwplayer/jwplayer.js" ></script>
<script>jwplayer.key="7SYdCOHxpEaICfiAz4rXDkkgf+fcssszRYDb2Q==";</script>
</head>

<body>

<div id="myElement">Loading the player...</div>
<script type="text/javascript">
jwplayer("myElement").setup({
    file : "<?php  ?>",
    //image: "",
    width: 640,
    height: 360
});
</script>

<?php

if(isset($_GET['id']))
{
$id = $_GET['id'];
$query = mysql_query("SELECT * FROM `videos` WHERE id='$id'");
while($row = mysql_fetch_assoc($query))
{
    $name = $row['name'];
    $url = $row['url'];
}

echo "Your are watching ".$name."<br />";
//echo "<embed src='$url' width='560' height='315'></embed>"; 
}
else
{
    echo "Error!";
}

?>

</body>
</html>

Solution解决方案

Instead of :代替 :

echo "<embed src='$url' width='560' height='315'></embed>";

Use this :用这个 :

echo "<video controls src='$url' width='560' height='315'></video>";

After HOURS & a few days of trying to find out my problem, I was messing around with the video tags and BOOM!经过 HOURS 和几天的尝试找出我的问题后,我开始处理视频标签和 BOOM! echo "<video controls src='$url' width='560' height='315'></video>"; If you're having my pain of 'A plugin is needed to display to content' or 'Format or MIME type not supported' try this out!如果您为“需要一个插件来显示内容”或“不支持格式或 MIME 类型”而苦恼,请试试这个! $url is what I'm using to retrieve the video from my database so that's the location of the file just incase anyone wanted or needed to know. $url 是我用来从我的数据库中检索视频的东西,所以这是文件的位置,以防万一有人想要或需要知道。 BTW I was using the video tags as HTML5 and it wasn't working so I switched it and now it's working like a champ顺便说一句,我将视频标签用作 HTML5,但它不起作用,所以我切换了它,现在它像冠军一样工作

(Source: http://www.w3schools.com/html/html5_video.asp ) (来源: http : //www.w3schools.com/html/html5_video.asp

The video you're testing might be a format that's supported by Chrome but not Firefox.您正在测试的视频可能是 Chrome 支持但 Firefox 不支持的格式。 Generally you wind up needing to provide sources for multiple formats just to be safe (example from W3C link above):通常,为了安全起见,您最终需要提供多种格式的来源(例如来自上面的 W3C 链接):

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM