【发布时间】:2015-02-08 16:37:20
【问题描述】:
我有一个带有工厂的 AngualrJS 应用程序,它负责在某些事件中播放音频。 我在该工厂创建了 3 种不同的音频。 我的问题是在 IE10 中,我从其他控制器调用的只有一个音频(已发送消息)正在播放 3,而另外 2 个正在播放(从同一工厂调用),仅在我逐步运行时和之后的调试器中播放第一次玩然后它在没有调试器的情况下按预期工作。 在 Chrome 和 Firefox 中效果很好。
var sounds = {
messageSent: new Audio('/assets/audios/message-sent.mp3'),
privateMessageRecived: new Audio('/assets/audios/private_message.mp3'),
notificationRecieved: new Audio('/assets/audios/notification-recived.mp3')
};
然后播放音频:
sounds[soundName].play();
mime 类型是audio/mpeg。
function start() {
pusherEvents.onAll(function(channelName, eventName, data) {
if (!isEmbedInactive() || isMuted()) {
return;
}
switch (eventName) {
case 'message':
if (!isMe(data.sender_id)) {
SpotsManager.getSpot({ id: data.spot_id })
.then(function(spot) {
if (spot.type === 'intimate') {
sounds.privateMessageRecived.play();
}
});
}
break;
case 'user_mentioned':
if (!isMe(data.mentioner.id)) {
sounds.notificationRecieved.play();
}
break;
case 'message_liked':
var isMine = isMe(data.sender_id);
if (isMine) {
sounds.notificationRecieved.play();
}
break;
case 'invitation_accepted':
if (!isMe(data.invitee.id)) {
sounds.notificationRecieved.play();
}
break;
case 'intimate_user_invited':
sounds.notificationRecieved.play();
break;
}
});
}
【问题讨论】:
标签: javascript angularjs audio internet-explorer-10