English 中文(简体)
将下一个项目列入议程。
原标题:calling the next item in my array

我现在有一系列录像。 当我点击下方和预击阵列负荷的下方或前方录像时,我如何这样做。

 <video id="video" controls autoplay width="1000">
  <source src="videos/test.mp4" type= video/mp4; codecs="avc1.42E01E, mp4a.40.2"  />
  <source src="videos/test.ogv" />
 </video>

<a href="#" onClick="javascript:vidSwap(vidURL[i+]); return false;">next</a>



<script>
var vidURL=["videos/test.ogv","videos/test2.ogv","videos/test3.ogv","videos/test4.ogv","videos/test5.ogv"    ]; // literal array
function vidSwap(vidURL) {
var myVideo = document.getElementsByTagName( video )[0];
myVideo.src = vidURL;
myVideo.load();
 myVideo.play();
}

问题回答

Using yout code, it ll be something like this. What you need to do is have the video that you loaded on a javascript variable. Then, when you click prev or next you can call a function that will put the correct video number and call it.

<script>
var vidURL=["videos/test.ogv","videos/test2.ogv","videos/test3.ogv","videos"]
var video = 0;

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


function prevVideo() {
  if(video == 0) {
    video = vidUrl.length;
  }
  else {
    video -= 1;
  }

  vidSwap();
}

function nextVideo() {
  if(video == length) {
    video = 0;
  }
  else {
    video += 1;
  }

  vidSwap();
}

</script>


 <video id="video" controls autoplay width="1000">
  <source src="videos/test.mp4" type= video/mp4; codecs="avc1.42E01E, mp4a.40.2"  />
  <source src="videos/test.ogv" />
 </video>

<a href="#" onClick="javascript:prevVideo(); return false;">prev</a>
<a href="#" onClick="javascript:nextVideo(); return false;">next</a>

引入可节省现有录像指数的变量,然后在你下台/前台时予以增减。

</script>
var i = 0;
<script>

javascript:vidSwap(vidURL[i++])

它希望你再次在你的增资操作员中找到另一个附加标志。

Try changing

<a href="#" onClick="javascript:vidSwap(vidURL[i+]); return false;">next</a>

www.un.org/Depts/DGACM/index_spanish.htm 页: 1

<a href="#" onClick="javascript:vidSwap(vidURL[i++]); return false;">next</a>

a. 总结选择;

<a href="#" onClick="return Vids.next();">next</a>
<a href="#" onClick="return Vids.prev();">prev</a>

...

var Vids = (function() {
    var _currentId = -1;
    var _urls = ["videos/test.ogv","videos/test2.ogv","videos/test3.ogv","videos/test4.ogv","videos/test5.ogv"    ]; // literal array
    return {
        next: function() {
            if (++_currentId >= _urls.length)
                _currentId = 0;
             return this.play(_currentId);
        },
        prev: function() {
            if (--_currentId < 0)
                _currentId = _urls.length - 1;
            return this.play(_currentId);
        },
        play: function(id) {
            var myVideo = document.getElementsByTagName( video )[0];
            myVideo.src = _urls[id];
            myVideo.load();
            myVideo.play();
            return false;
       }
    }
})();




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签