Return to Snippet

Revision: 52896
at November 4, 2011 07:30 by parkerkrhoyt


Initial Code
$( '#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;
  }
} );

Initial URL


Initial Description


Initial Title
Play an Audio File with PhoneGap

Initial Tags
phone, file, mobile

Initial Language
JavaScript