2017-05-12 6 views
0

これは私のimpress.jsスライドです。それらのうち2人にビデオがあります。フォーカススライドの音だけを鳴らしたいのですが。スライドが再生されるたびに、残りの部分がミュートされます。すべてのスライドには、ビデオ内にiframeがあります。Impress.jsにスライドしてフォーカスを合わせるときにビデオサウンドのミュートを解除する方法

動画のプレイリストのスクリプトは次のとおりです。動画の

function shuffle (array) { 
    var i = 0 
    , j = 0 
    , temp = null 

    for (i = array.length - 1; i > 0; i -= 1) { 
    j = Math.floor(Math.random() * (i + 1)) 
    temp = array[i] 
    array[i] = array[j] 
    array[j] = temp 
    } 
} 

function play_vid() { 
    video.src = links[current] 
    video.play(); 
    if(current!=links.length) { 
     current++; 
    } 
} 

var video = $("#w-video").get(0); 
var current = 0; 
var links = []; 
playlist = $('#playlist'); 
tracks = playlist.find('li a'); 

$.each(tracks, function(){ 
    links.push($(this).attr('href')); 
}); 
shuffle(links); 
play_vid(); 


video.onended = function(e) { 
    play_vid(); 
}; 

htmlコードは次のとおりです。

<video id="w-video" class="video-js w-video" muted autoplay controls width=640 height=480></video> 
    <ul id="playlist"> 
    <li><a href="https://gemusteste.novohamburgo.rs.gov.br/temp_videos/[SMS]Filme_Mais_Medicos_1min.mp4">Number One</a> 
    <li><a href="https://gemusteste.novohamburgo.rs.gov.br/temp_videos/[SMS]FILME_MeningiteC_e_HPV_1min.mp4">Number Two</a> 

答えて

1

impress.jsは感動を放出します:stepenterたびにそれが動くJavaScriptのイベント次のステップ。このイベントのイベントリスナーを作成し、そのイベントリスナーで動画をミュート/ミュート/再生/停止する必要があります。 event.targetは入力されたステップです。 See the last examples of DOCUMENTATION.md for more info

document.addEventListener("impress:stepenter", function(event){ 
    if(event.target.id == "step-1") { 
     // unmute video 1, mute video 2 
    } 
    else if(event.target.id == "step-2") { 
     // unmute video 2, mute video 1 
    } 
    else { 
     // mute both videos 
    } 
}); 
関連する問題