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

        final AssetFileDescriptor afd = context.getAssets().openFd(path);

        synchronized (mediaPlayer) {

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

            mediaPlayer.prepare();
            mediaPlayer.start();

            // Make the other synchronized calls to wait until the file
            // is
            // played
            Thread.sleep(mediaPlayer.getDuration());

            mediaPlayer.stop();
            mediaPlayer.reset();

        }

        afd.close();
    }
/**
     * Play the sound in path synchronized (only one sound at time)
     *
     * @param path file to play
     * @throws IOException
     */
Play the sound in path synchronized (only one sound at time)
@param path file to play
@throws IOException
Play the sound in path synchronized ( only one sound at time ) @param path file to play @throws IOException
public void playSynchronized(final String path) throws IOException, InterruptedException {
        final AssetFileDescriptor afd = context.getAssets().openFd(path);
        synchronized (mediaPlayer) {
            mediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
            mediaPlayer.prepare();
            mediaPlayer.start();
            Thread.sleep(mediaPlayer.getDuration());
            mediaPlayer.stop();
            mediaPlayer.reset();
        }
        afd.close();
    }
public void playSynchronized ( final String path ) throws IOException , InterruptedException { final AssetFileDescriptor afd = context . getAssets ( ) . openFd ( path ) ; synchronized ( mediaPlayer ) { mediaPlayer . setDataSource ( afd . getFileDescriptor ( ) , afd . getStartOffset ( ) , afd . getLength ( ) ) ; mediaPlayer . prepare ( ) ; mediaPlayer . start ( ) ; Thread . sleep ( mediaPlayer . getDuration ( ) ) ; mediaPlayer . stop ( ) ; mediaPlayer . reset ( ) ; } afd . close ( ) ; }
Play the sound in path synchronized (only one sound at time)
 @param path file to play
 @throws IOException
Play the sound in path synchronized ( only one sound at time ) @param path file to play @throws IOException
// Make the other synchronized calls to wait until the file // is // played