如何使用数组中的项创建连续播放?

时间:2014-04-03 19:07:10

标签: php html mysql

我在这里有一些代码,我试图让它一次显示一个项目。我想让它一个接一个地播放视频,在视频之间有一些输入(按钮或其他)。与5by.com的工作方式类似。它目前在列表中显示我的所有视频。有人可以帮忙吗?

`

<?php

    $genre = $user_data['interview'];
    $raw_results = mysql_query ("SELECT `link` FROM `short_films` WHERE `genre` LIKE '$genre'");
    while ($row = mysql_fetch_array($raw_results)){

?>
    <div id="video_player">
        <iframe src="<?php echo $row['link'] ?>" type=""></iframe>
    </div>
<?php
    }
    include 'includes/overall/footer.php';
?>

`

2 个答案:

答案 0 :(得分:0)

您必须paginate结果。我会让你弄明白,但这是一般概念:

<video id="video_<?php echo $row['id'] ?>" src="<?php echo $row['link'] ?>"></video>

var vid = document.getElementById("video_<?php echo $row['link'] ?>");
vid.onended = function(e) {
      $.ajax({ 
          // get next video and create an element
      });
}

答案 1 :(得分:0)

<script> function next_video () { var xmlhttp; if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.getElementById ("video_player").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","play.php",true); xmlhttp.send(); } </script>     

$genre_action       = $user_data['action'];
$genre_adventure    = $user_data['adventure'];
$genre_art          = $user_data['art'];
$genre_animation    = $user_data['animation'];
$genre_documentary  = $user_data['documentary'];
$genre_drama        = $user_data['drama'];
$genre_interview    = $user_data['interview'];
$genre_romance      = $user_data['romance'];
$genre_sf           = $user_data['sf'];
$genre_visual       = $user_data['visual'];
$raw_results = mysql_query ("SELECT `link` FROM `short_films` WHERE `genre` = '$genre_action' OR `genre` = '$genre_adventure' OR `genre` = ' $genre_art' OR `genre` = '$genre_animation' OR `genre` = '$genre_documentary' OR `genre` = '$genre_drama' OR `genre` = '$genre_interview' OR `genre` = '$genre_romance' OR `genre` = '$genre_sf' OR `genre` = '$genre_visual'  LIMIT 1");
while ($row = mysql_fetch_array($raw_results)){
?>
<div id="video_player">
    <iframe src="<?php echo $row['link'] ?>" type=""></iframe>
</div>
<button type="button" onclick="next_video()">next video</button>
<?php
}
     include 'includes/overall/footer.php';
?>

`

这是我到目前为止所拥有的!我已经在另一个页面上添加了播放器的div,然后我使用include来添加它。我的问题是,虽然第一个视频播放,但是当我点击下一个视频时我得到403错误(你没有访问所请求对象的权限。它是读保护的或服务器不可读。)