SORU
17 EKİM 2010, Pazar


HTML5 < node.js bir sunucudan akış ses;ses> etiketi

Ben deneme ile ikili akışları Node.js ve çok hayret aslında bir çalışma demo alarak bir Shoutcast stream kullanarak düğüm-radyo-akış ve itme içine bir HTML5 öğesi kullanarak yığın halinde kodlama. Ama sadece Safari'de çalışıyor!

Burada benim sunucu kodu:

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);
});

// Listen on a web port and respond with a chunked response header. 
var server = http.createServer(function(req, res){ 
    res.writeHead(200,{
        "Content-Type": "audio/mpeg",
        'Transfer-Encoding': 'chunked'
    });
    // Add the response to the clients array to receive streaming
    clients.push(res);
    console.log('Client connected; streaming'); 
});
server.listen("8000", "127.0.0.1");

console.log('Server running at http://127.0.0.1:8000'); 

Müvekkilim kod basitçe:

<audio controls src="http://localhost:8000/"></audio>

Bu Mac üzerinde Safari 5'te gayet iyi çalışıyor ama Chrome veya Firefox bir şey yapmak için görünmüyor. Herhangi bir fikir?

Olası adaylar kodlama sorunları veya kısmen uygulanan sadece HTML5 özellikleri de dahil olmak üzere...

CEVAP
20 EKİM 2010, ÇARŞAMBA


Here's a (slightly outdated) summary of the current status of HTML5 Audio and Icecast streams.

Gördüğünüz gibi, bir MP3 kaynağı sadece Safari (ve muhtemelen) 9 çalışıyor. Sunucu tarafı kodlama (bazıları ile . denemek gerekebilir ^em>ffmpegyamencoder) OGG Vorbis. Vorbis veri gönderiyordum zaman düzgün davranmaya Krom bulabildim eminim.

Firefox hala, belki de yığın halinde kodlama (tüm SHOUTcast sunucuları henüz Transfer-Encoding: chunked tanımlanmış etmediği HTTP/1.0 sürüm bir tepki ile yanıt) sevmediği bir çocuk vardı. OGG akışı ile Transfer-Encoding: identity yanıt Başlığı chunked devre dışı bırakmak için göndermeyi deneyin ve Firefox işe YARAYABİLİR. Bu test etmedim.

Nasıl gidiyor bana bildirin! Şerefe!

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Google Developers

    Google Devel

    23 AĞUSTOS 2007
  • Richard Laxa

    Richard Laxa

    30 AĞUSTOS 2012
  • Tahir Jahi

    Tahir Jahi

    6 Mart 2006