src/main/java/org/intellimate/izou/sdk/frameworks/permanentSoundOutput/output/SimplePermanentSoundOutputPlugin.java
public Optional<CompletableFuture<Void>> startPlaying(Runnable function) {
        if (isCurrentlyPlayingSound)
            return Optional.empty();
        CompletableFuture<Void> voidCompletableFuture = submit((Runnable) () -> startedSound(isUsingJava))
                .thenRun(() -> {
                    try {
                        isCurrentlyPlayingSound = true;
                        function.run();
                    } finally {
                        submit((Runnable) this::endedSound);
                        isCurrentlyPlayingSound = false;
                    }
                });
        return Optional.of(voidCompletableFuture);
    }
public Optional<CompletableFuture<Void>> startPlaying(Runnable function) {
        if (isCurrentlyPlayingSound)
            return Optional.empty();
        CompletableFuture<Void> voidCompletableFuture = submit((Runnable) () -> startedSound(isUsingJava))
                .thenRun(() -> {
                    try {
                        isCurrentlyPlayingSound = true;
                        function.run();
                    } finally {
                        submit((Runnable) this::endedSound);
                        isCurrentlyPlayingSound = false;
                    }
                });
        return Optional.of(voidCompletableFuture);
    }
public Optional < CompletableFuture < Void > > startPlaying ( Runnable function ) { if ( isCurrentlyPlayingSound ) return Optional . empty ( ) ; CompletableFuture < Void > voidCompletableFuture = submit ( ( Runnable ) ( ) -> startedSound ( isUsingJava ) ) . thenRun ( ( ) -> { try { isCurrentlyPlayingSound = true ; function . run ( ) ; } finally { submit ( ( Runnable ) this :: endedSound ) ; isCurrentlyPlayingSound = false ; } } ) ; return Optional . of ( voidCompletableFuture ) ; }
use this method to start playing sound (only plays sound if it is not already playing)
@param function the function which plays the sound
@return the Future
use this method to start playing sound ( only plays sound if it is not already playing )