Skip to content

Instantly share code, notes, and snippets.

@bendenoz
Last active July 24, 2024 13:35
Show Gist options
  • Select an option

  • Save bendenoz/d9832f24caa6c826f1c4 to your computer and use it in GitHub Desktop.

Select an option

Save bendenoz/d9832f24caa6c826f1c4 to your computer and use it in GitHub Desktop.

Revisions

  1. bendenoz revised this gist Oct 12, 2014. 1 changed file with 53 additions and 0 deletions.
    53 changes: 53 additions & 0 deletions Beep.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    import android.media.MediaPlayer;
    import android.media.AudioManager;
    import android.util.Log;

    import java.io.IOException;

    public class Beep {

    /**
    * Command-line entry point.
    *
    * @param args The command-line arguments
    */
    public static void main(String[] args) {
    (new Beep()).run(args);
    }


    private void run(String[] a) {

    MediaPlayer mp = new MediaPlayer();

    try {
    mp.setDataSource(a[0]);
    mp.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);
    mp.setVolume(1f,1f);
    mp.prepare();
    mp.start();
    }
    catch (IOException e) {
    Log.w("Beep", "IOException", e);
    }

    System.out.print("Playing " + mp.getDuration() + "ms");
    int i = 0;
    while(mp.isPlaying() && i < 20) {
    System.out.print(".");
    i++;
    try {
    Thread.sleep(1000);
    }
    catch(InterruptedException e) {
    Log.w("Beep", "IOException", e);
    }
    }
    System.out.println();
    mp.stop();
    mp.release();
    System.out.println("Stopped.");

    }

    }
  2. bendenoz created this gist Oct 12, 2014.
    2 changes: 2 additions & 0 deletions play_beep.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    export CLASSPATH=./Beep.dex
    app_process /system/bin Beep /system/media/audio/ringtones/Beep-beep.ogg