【发布时间】:2015-11-16 08:24:35
【问题描述】:
我从之前询问的关于将 mp3 文件添加到我的 javascript 代码的问题中得到了建议,并提出了这个建议。
var howrutday = new Audio('file:///C:/This_PC/Music/Science_Fair_Robot/howrutday.mp3');
var name = function (robot) {
if ('Hi.' + 'Hi!' + 'Hello.' + 'Hello!' + 'Greetings.' + 'Greetings!') {
console.log("How are you doing today " + name + "?");
howrutday.play();
} else if ('Good morning.' + 'Good morning!') {
console.log("How are you doing today " + name + "?");
} else if ('Good afternoon.' + 'Good afternoon!') {
console.log("And to you also, what a lovely day.");
} else if ('Good evening.' + 'Good evening!') {
console.log("How was your day?");
} else if ('Good night.' + 'Good night!') {
console.log("Rest well " + name + ". I hope to see you tomorrow.");
} else {
console.log("Try saying that again but make sure you are using proper grammar like applying punctuation and capitalization.");
}
我不确定是我的语法有问题,还是我的音频文件没有对程序可见。也有人建议网站运行我的代码,因为我使用的可能不播放音频。虽然只是一个理论。
【问题讨论】:
-
你还有很长的路要走,因为我假设你不太了解 HTML、JS 或 CSS。抱歉,如果我错了,但我正在尝试建立和评估您的知识。你的问题需要一个很大比例的答案。您是否有使用其他语言(如 C、C++ 或 Java)的经验?
-
不,我不是要他那样做,请看我的意思。
标签: javascript audio