HTML5 video player: dynamically loading videos

后端 未结 1 862
花落未央
花落未央 2021-02-13 18:54

So, using a HTML 5 compliant video player, (like Video JS) how would one go about loading a video dynamically, without having to reload the entire page? Imagine, a list of links

相关标签:
1条回答
  • 2021-02-13 19:05

    Came up with a simple solution. Here's the script; throw this in the head:

    function vidSwap(vidURL) {
    var myVideo = document.getElementsByTagName('video')[0];
    myVideo.src = vidURL;
    myVideo.load();
    myVideo.play();
    }
    

    And then the HREF will call the function:

    <a href="#" onClick="javascript:vidSwap('myMovie.m4v'); return false;">Link</a>
    
    0 讨论(0)
提交回复
热议问题