单击播放按钮捕获Html5视频src

时间:2014-08-26 12:55:48

标签: jquery html5 html5-video

当我点击那个html5视频帧的播放按钮时,我的目标是捕获Html5视频src。如何在jquery中实现?

<video src="video.ogv">
 video not supported
</video>

<script>
var video = document.getElementsByTagName('video')[0];
 video.onended = function(e) {
  /*Do things here!*/
};

$('video source').each(function(num,val){
console.log($(this).attr('src'));        // i am not getting this..
strSrc = $(this).attr('src'); 
strPath = strSrc.substring(0, strSrc.lastIndexOf('/'));
strExtenion = strSrc.substring(strSrc.lastIndexOf('.'));
$(this).attr('src', strPath + "/" + "newFileName" + strExtenion );
alert($(this).attr('src'));

})

1 个答案:

答案 0 :(得分:0)

类似

   <video id='vids' src="video.ogv">
       video not supported
   </video>

   <input id='plyvid' type='button'  />

 <script>
$('#plyvid').click(function(){
 var vid = $('#vids');
 vid.get(0).play();
  var vidSrc =  vid.attr('src'); //Here you get the SRC

 });
  var video = document.getElementsByTagName('video')[0];
  video.onended = function(e) {

  alert($(video).attr('src')) ;// I am not tested this ..may it works for you.

  };
    </script>