现场没有播放声音

时间:2014-11-21 13:42:22

标签: javascript wordpress audio console

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

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

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 个答案:

答案 0 :(得分: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