小编Sco*_*son的帖子

将音频从Node.js服务器流式传输到HTML5 <audio>标签

我一直在尝试使用Node.js中的二进制流,令我惊讶的是,实际上有一个工作演示,即使用节点无线电流获取Shoutcast流并使用分块编码将其推送到HTML5元素.但它只适用于Safari!

这是我的服务器代码:

var radio = require("radio-stream");
var http = require('http');
var url = "http://67.205.85.183:7714";
var stream = radio.createReadStream(url);

var clients = [];

stream.on("connect", function() {
  console.error("Radio Stream connected!");
  console.error(stream.headers);
});


// When a chunk of data is received on the stream, push it to all connected clients
stream.on("data", function (chunk) {
    if (clients.length > 0){
        for (client in clients){
            clients[client].write(chunk);
        };
    }
});

// When a 'metadata' event happens, usually a new song is starting.
stream.on("metadata", function(title) {
  console.error(title);
}); …
Run Code Online (Sandbox Code Playgroud)

streaming shoutcast audio-streaming node.js html5-audio

51
推荐指数
1
解决办法
3万
查看次数

如何在 Mac OS X 上运行 PostgreSQL 的两个副本?

我需要对同时具有本地和远程数据库服务器的系统运行集成测试;我希望在我的开发 Mac 上有两个位于不同端口的 PostgreSQL 服务器。我通常使用 Postgres.app - 可以以某种方式配置它来运行两个实例吗?

postgresql postgresapp

4
推荐指数
1
解决办法
3281
查看次数