如何在php中同时停止本地视频播放

时间:2018-01-25 04:39:18

标签: php iframe

我的页面中有8个视频,可从数据库中检索。他们同时玩。如果我点击另一个视频播放,如何让它们暂停。我找到了youtube视频,但没有找到本地视频。你能建议如何摆脱这个问题吗?

检查下面的代码:

<?php 

include 'config.php';

?>
<!DOCTYPE html>
<html>
<head>
<script>



</script>
</head>

<body>
<center>
<label style="font-size:2em;color:tomato"><b>Today's Video</b></label>
<table>
<tr>
<td>
<?php $sql="SELECT video_path FROM videos WHERE category =  'Films'
 AND postedby =  'Admin'";
 $res=mysqli_query($db,$sql);
 while($row=mysqli_fetch_array($res))
 {
 $vid=$row['video_path'];

  }
  ?>

  <iframe src=<?php echo $vid; ?> id="video-1" height="150" width="150" 
  frameborder="0" allowfullscreen="allowfullscreen"></iframe>
  </td>
  <td>

  <?php $sql="SELECT video_path FROM videos WHERE category =  'Political'
  AND postedby =  'Admin'";
  $res=mysqli_query($db,$sql); 
  while($row=mysqli_fetch_array($res))
  {
  $vid=$row['video_path'];

    }
  ?>

  <iframe src=<?php echo $vid; ?> id="video-2" height="150" width="150" 
  frameborder="0" allowfullscreen="allowfullscreen"></iframe>
  </td>
  </tr>
   <tr>
  <td style="text-align:center">
  <input type="text" value="Films" readonly style="font-
  weight:bold;color:white;background-color:#f7c02a;border:none;text-
  align:center;font-size:1em;width:150px">
  </td>
  <td style="text-align:center">
  <input type="text" value="Political" readonly style="font-
  weight:bold;color:white;background-color:#40cc16;border:none;text-
  align:center;font-size:1em;width:150px">
  </td>
  </tr>
  <tr>
  <td>
  <?php $sql="SELECT video_path FROM videos WHERE category =  'Shopping'
  AND postedby =  'Admin'";
  $res=mysqli_query($db,$sql);
  while($row=mysqli_fetch_array($res))
  {
  $vid=$row['video_path'];

   }
  ?>  
  <iframe src=<?php echo $vid; ?> height="150" width="150" frameborder="0" 
   allowfullscreen="allowfullscreen"></iframe>
  </td>
  <td>
  <?php $sql="SELECT video_path FROM videos WHERE category =  'Services'
  AND postedby =  'Admin'";
  $res=mysqli_query($db,$sql);
  while($row=mysqli_fetch_array($res))
   {

    $vid=$row['video_path'];

   }
  ?>  
  <iframe src=<?php echo $vid; ?> height="150" width="150" frameborder="0" 
   allowfullscreen="allowfullscreen"></iframe></td>
   </tr>
  <tr>
  <td style="text-align:center">
  <input type="text" value="Shopping" readonly style="font-
  weight:bold;color:white;background-color:#e825ce;border:none;         
  text-align:center;font-size:1em;width:150px"> 
  </td>
  <td style="text-align:center">
  <input type="text" value="Services" readonly style="font-
  weight:bold;color:white;background-color:#607c03;border:none;         
  text-align:center;font-size:1em;width:150px">
  </td>
  </tr>
  <tr>
  <td>
  <?php 
  $sql="SELECT video_path FROM videos WHERE category =  'Events'
  AND postedby =  'Admin'";
  $res=mysqli_query($db,$sql);
  while($row=mysqli_fetch_array($res))
  {     
   $vid=$row['video_path'];

    }
  ?>  
  <iframe src=<?php echo $vid; ?> height="150" width="150" frameborder="0" 
  allowfullscreen="allowfullscreen"></iframe>
  </td>
  </tr>
  </table>
  </center>
  </body>
  </html>

如果我在一个iframe中播放视频,剩余的视频应暂停或刷新。

1 个答案:

答案 0 :(得分:0)

我从stop all videos when a new video is played得到了答案。谢谢Satya和Anubhav Ranjan。我发布了我的代码。请验证并建议任何进一步的修改。

ca.fs_r(1)