<!DOCTYPE HTML><HTML><Head> <MetaCharSet= "Utf-8"> <Metaname= "Viewport"content= "initial-scale=1.0, maximum-scale=1.0, User-scalable=no" /> <title>Recording Playback</title> <Scripttype= "Text/javascript"src=".. /js/jquery.js "></Script> <styletype= "Text/css">Body{width:100%;padding:0;margin:0; }input{padding:. 2rem;margin:. 5rem Auto 0 Auto;font-size:. 5rem;Border-radius:. 5rem;Display:Block;width:5rem;Color:Red;background: White; } </style></Head><Body> <inputtype= "button"value= "Back to Home"ID= "Returnindex"> <inputtype= "button"value= "Click to record"ID= "Recorder" /> <inputtype= "button"value= "Stop Recording"ID= "STOPR"> <inputtype= "button"value= "Play recording"ID= "Player" /> <inputtype= "button"value= "Stop playing"ID= "StopP" /></Body></HTML><Scripttype= "Text/javascript"> /** Page layout rem Reset statement*/ $('HTML'). CSS ('font-size', $ (window). Width ()/( ten); /** * Phone-side page initialization event, all actions must be written in this event * Otherwise error may occur: Plus is not defind*/Document.addeventlistener ('Plusready', function(){ /** * Get the Recording object Plus.audio.getRecorder () * Define the Save address of the recording file*/ varRecorder=Plus.audio.getRecorder (); varFILEURL= "'; /** * Start recording recorder.record (option, success callback, failed callback) * End Recording recorder.stop () * option: {* F Ilename: File Save folder * Samplerate: Sample rate * Format: Record saved file suffix name *}*/ $('#Recorder'). On ('Touchstart', function() {event.preventdefault (); varoption={filename:"_doc/audio/", Samplerate:'8000', Format:'Amr'} recorder.record ({},function(e) {fileUrl=e; }, function() {Console.log ("Recording failed"); }); }); $('#StopR'). On ('Touchstart', function() {recorder.stop (); }); /** * Get playback Recording Object Plus.audio.createPlayer (file address) * Start playing Player.play (Success callback, failed callback) * Stop playback Player.sto P () * >>>>>>>>>>>>>>>>>> Player Basic Method >>>>>> ;>>>>>>>>>>> * Play (Success callback, fail callback): Start playing audio * pause (): Pause audio Playback * resum E (): Resume playing audio * STOP (): Stop playing audio * Seekto (how many seconds): Jump to the specified position play audio * getduration (): Get the total length of the audio stream * GetPos Ition (): Gets the current playback position of the audio stream * Setroute (): Set audio output line*/ $('#Player'). On ('Touchstart', function() {event.preventdefault (); //get audio Playback objects varplayer=Plus.audio.createPlayer (FILEURL); Player.play (function(e) {console.log (e); Console.log (FILEURL); }, function() {Console.log ("Playback failed"); }); $('#StopP'). On ('Touchstart', function() {player.stop (); }); }); /** * Back to Home*/ $('#ReturnIndex'). On ('Touchstart', function() {location.href= 'index.html'; }) });</Script>
html5+ phone recording and playback recording