模态隐藏后缓冲不会停止

时间:2016-02-24 06:25:47

标签: php codeigniter twitter-bootstrap-3 bootstrap-modal

当我开始播放视频并暂停时。或者隐藏模型缓冲不停止 我的型号代码是: -

<div class="modal fade" id="model_<?=$l_no;?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
   <div class="modal-dialog" >
      <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">Preview</h4>
         </div>
         <div class=" modal-body">
            <?php if($row1['type']=='video'){ ?>
            <video  style="width: 100%; height:auto;" preload="none" controls>
               <source src="<?=$row1['file_path'];?>" type="video/mp4" >
            </video>
            <?php }elseif($row1['type']=='audio'){ ?> 
            <audio preload="none" controls>
               <source src="<?=$row1['file_path'];?>" type="audio/mpeg">
            </audio >
            <?php }else{ ?>
            <iframe src="http://docs.google.com/viewer?url=<?=$row1['file_path'];?>&embedded=true"  style="width: 100%; height:450px;"></iframe>
            <?php } ?>     
         </div>
      </div>
   </div>
</div>

我也尝试了所有这些功能

$('body').on('hidden.bs.modal', '.modal', function () {
  $('video').trigger('pause');
  //$('video').remove();
  $('video').currentTime = 0;
  //$('#myModalPrev .modal-body').empty();
  });

但它只暂停我的视频但无法停止缓冲

1 个答案:

答案 0 :(得分:0)

尝试使用...

$('body').on('hidden.bs.modal', '.modal', function () {
   var video = jQuery('video').get(0);
   video.trigger("pause");
   video.addEventListener('pause',function(){
     var tmp_src = video.src;
     var playtime = video.currentTime;
     video.src = '';
     video.load();
     video.src = tmp_src;
     video.currentTime = playtime;
   });
 });