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 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 基于52单片机的酒精浓度检测系统加继电器和sim800
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答