我使用以下代码从 Node.js 的套接字解码音频块
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var context = new AudioContext();
var delayTime = 0;
var init = 0;
var audioStack = [];
var nextTime = 0;
client.on('stream', function(stream, meta){
stream.on('data', function(data) {
context.decodeAudioData(data, function(buffer) {
audioStack.push(buffer);
if ((init!=0) || (audioStack.length > 10)) { // make sure we put at least 10 chunks in the buffer before starting
init++;
scheduleBuffers();
}
}, function(err) {
console.log("err(decodeAudioData): "+err);
});
});
});
function scheduleBuffers() {
while ( audioStack.length) {
var buffer …Run Code Online (Sandbox Code Playgroud) 使用 NodeJS 中的以下代码,我可以播放服务器提供的 webm 文件:
app.get('/video', function(req, res){
res.writeHead(200,{
'Connection': 'close',
'Cache-Control': 'private',
'Content-Type': 'video/webm'
});
console.log('Http client connected: Streaming!');
var readStream = fs.createReadStream('./small.webm');
readStream.pipe(res);
});
Run Code Online (Sandbox Code Playgroud)
现在我想直接从 getUserMedia() API 获取 WebM。所以我在 Socket.IO 中使用了 MediaRecorder:
// Client
var mediaRecorder = new MediaRecorder(stream, options);
// ...
mediaRecorder.ondataavailable = function(e) {
console.log('Data', e.data);
chunks.push(e.data);
socket.emit('data', e.data);
}
// Server
app.get('/video', function(req, res){
res.writeHead(200,{
"Content-Type": "video/webm",
'Transfer-Encoding': 'chunked'
});
// Add the response to the clients array to receive streaming
clients.push(res);
console.log('Http client connected: …Run Code Online (Sandbox Code Playgroud) 我正在使用以下查询
https://www.instagram.com/graphql/query/?query_id=17851374694183129&id={acountId}&first=1000&after={cursor}
来获取用户关注者。我需要的信息是followed_by_count每个用户都可以使用的索引https://www.instagram.com/{username}?__a=1
结果中是否query_id包含followed_by_count?