AIR is rocking in the web world, if you guys! Search for Adobe AIR you will get tons of web snippets and sample applications which are developed using this awesome enough technology.
As Adobe experts says Adobe AIR, formerly code-named Apollo, is a cross-operating system runtime that allows developers to use their existing web development skills to build and deploy rich Internet applications to the desktop. Using AIR we can develop desktop applications using HTML, JavaScript, XML, AJAX, Flash, Flex etc.,
In this tutorial, you guys! Can learn how we can play an audio file, the audio file might be of .mp3 / .wmv or any other compatible audio files.
The application has got one button, on clicking of the button the particular audio file will be played, I have taken .mp3 file as an example. Below is the code for the index.html file, this file has got simple JavaScript code only few lines of code are required.
Copy the below code and paste it in between tags:
<script>
function init()
{
document.getElementById("playButt").addEventListener("click", playFile);
}
function playFile()
{
var audiofile = air.File.applicationResourceDirectory.resolve("rockup.mp3");
var mp3File = new air.Sound(new air.URLRequest(audiofile.nativePath));
mp3File.play();
}
</script>Call the init() function on page load, so onload of the page call the init() function like –
<body onLoad="init()">
So its done, just we need to place a button, create a button like –
<input id="playButt" type="button" value="Play >" />
So we have done with the code, below is the full snippet code to copy:
<html>
<head>
<title>Playing a Sound</title>
<script>
function init ()
{
document.getElementById( "playButt" ).addEventListener( "click", playFile );
}
function playFile()
{
var audiofile = air.File.applicationResourceDirectory.resolve( "rockup.mp3" );
var mp3File = new air.Sound( new air.URLRequest( audiofile.nativePath ) );
mp3File.play();
}
</script>
</head>
<body onLoad="init()">
<input id="playButt" type="button" value="Play >" />
</body>
</html>So Guys! What are you waiting for ROCK UP THE WEB WORLD WITH ADOBE AIR.
Related Entries...
John Resig, has explained us a better and interesting way of Method Overloading. Here he has discusse ...
You guys might know the importance of XML, XML (Extensible Markup Language) is a flexible markup lang ...
Making a preloader in flash is very simple. By using ProgressBar and Image Loader components, we can ...
Hey folks, hmmm... How can I start.... !!! Yeah, well folks... below is very simple snippet code for ...
As we all know AJAX is rocking the Web World all around, just I had a thought to developer a simple A ...
Below is the code which is written in JavaScript, we can use this script for bookmarking the particul ...
I am back again with some helpful snippet code. Here using JavaScript we can pro actively sort date f ...
Hi Guys, I would like to share a JavaScript snippet code which will remove special characters (like ! ...
Hi Dev Folks, this topic explains you about different patterns used to match character combinations i ...
The Sprite class is new in ActionScript 3.0, This class is a basic display list building block, which ...























One Response
[...] Adobe AIR Application to play a sound file » This Summary is from an article posted at Developer Snippets on Friday, August 31, 2007 AIR [...]