dtvx3420 2014-09-09 20:43
浏览 62
已采纳

如何从HTML5中的数据库一个接一个地显示视频

I have a video table which contains (more than one) id and video_path. I want to play video one after another from the database using PHP in HTML5. note that I keep only video path in the table.

I am trying

PHP

    $connection...
    while($row = mysqli_fetch_assoc($controller)) {     
    $id = $row['id'];
    $url = $row['video_path'];
    $vdo = $_POST[$url];
}

HTML

<video id="custom_video_play" width="400" controls="controls" src="$vdo" autoplay="autoplay" loop>
</video>

my database query is working properly. I want to fix the code error only to watch video in web page. if someone please help! Thanks in advance

  • 写回答

1条回答 默认 最新

  • doudeng2184 2014-09-09 20:56
    关注

    You can recursively call a play function which checks if the current video has ended, if it has it will get the next src path in your array.

        // Get the video of the element
        var video = $('#your_video_elem');
        var video_array; // get your array of video paths
        var n = 0;
    
        $(document).ready(function(){
             // Check if DOM is ready, if so play the first video.
            play_video();
        });
    
        function play_video() {
            if(video.get(0).ended) {
                video.attr('src', video_array[n]);
                n++;
                play_video();    // call recursively to get the next video
            } 
        }
    

    The play_video method is called recursively only one the current video has ended, it loops through your array of video paths and updates the src of your video tag each time

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致
  • ¥15 禅道二次开发编辑版本,上传不了发行包