jw玩家不会玩

时间:2013-06-24 19:25:41

标签: javascript jwplayer

我有一个嵌入了jw播放器的ASP.NET Web应用程序

我有这个调用播放器的功能。它加载,但它不播放视频。

function watchMovie() {

                  $("#vidRecorderHolder").html("<span id='vidRecorderDIV'></span>");
                  var flashvars = {};
                  //flashvars.file = "rtmp://localhost:5080/irreducibleVideoRecorder/streams/vid_undefined.flv";
                  //flashvars.file = "rtmp://localhost:5080/irreducibleVideoRecorder/flv:streams/vid_undefined.flv";
                  flashvars.file = "C:\\Red5\\webapps\\irreducibleVideoRecorder\\streams\\vid_undefined.flv";
                  flashvars.bufferLength = 2;
                  flashvars.autostart = "false";

                  var parameters = {};

                  var attributes = {};
                  attributes.id = "audioPlayer";
                  attributes.name = "audioPlayer";
                  swfobject.embedSWF("jwplayer/player.swf", "vidRecorderDIV", "400", "320", "11.2.0", "scripts/expressInstall", flashvars, parameters, attributes);
              }

对于指定文件的前两个注释掉的行,它会给我一个“未找到”的错误,但就像现在一样,玩家只有一个“游戏”符号,但按下它什么都不做。

\是一个转义字符,所以我想我会在那里放两个斜杠,因为当我用Chrome查看页面来源时,它省略了字符。

现在页面源读取

<param name="flashvars" value="file=C:\Red5\webapps\irreducibleVideoRecorder\streams\vid_undefined.flv&amp;bufferLength=2&amp;autostart=false">

这仍然看起来很奇怪,但我不确定这是否相关

我可以确认该文件在目录中,并且可以播放。

页面来源


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/swfobject.js" type="text/javascript"></script>

    <title>
    Home Page
</title><link href="Styles/Site.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form method="post" action="Default.aspx" id="ctl01" enctype="multipart/form-data">
<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMjA2NTIwMDgwNw9kFgJmD2QWAgIDDxYCHgdlbmN0eXBlBRNtdWx0aXBhcnQvZm9ybS1kYXRhZGQlAX0mmeHCCAuOdpcUwBxGH14XJq01zIbI4uCjZlatCw==" />
</div>


<script src="/WebResource.axd?d=MJP5xkYPuyWBAjVU2xsV-Ap2JP1L220SBXlo3NjcDd8nogK0ORiSjVtryfppfDDGc0ng66U7H1aIS7AXhxSYzmap9_sZlZB7JlPbjfVnsV41&amp;t=635067596440015508" type="text/javascript"></script>
<div class="aspNetHidden">

    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwL3msvyAgKbwpb7BgKQ27PvDeRlS3bV+I+t0mZfoGe3YHVdQS6I+/ddesy6Gg5KpxvT" />
</div>
    <div class="page">
        <div class="header">
            <div class="title">
                <h1>
                    My ASP.NET Application
                </h1>
            </div>
            <div class="loginDisplay">

                        [ <a href="Account/Login.aspx" id="HeadLoginView_HeadLoginStatus">Log In</a> ]

            </div>
            <div class="clear hideSkiplink">
                <a href="#NavigationMenu_SkipLink"><img alt="Skip Navigation Links" src="/WebResource.axd?d=T_8NFTKgMGpmwN-MxtBGLhNPWQQCQCTOa8uoBDlXGQ-NVWkd3uGFEJgng62cCcewoNt4jyQGp3B6P2tEJPk51WuRKvO1gE1qzDp5lWaAI9c1&amp;t=635067596440015508" width="0" height="0" style="border-width:0px;" /></a><div class="menu" id="NavigationMenu">
    <ul class="level1">
        <li><a class="level1" href="Default.aspx">Home</a></li><li><a class="level1" href="About.aspx">About</a></li>
    </ul>
</div><a id="NavigationMenu_SkipLink"></a>
            </div>
        </div>
        <div class="main">

            <input name="ctl00$MainContent$File1" type="file" id="MainContent_File1" />
            <input type="submit" name="ctl00$MainContent$b1" value="Upload" id="MainContent_b1" />

           <link href="vid.css" rel="stylesheet"> 

           <object width="400" height="400">
            <embed src="commercialtribe.swf" type="application/x-shockwave-flash" width="400" height="400" allowscriptaccess: "always" name="vidRecorder"  Attributes.name="vidRecorder"/>
           </object>

           <input type="button" value="next" onclick="DoNext()" />

           <input type="button" value="watch" onclick="watchMovie()" />

          <img src="" id="imagebox" height=400 width=400/>

          <input type="hidden" name="ctl00$MainContent$fetch" id="MainContent_fetch" />

          <div id="vidRecorderHolder"><span id="vidRecorderDIV"></span></div>

           <script type="text/javascript">
               var index = 1;
               document.getElementById("imagebox").src = "./Data/image1.png";

               function DoNext() {
                   var get = document.getElementById('MainContent_fetch').value;

                   var getInt = parseInt(get);
                   if(index<getInt){
                      index++;
                      document.getElementById("imagebox").src = "./Data/image"+(index)+".png";
                   }else{
                      index=1;
                      document.getElementById("imagebox").src = "./Data/image1.png";
                  }

                  thisMovie("vidRecorder").addTimeStamp();
              }

              function thisMovie(movieName) {
                  if (navigator.appName.indexOf("Microsoft") != -1) {
                      return window[movieName];
                  } else {
                      return document[movieName];
                  }
              }
              var timeArr = Array();
              function timeArray(x) {
                  alert("Your time array is " + x);
                  x = timeArr;
              }


              function watchMovie() {

                  $("#vidRecorderHolder").html("<span id='vidRecorderDIV'></span>");
                  var flashvars = {};
                  //flashvars.file = "rtmp://localhost:5080/irreducibleVideoRecorder/streams/vid_undefined.flv";
                  //flashvars.file = "rtmp://localhost:5080/irreducibleVideoRecorder/flv:streams/vid_undefined.flv";
                  flashvars.file = "C:\\Red5\\webapps\\irreducibleVideoRecorder\\streams\\vid_undefined.flv";
                  flashvars.bufferLength = 2;
                  flashvars.autostart = "false";

                  var parameters = {};

                  var attributes = {};
                  attributes.id = "audioPlayer";
                  attributes.name = "audioPlayer";
                  swfobject.embedSWF("jwplayer/player.swf", "vidRecorderDIV", "400", "320", "11.2.0", "scripts/expressInstall", flashvars, parameters, attributes);
              }

           </script>


        </div>
        <div class="clear">
        </div>
    </div>
    <div class="footer">

    </div>

<script type='text/javascript'>new Sys.WebForms.Menu({ element: 'NavigationMenu', disappearAfter: 500, orientation: 'horizontal', tabIndex: 0, disabled: false });</script></form>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

我找到了解决方案。

我替换了

flashvars.file = "C:\\Red5\\webapps\\irreducibleVideoRecorder\\streams\\vid_undefined.flv";

有了这个:

flashvars.file = "http://localhost:5080/irreducibleVideoRecorder/streams/vid_undefined.flv";

在绝对文件系统路径之前,它之前是rtmp://,但是没有用,但是当我将其更改为http时,它就有用了。

我要离开this tutorial,但也许我没有rtmp服务器。我认为Red5是一个,但现在我看到它只支持它。