package rnsoundplayer;

import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;

import java.io.IOException;
import javax.annotation.Nullable;

import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.Arguments;


public class RNSoundPlayerModule extends ReactContextBaseJavaModule {

  private final ReactApplicationContext reactContext;
  private MediaPlayer mediaPlayer;

  public RNSoundPlayerModule(ReactApplicationContext reactContext) {
    super(reactContext);
    this.reactContext = reactContext;
  }

  @Override
  public String getName() {
    return "RNSoundPlayer";
  }

  @ReactMethod
  public void playSoundFile(String name, String type) throws IOException {
    if (this.mediaPlayer == null) {
      int soundResID = getReactApplicationContext().getResources().getIdentifier(name, "raw", getReactApplicationContext().getPackageName());
      this.mediaPlayer = MediaPlayer.create(getCurrentActivity(), soundResID);
      this.mediaPlayer.setOnCompletionListener(
        new OnCompletionListener() {
          @Override
          public void onCompletion(MediaPlayer arg0) {
            WritableMap params = Arguments.createMap();
            params.putBoolean("success", true);
            sendEvent(getReactApplicationContext(), "FinishedPlaying", params);
          }
      });
    } else {
      Uri uri = Uri.parse("android.resource://" + getReactApplicationContext().getPackageName() + "/raw/" + name);
      this.mediaPlayer.reset();
      this.mediaPlayer.setDataSource(getCurrentActivity(), uri);
      this.mediaPlayer.prepare();
    }
    this.mediaPlayer.start();
  }

  @ReactMethod
  public void playUrl(String url) throws IOException {
    if (this.mediaPlayer == null) {
      Uri uri = Uri.parse(url);
      this.mediaPlayer = MediaPlayer.create(getCurrentActivity(), uri);
      this.mediaPlayer.setOnCompletionListener(
        new OnCompletionListener() {
          @Override
          public void onCompletion(MediaPlayer arg0) {
            WritableMap params = Arguments.createMap();
            params.putBoolean("success", true);
            sendEvent(getReactApplicationContext(), "FinishedPlaying", params);
          }
      });
    } else {
      Uri uri = Uri.parse(url);
      this.mediaPlayer.reset();
      this.mediaPlayer.setDataSource(getCurrentActivity(), uri);
      this.mediaPlayer.prepare();
    }
    this.mediaPlayer.start();
  }

  @ReactMethod
  public void pause() throws IllegalStateException {
    if (this.mediaPlayer != null) {
      this.mediaPlayer.pause();
    }
  }

  @ReactMethod
  public void resume() throws IllegalStateException {
    if (this.mediaPlayer != null) {
      this.mediaPlayer.start();
    }
  }

  @ReactMethod
  public void stop() throws IllegalStateException {
    if (this.mediaPlayer != null){
      this.mediaPlayer.stop();
    }
  }

  private void sendEvent(ReactApplicationContext reactContext,
                       String eventName,
                       @Nullable WritableMap params) {
    reactContext
        .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
        .emit(eventName, params);
  }

}

@@ -604,16 +604,58 @@
 uments;%0A
+import com.facebook.react.bridge.Promise;%0A
 %0A%0Apublic
@@ -3264,16 +3264,311 @@
  %7D%0A  %7D%0A%0A
+  @ReactMethod%0A  public void getInfo(%0A      Promise promise) %7B%0A    WritableMap map = Arguments.createMap();%0A%0A    map.putDouble(%22currentTime%22, this.mediaPlayer.getCurrentPosition() / 1000.0);%0A    map.putDouble(%22duration%22, this.mediaPlayer.getDuration() / 1000.0);%0A%0A    promise.resolve(map);%0A  %7D%0A%0A
   privat

Add the implemation of `getInfo` on Android