流式传输.flv视频从php无效,使用流媒体播放器和视频js

时间:2013-03-06 11:29:39

标签: php apache streaming video-streaming flowplayer

我试图在我的网站上添加视频播放..

我是怎么试过的?   要播放的视频不在我的网站文档根目录中,而是在Doc root之外,因此我无法将文件命名为 example.com/video/vid1.flv ,而是我正在做的是使用网址 example.com/video/index.php?id=hngthf 来获取数据,并在这个php文件中我做

                //Video Streaming
            header('Content-Description: File Transfer');
            header('Content-Type: video/flv');
            //header('Content-Disposition:attachment; filename=' . $justName);
            header('Content-length: ' . filesize($fileName));
            header('Expires: 0');
            header('Content-Transfer-Encoding: binary');
            $file = fopen($fileName, 'r');
            echo stream_get_contents($file);    
            //echo file_get_contents($fileName);
            fclose($file);

然后在客户端,我试图使用videojs和流媒体播放器,但没有运气,让我们看看我如何使用这些播放器

视频js

var myPlayer = _V_("myVideo",{"techOrder" : ["flash"], "controls" : true, "autoplay" : false, "preload": "auto"});
            _V_.options.flash.swf = "../scripts/video-js.swf"
            myPlayer.src('../index.php?id=' + code);
            //myPlayer.src('../my.flv');
            myPlayer.load(); 
            myPlayer.play();

视频js错误消息:     *视频错误 V .Event {type:“error”,timeStamp:1362567722368,vdata1362567711568:true,preventDefault:function,stopPropagation:function ...} video.js:21 Flash Error srcnotfound myVideo_flash_api *

even though it says src not found, it actually hit my php  and getting executed

然后流播放器

步骤1

flowplayer("player", "../scripts/flowplayer-3.2.16.swf", {
                plugins: {
                    secure: {
                        url: '../scripts/flowplayer.securestreaming-3.2.8.swf'
                    }   
                },

                clip: {
                    provider: 'http',
                    url: '../index.php?id=' + code
                }
            }); 

流播放器错误消息:      200,未找到流,NetStream.Play.StreamNotFound,剪辑:

步骤-2

var videoURL = "index.php?id=" + code;
            //var videoURL = "my.flv";
            var htmll = '<object width="640" height="264" type="application/x-shockwave-flash" data="../scripts/flowplayer-3.2.16.swf">';
            htmll += '<param name="wmode" value="transparent"/><param name="movie" value="../scripts/flowplayer.securestreaming-3.2.8.swf" />';
            htmll += '<param name="allowfullscreen" value="true" />';
            htmll += '<param name="flashvars" value=\'config={"playlist":[{"url": "' + videoURL + '", "baseUrl": "http://localhost", "autoPlay":false,"autoBuffering":true,"bufferLength":5}]}\' /></object>';
            $("#videoTag").html(htmll);

Flow player  error message : 
*200 stream not found Netstream.play.StreamNotFound, clip:*

注意:     我在服务器上使用Apache,php,mysql(Localhost也在生产服务器上试过),还安装了mod_flvx和客户端是在Ubuntu 12.04上的chrome也试过firefox

1,也尝试在apache中添加类型      #AddType video / flv .flv       AddType video / x-flv .flv      #AddType video / x-flv flv

2,在php,$ fileName中,我在Doc root中保存了一个flv文件并尝试从php脚本中获取它但没有运气

3,在上面的所有客户端示例中,如果我在服务器中提供直接的.flv文件,而不是给出.php,那么它可以工作

4,正如你可以看到上面评论的代码,那些是我的试验和错误...我试了很多,没有运气

0 个答案:

没有答案