按查询字符串加载mp4视频



我需要通过查询字符串加载mp4视频。使用jquery我的代码不更新视频源。如果我将示例视频url放在html5源id中,它可以在没有JQuery的情况下工作。我的任务是打开加载了正确视频的页面。

问题是代码没有看到JS源代码。当我不应该用$定义变量的时候。

  <video id='videoPlayer' width="640" height="480" controls="controls">
      <source id='mp4Source' src="" type="video/mp4" />  
    </video>  
    <script src="jquery.min.js"></script>
<!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">-->
  <script>
$(document).ready(function () {
    // theVid will be populated by query string, for testing it's hard coded.
    //var theVid = 'http://html5demos.com/assets/dizzy.mp4';
    var theVid = 'http://techslides.com/demos/sample-videos/small.mp4';
    var player = document.getElementById('videoPlayer');
    var mp4Vid = document.getElementById('mp4Source');
    player.pause();
      // Now simply set the 'src' attribute of the mp4Vid variable!!!!
      // (...using the jQuery library in this case)
    $(mp4Vid).attr('src', theVid);
    player.load();
    //player.show();
    player.play();   
});
$('#mp4Source').attr('src', theVid);

您没有将源代码设置为html。试试。

最新更新