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