小编Val*_*dir的帖子

Web Audio Api:通过套接字从 Nodejs 服务器播放数据块的正确方法

我使用以下代码从 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)

sockets audio node.js web-audio-api

8
推荐指数
1
解决办法
2759
查看次数

从 MediaRecorder 发送块到服务器并在浏览器中播放

使用 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)

node.js webm getusermedia

7
推荐指数
1
解决办法
6278
查看次数

如何使用 Instagram graphql?

我正在使用以下查询 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

instagram graphql

5
推荐指数
1
解决办法
2万
查看次数