开发者

C++ stream server for HTML5 Audio

Is it possible to have the src of an HTML5 Audio tag be a C++ program, and for the C++ program to stream audio to the audio element? For example, let's say I have an HTML5 Audio element trying to get audio from a local program like so:

<audio src='file://(path to program)'>

If it is possible, which libraries should I use? I just want to try it l开发者_Python百科ocally for now, so file:// is what I want.

EDIT: Setting the source as file:// won't work, so how can I tell it to get audio from the specific C++ program?


I am not sure about the C++ side of the question, but trying to embed a would-be program via file: will not work, as the browser would simply read the binary file foo.exe instead of calling it and reading in the standard output (or whatever).

Instead, for testing purposes, you would probably like to run the server locally on your machine, referring to it via localhost.


Certainly if your C++ program was stand-alone, you could write/include a mini-web server to service only audio requests that come in and then execute whatever code you wanted to in C++ to return the data.

Otherwise you could write a C++ plugin/module to an existing web server like IIS or apache and configure the web server to direct traffic for a specific url to your C++ functions to return the data. This might be a little more complicated but alot more powerful by allowing you to focus more on your audio code than worrying about handling HTTP protocol and TCP connections.

In either case then your C++ code would be referenced the same as any webserver. "<audio src='http://localhost:port/etc'>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜