2017-09-02 131 views
0

請問,你能幫助我嗎?我有這個代碼,在HTML5視頻播放懸停...但我需要,沒有暫停時mouseout,但顯示IMG海報就像刷新。MouseOver - 顯示海報/ HTML5視頻,WordPress

任何想法?泰

的functions.php

function custom_video_preview(){ 
?> 
<script> 
var figure = jQuery(".video").hover(hoverVideo, hideVideo); 

function hoverVideo(e) { 
    jQuery('video', this).get(0).play(); 
} 

function hideVideo(e) { 
    jQuery('video', this).get(0).pause(); 
} 
</script> 
<?php 
} 
add_action('wp_footer', 'custom_video_preview'); 

,並在後期我的HTML代碼

<div id="videosList">   
<div class="video"> 
    <video class="thevideo" loop preload="none" poster="https://t12.pixhost.org/thumbs/383/50595935_s970x545.jpg"> 
     <source src="https://my.mixtape.moe/qvmktx.mp4" type="video/mp4"> 
    Your browser does not support the video tag. 
    </video> 
    </div> 
</div> 

謝謝

回答

0
var figure = jQuery(".video").hover(hoverVideo, hideVideo); 

調用hoverVideo功能,當它進入選擇(徘徊)「 .video「,然後在退出時調用hideVideo。你會想要替換這一行。

var figure = jQuery(".video").mouseenter(hoverVideo); 

這是關於懸停的jQuery文檔。 https://api.jquery.com/hover/

+0

謝謝你,但它不工作:/ 下面是測試版/結果 - http://68108.w8.wedos.ws/domains/giftbox.sk/2014/11/23/are-will -took-form-the-nor-true/ –

+0

當鼠標退出時它會繼續播放,所以它似乎在工作?看起來有點遲緩。點擊ctrl + f5,這將做一個硬刷新刷新JavaScript的你。 – Chad