Record Audio with PhoneGap


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $( '#record' )
  2. .bind( 'touchstart', function( e ) {
  3. if( media == null )
  4. {
  5. $( this ).attr( 'src', 'assets/record.down.png' );
  6. } else {
  7. $( this ).attr( 'src', 'assets/stop.down.png' );
  8. }
  9. } )
  10. .bind( 'touchend', function( e ) {
  11. $( this ).attr( 'src', 'assets/stop.up.png' );
  12.  
  13. if( media == null )
  14. {
  15. media = new Media( reference, function() {
  16. // alert( 'Got media' );
  17. }, function( err ) {
  18. // alert( 'Problems accessing media' );
  19. } );
  20.  
  21. media.startRecord();
  22. } else {
  23. media.stopRecord();
  24. media.release();
  25. media = null;
  26.  
  27. $( this ).attr( 'src', 'assets/record.up.png' );
  28. }
  29. } );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.