FunnySounds-LiveView/app/src/main/java/com/makingiants/liveview/funny/model/SoundPlayer.java
public void play(final String path) throws IOException, InterruptedException {

        if (mediaPlayer.isPlaying()) {
            mediaPlayer.reset();
        } else {
            final AssetFileDescriptor afd = context.getAssets().openFd(path);

            mediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());

            mediaPlayer.prepareAsync();
            // mediaPlayer.start();
            afd.close();
        }

    }
/**
     * Play the sound in path and if there are any sound playing it will stop
     * and play the new one if there are no sounds playing now, else stop the sound
     *
     * @param path file to play
     * @throws IOException
     */
Play the sound in path and if there are any sound playing it will stop
and play the new one if there are no sounds playing now, else stop the sound

@param path file to play
@throws IOException
Play the sound in path and if there are any sound playing it will stop and play the new one if there are no sounds playing now else stop the sound @param path file to play @throws IOException
public void play(final String path) throws IOException, InterruptedException {
        if (mediaPlayer.isPlaying()) {
            mediaPlayer.reset();
        } else {
            final AssetFileDescriptor afd = context.getAssets().openFd(path);
            mediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
            mediaPlayer.prepareAsync();
            afd.close();
        }
    }
public void play ( final String path ) throws IOException , InterruptedException { if ( mediaPlayer . isPlaying ( ) ) { mediaPlayer . reset ( ) ; } else { final AssetFileDescriptor afd = context . getAssets ( ) . openFd ( path ) ; mediaPlayer . setDataSource ( afd . getFileDescriptor ( ) , afd . getStartOffset ( ) , afd . getLength ( ) ) ; mediaPlayer . prepareAsync ( ) ; afd . close ( ) ; } }
Play the sound in path and if there are any sound playing it will stop
 and play the new one if there are no sounds playing now, else stop the sound
Play the sound in path and if there are any sound playing it will stop and play the new one if there are no sounds playing now else stop the sound
// mediaPlayer.start();