2014-11-21 99 views
0

我的网站存在问题。当我们创建网站时,声音完全运作,但当我们把它放在域上时,声音似乎不起作用。我们运行了错误测试,看起来声音正在控制台日志中运行,但实际上并未在网站上运行。活网站上没有声音播放

声音只出现在控制台日志中。

http://imgur.com/h8LXs1t

//////////////////////////////////////////////////////////////////////////////////////////////////////////// 
    playSound: function (clip) { //plays the sound that corresponds to the pad chosen 
     if ($("#sound").is(":checked")) {//Check Box Function 
      var sound = $('.sound' + clip)[0]; 
      console.log(sound); 
      console.log($('.sound' + clip)); 
      sound.currentTime = 0; //resets audio position to the start of the clip 
      sound.play(); //play the sound 
     } 
    }, 

这是实际的代码脱机能够起到的代码运行的JavaScript,但是,当我们把它放在网上,只在控制台日志中播放。我们正在寻找,了解如何让声音播放

继承人链接到真人版,所以你可以看到,声音不工作 - http://e-lemon-ators.com/

感谢提前的帮助。

回答

1

服务器发送.mp3和.ogg文件,但是使用Content-Type:text/html; charset=UTF-8标头。

你需要告诉服务器,设置正确的内容类型标头,例如这些规则添加到您的.htaccess

# MP3 audio 
AddType audio/mpeg3 .mp3 
AddType audio/mp3 .mp3 
AddType audio/x-mpeg3 .mp3 

# Ogg Vorbis audio 
AddType audio/ogg .ogg 
AddType audio/ogg .oga 
+0

我把它们添加到的.htaccess,但什么都没有改变 – hereskellie 2014-11-21 14:11:05

+0

@hereskellie是啊,还是在标题中获得'Content-Type:text/html;'。也许你的服务器不允许在.htaccess中使用'AddHeader'?尝试联系您的管理员或支持人员。 – pawel 2014-11-21 14:16:08