0

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

我是怎么试过的?要播放的视频不在我的网站文档根目录中,而是在文档根目录之外,因此我无法命名要播放的文件,例如example.com/video/vid1.flv,而我正在做的是使用url example.com/video/index.php?id=hnngthf 来获取数据,在这个 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 和 flow player 但没有运气,让我们看看我是如何使用这些播放器的

视频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();

Video js 错误消息:*Video Error 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 也在生产服务器上尝试过),还在 Ubuntu 12.04 上安装了 mod_flvx 和客户端是 chromium 也尝试了 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,正如您在上面看到的注释代码,这些是我的试验和错误......我尝试了很多,没有运气

4

0 回答 0