我基本上试图构建的是一个自我读取的站点,并在使用鼠标时提供声音反馈。 Earcons的使用方式与大多数用户使用可视图标的方式类似。预先录制的语音轨道用于已知元素,例如我的唠叨栏菜单。我在大多数浏览器中使用E-Speak进行tts,但计划在IE中使用tts web服务,因为E-Speak在IE中不起作用。传统上,盲人用户可以通过击键来导航网站;但是,我是一名培训的网络开发人员,我通过使用声音作为校对布局的辅助来推动信封[即]我的div正确浮动?图像是否在正确的div中?我可以通过徘徊和倾听来检查这一点。它是一种颠覆性技术,它试图让你的思维更多地归功于使用更传统的阅读解决方案。
我已经在这几个星期了,仍然无法预加载我的所有声音。我已经使用了递归函数,理论上,在第一个声音对象加载之前,它不会创建下一个声音对象。我的十八个耳机正在装载并正确播放所需的事件,但我的12个语音轨道中只有三个似乎正在加载 - 或者,如果它们正在加载,则它们没有播放。
这是我的两个相关模块的代码。你们有没有想出一种可靠的预加载多种声音的方法?
var Earcons = (function() {
// Earcons are like icons, but use symbolic sounds instead of pictures
var trackUrls = [
"audio/newpage.mp3", "audio/fgrow.mp3", "audio/fshrink.mp3",
"audio/slideright.mp3", "audio/slideleft.mp3", "audio/sdiv.mp3", "audio/tell.mp3",
"audio/office_lobby.mp3", "audio/footstep.mp3", "audio/apple.mp3",
"audio/typewriter.mp3",
"audio/walking.mp3", "audio/macspeak.mp3", "audio/picklock1.mp3",
"audio/gossip.mp3", "audio/winenter.mp3", "audio/winleave.mp3", "audio/beep.mp3"];
var trackTitles = [
"soundOnLoad", "soundOnGrow", "soundOnShrink", "soundOnSlideRight",
"soundOnSlideLeft", "soundOnDiv", "soundOnParagraph", "work",
"soundOnList", "apple", "stype", "walk", "macbook",
"soundOnLink", "soundOnInput", "winenter", "winleave", "soundOnImage"];
var trackPtr = 0;
var getTrackNumber = function (trackName) {
for (i = 0; i < trackTitles.length; i++) {
if (trackName == trackTitles[i]) return i;
}
return -1;
};
var preload = function() {
if (trackPtr >= trackUrls.length)
{ trackPtr = 0; return; }
var trackId = "st" + trackPtr + "";
var trackUrl = trackUrls[trackPtr];
trackPtr++;
var soundTrack = soundManager.createSound ({stream: false,
id: trackId,
url: trackUrl,
autoLoad: false, autoPlay: false});
soundTrack.load ({onload: function() { preload(); } });
};
var unload = function() {
for (i = 0; i < trackUrls.length; i++) {
var soundTrack = soundManager.getSoundById ("st" + i);
soundTrack.unload();
soundTrack.destruct();
}
};
interface = {
trackUrls: trackUrls,
trackTitles: trackTitles,
getTrackNumber: getTrackNumber,
preload: preload,
unload: unload
};
return interface;
} )();
var Narrations = (function() {
var trackUrls = [
"audio/about.mp3", "audio/webtech.mp3", "audio/screenreader.mp3",
"audio/services.mp3", "audio/stories.mp3", "audio/settings.mp3",
"audio/feedback.mp3", "audio/display.mp3", "audio/soundset.mp3",
"audio/voiceset.mp3", "audio/divmain.mp3", "audio/divcenter.mp3",
"audio/divnav.mp3"];
var trackTitles = [
"About This Web App", "Web Development Technologies", "What's A Screen Reader",
"Services I Can Offer", "Stories, Poetry, Anecdotes", "Settings",
"Send Me Your Comments", "Display Settings", "Sound Settings",
"Voice Quality Settings", "div mainContent", "div center", "div navBar"];
var trackPtr = 0;
var getTrackNumber = function (trackName) {
for (i = 0; i < trackTitles.length; i++) {
if (trackName == trackTitles[i]) return i;
}
return -1;
};
var preload = function() {
if (trackPtr >= trackUrls.length)
{ trackPtr = 0; return; }
var trackId = "vt" + trackPtr + "";
var trackUrl = trackUrls[trackPtr];
trackPtr++;
var voiceTrack = soundManager.createSound ({stream: false,
id: trackId,
url: trackUrl,
autoLoad: false, autoPlay: false});
voiceTrack.load ({onload: function() { preload(); } });
};
var unload = function() {
for (i = 0; i < trackUrls.length; i++) {
var voiceTrack = soundManager.getSoundById ("vt" + i);
voiceTrack.unload();
voiceTrack.destruct();
}
};
interface = {
trackUrls: trackUrls,
trackTitles: trackTitles,
getTrackNumber: getTrackNumber,
preload: preload,
unload: unload
};
return interface;
})();
播放耳朵的功能: var playSound = function(trackName){ var trackID =&#34; st&#34; + Earcons.getTrackNumber(trackName)+&#34;&#34 ;; var soundTrack = soundManager.getSoundById(trackID); if(!soundTrack)返回; 如果(沉默)回归; if(soundManager.playState&gt; 0)soundManager.stopAll(); soundTrack.play(); };
用于播放语音录音: function playSpeech(录音){ var tn = Narrations.getTrackNumber(录音); if(tn == -1)返回false; var voiceId =&#34; vt&#34; + tn +&#34;&#34 ;; var voiceTrack = soundManager.getSoundById(voiceId); if(!voiceTrack)返回false; if(soundManager.playState&gt; 0)soundManager.stopAll(); soundManager.onready(function(){voiceTrack.play();}); 返回true; } //结束playSpeech
如果我制作播放函数方法[即] Earcons.playSound(),Narrations.playSpeech()? 您可以在以下位置体验我的网站的工作部分: www.innovascripter.com 提前感谢任何见解: - )
答案 0 :(得分:0)
IE 9具有硬件和资源确定的限制,可以一次加载多少个音频标签。我处理SoundJS,我们在documentation中包含有关此限制和其他限制的说明。
SoundJS有两个解决方法,最近实施的audio sprites以及强制闪回后备的旧解决方案。
希望有所帮助。