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