Just the two media elements (plus their associated API) that you’ve seen so far in this chapter provide many more options for media than developers have ever had in the past, but this is only the beginning. Plans are already underway to provide far more granular control and extensibility to playing media natively in the browser, with advanced audio capabilities and peer-to-peer data connection acting as the vanguard.
For people who want to go beyond simple playback of audio files, an emerging standard called the Web Audio API aims to provide high-level processing and synthesizing of audio in web applications. The Web Audio API is based on the concept of Audio Routes, a common tool in sound engineering (but way over my head!).
Like the canvas element, the Web Audio API uses a context, which is constructed with the AudioContext() method:
var context = new AudioContext();
Going further on this subject is far beyond the scope of this book, and my own capabilities, but if you’re interested in advanced audio processing, I suggest you read the article “Web Audio API – Getting Started” on the CreativeJS site (see Appendix J).
Back in Chapter 6, we looked at the getUserMedia() method. There, I mentioned that it’s part of the wider WebRTC project. WebRTC is an exciting proposal aimed at allowing all web-connected devices to communicate with each other, using audio, video, and data in real-time and using a single standardized protocol.
At the moment, many tools do this, but all of them require plug-ins or extra software, and very few actually use the same protocol and are able to talk to each other, creating a series of “walled gardens” with no way to get data from one to the other. WebRTC aims to remove those walls.
WebRTC has three key APIs: MediaStream gives access to data streams such as from a camera or microphone (using getUserMedia()), PeerConnection allows voice or video communication between devices, and DataChannel is for generic data communication. As I write this, Chrome and Firefox have experimental support for all three, and Opera supports MediaStream through getUserMedia().
As with so much of the media landscape on the Web, however, even the current WebRTC specification has an uncertain future. An alternative specification, CU-RTC-Web, has been proposed by Microsoft based on their experience of owning the Skype platform. Going into detail on either of the two specs is very probably a fool’s errand, so I’ll leave it at this: Real-time communication will come to the Web, even if the precise shape it takes is not currently known.