AMR audio playback for web development

Source: Internet
Author: User

MP3 format Play Everybody knows that AMR format is strange, at least I haven't done it before

AMR format files play out the sound quality than MP3, mainly used in mobile phone ringtones and mobile phone recording, the purpose is to give mobile users to save traffic. Most of the mainstream audio and video players support AMR format, and now it's a bit of a problem to implement Web playback (also consider compatibility). Baidu, debugging some, finally heard the sound.

I use the play plugin is QuickTime, do not know can be Wikipedia, the following is the method:
1, download QuickTime software and install, address http://www.apple.com/quicktime/download/index.html
2. Add the following code to the Web page
<//embed controller= "true" bgcolor= "Black" target= "Myself" type= "Video/quicktime" pluginspage= "/http Www.apple.com/quicktime/download/index.html "align=" Middle "height=" "width=" >

3, the effect, no picture no truth, progress bar will move OH

[Reprint] web development of AMR audio playback (background to determine the length of audio)

IE, FireFox, chrome test pass.
Also attached Java code to get AMR audio playback length in the background

Public static long getamrduration (File file)  throws IOException {           long duration = -1;           int[] packedSize = { 12, 13, 15,  17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };           randomaccessfile randomaccessfile =  null;          try {               randomAccessFile = new  Randomaccessfile (file,  "RW");               long length = file.length ();//Length of file                int p os = 6;//Set initial position                int framecount = 0;//Initial Frame Number                int packedPos = -1;                byte[] datas = new byte[1];//Initial data Values                while  (pos <= length )  {                   randomaccessfile.seek (POS);                   if  (Randomaccessfile.read (datas, 0, 1)  != 1)  {                       duration = length > 0 ?  ((length - 6)  / 650)  : 0;                        break;                   }                   packedPos =  (datas[0] >> 3)  & 0x0F;                    pos += packedsize[packedpos] + 1;                   frameCount++;               }               duration  += framecount * 20;//Frame Number *20          }  finally {              if  ( Randomaccessfile != null)  {                   randomaccessfile.close ();               }          }           return duration;       }

The method calls itself, and the pro-test is available.


AMR audio playback for web development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.