1

I have an ASP.NET web application with a jw player embedded inside

I have this function that calls the player. It loads, but it doesn't play the video.

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);
              }

For the first two commented-out lines designating the file, it gives me a "not found" error, but as it is now, the player only has a "play" symbol, but pressing it does nothing.

\ is an escape character, so I figured I'd put double slashes there, because when I viewed the page source with Chrome, it omitted the characters.

Now the page source reads

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

Which still looks weird, but I'm not sure if that's relevant or not

I can confirm that the file is in the directory, and is playable.

Page source


<!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>
4

1 回答 1

1

我找到了解决方案。

我换了

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

有了这个:

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

在绝对文件系统路径之前,它以前是rtmp://,并且不起作用,但是当我将其更改为 时http,它就起作用了。

我打算离开本教程,但也许我没有 rtmp 服务器。我以为 Red5 是其中之一,但现在我看到它只支持它。

于 2013-06-24T19:51:25.980 回答