/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$( '#record' ) .bind( 'touchstart', function( e ) { if( media == null ) { $( this ).attr( 'src', 'assets/record.down.png' ); } else { $( this ).attr( 'src', 'assets/stop.down.png' ); } } ) .bind( 'touchend', function( e ) { $( this ).attr( 'src', 'assets/stop.up.png' ); if( media == null ) { media = new Media( reference, function() { // alert( 'Got media' ); }, function( err ) { // alert( 'Problems accessing media' ); } ); media.startRecord(); } else { media.stopRecord(); media.release(); media = null; $( this ).attr( 'src', 'assets/record.up.png' ); } } );