0

I want to play an audio file from server. currently i am using html audio control, but its very slow. my requirement is to play as fast as possible, almost instantaneously. what would be the best way to achieve this? reference to source would be appreciated. Thanks in advance.

Vishal Maral
  • 1,279
  • 1
  • 10
  • 30
  • 1
    Check this http://stackoverflow.com/questions/13624048/what-is-the-best-way-to-stream-a-audio-file-to-website-users-listners – vijaykumar Jan 08 '14 at 06:06

1 Answers1

0

The HTML5 way is here.

<audio controls>
 <source src="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.mp4"
         type='audio/mp4'>
 <!-- The next two lines are only executed if the browser doesn't support MP4 files -->
 <source src="http://media.w3.org/2010/07/bunny/04-Death_Becomes_Fur.oga"
         type='audio/ogg; codecs=vorbis'>
 <!-- The next line will only be executed if the browser doesn't support the <audio> tag-->
 <p>Your user agent does not support the HTML5 Audio element.</p>
</audio>

You can also make use of javascript to get this done.

var aud = document.createElement("iframe");
    aud.setAttribute('src', "http://yoursite.com/youraudio.mp4"); // replace with actual file path
    aud.setAttribute('width', '1px');
    aud.setAttribute('height', '1px');
    aud.setAttribute('scrolling', 'no');
    aud.style.border = "0px";
    document.body.appendChild(aud);
Aby
  • 1,916
  • 1
  • 12
  • 18