gpt4 book ai didi

javascript - Javascript 中的嵌套函数

转载 作者:行者123 更新时间:2023-11-30 07:57:54 24 4
gpt4 key购买 nike

我想要一个这样的 JavaScript block ,但这似乎无效。

MYAPP.audioRecording = {

var navigator = window.navigator;
var Context = window.AudioContext || window.webkitAudioContext;
var context = new Context();

navigator.getUserMedia = (
navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia
);

function startRecorder() {
//start recording code
}

function stopRecorder() {
//recorder stop
}

}

然后我想从另一个代码块调用 startRecorder() 和 stopRecorder() 函数。

MYAPP.recordingManager = {

MYAPP.audioRecording.startRecorder();
MYAPP.audioRecording.stopRecorder();

}

非常感谢您提供的任何帮助。谢谢!

最佳答案

MYAPP.audioRecording = (function() {

var navigator = window.navigator;
var Context = window.AudioContext || window.webkitAudioContext;
var context = new Context();

navigator.getUserMedia = (
navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia
);

return {
startRecorder: function() {
//start recording code
},
stopRecorder: function() {
//recorder stop
}
}

})();

关于javascript - Javascript 中的嵌套函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35507153/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com