2016-08-22 104 views
0

我正在使用放大彈出來顯示圖片... 當彈出窗口打開時,是否可以開始播放au音頻文件?關閉窗戶時停止它?放大彈出,如何彈出打開時播放音頻文件,關閉彈出時停止播放

 <a href="images/capoeira.jpg" class="fh5co-project-item image-popup to-animate"> 
      <img src="images/berimbau.jpg" alt="Animason groupes" class="img-responsive"> 
      <div class="fh5co-text"> 
      <h1>ANIMA'SON</h1> 
      <span>Participants: minimum 10, maximum: 20</span> 
      </div> 
     </a> 

回答

0

我通過每一個影像彈出鏈接

<a href="images/capoeira.jpg" data-sound="berimbau" class="fh5co-project-item image-popup to-animate"> 
     <img src="images/berimbau.jpg" alt="Animason groupes" class="img-responsive"> 
      <div class="fh5co-text"> 
       <h1>ANIMA'SON</h1> 
       <h2>60€/heure/groupe</h2> 
       <span>Participants: minimum 10, maximum: 20</span> 
      </div> 
      <audio id="berimbau-audio" loop="loop" preload="none"> 
       <source src="./sounds/berimbau.ogg" type="audio/ogg"> 
       <source src="./sounds/berimbau.mp3" type="audio/mpeg"> 
      </audio> 
    </a> 

中添加音頻標籤和添加的回調,他莊重,彈出式options.js,使用數據的聲音參數和音頻解決它。 ID

$(文件)。就緒(函數(){VAR soundName; VAR audioElement;

// MagnificPopup 
    var magnifPopup = function() { 
    $('.image-popup').magnificPopup({ 
    .... 
     callbacks: { 
     elementParse: function(item) { 
     soundName = item.el[0].attributes['data-sound'].value; 
     audioElement= document.getElementById(soundName + "-audio") 
     audioElement.load(); 
     }, 
     close: function() { 
     audioElement.pause(); 
     }, 
     change: function() { 
     audioElement.play(); 
     } 
    }, 
相關問題