JavaScript Tutorials
JavaScriptJavaScript Audio Interface (JAI)
JavaScript has always been about data manipulation and interaction. Most of the online applications are used to deal with data but they are often for videos and texts entered by users. Audio is rarely developed with the help of Ajax because Flash based interface that can easily stream audio is extensively used.
But that doesn't mean JavaScript on audio is completely ignored. Small libraries have been created to help users launch audio interface in the client side with the help of JavaScript. Called JAI or JavaScript Audio Interface, this small library will allow developers to create audio interface in the client side using pure JavaScript.
Components on Basic JAI-Based Playlist
At first glance, JAI based interface looks like a regular Flash-based playlist. But the library was able to combine smart functions in order to load the application in the client side.
Graphics - loaded with element which can be interpreted by any browser.
Playlist - information is loaded with the aid of CSS.
Audio - the audio is loaded as OGG format which should be easily read by most browsers.
These three components allow developers to create a playlist which can be highly interactive for users in the client side.
HTML5 and Fallback
The power of loading audio in real time to the client side is based on the evolution of HTML5. As the coding practice is slowly adapting to the increasing demand not only in text and video, interpretation of audio is already implemented.
But even with the improvement of audio support in HTML5, the library provides a very smart fallback to avoid loading problems. HTML5 audio tag is loaded from regular HTML. In case HTML5 cannot be loaded in the client side, the code will revert to HTML so that it can load in various browsers.
Requirements on Developer's End
Even though JAI is pure JavaScript, there are some requirements on the developers end to ensure proper loading. The server has to ensure the accurate MIME type is rendered. Ignoring these requirements will mean the audio will load but users will not hear anything on their end. Developers can change the httpd.conf on the server if they are allowed accessed. Another option is to allow OGG to be loaded in the application. This can be done by adding the following line in the .htcaccess file:
AddType application/ogg ogg
The biggest challenge to this type of implementation is actually based on HTML5 but that is already dealt with by the library because the HTML can still be used. The OGG file is expected to load easily in major browsers and this limitation can be easily dealt with simple configuration on the server.
JAI is still on its early stages but it can work well in various environments. It relies on the fact that it has used W3C-complying scripts for cross-browser implementation. As long as the server is powerful enough to stream the audio with stable connection, there should be no problem loading this library.
Download the library and read additional instructions here:
http://hyper-metrix.com/open-source/jai/
Sponsored Links
