Deprecated: Assigning the return value of new by reference is deprecated in /home/nsdc/public_html/ventrix/code_folds/wp-settings.php on line 472

Deprecated: Assigning the return value of new by reference is deprecated in /home/nsdc/public_html/ventrix/code_folds/wp-settings.php on line 487

Deprecated: Assigning the return value of new by reference is deprecated in /home/nsdc/public_html/ventrix/code_folds/wp-settings.php on line 494

Deprecated: Assigning the return value of new by reference is deprecated in /home/nsdc/public_html/ventrix/code_folds/wp-settings.php on line 530

Deprecated: Assigning the return value of new by reference is deprecated in /home/nsdc/public_html/ventrix/code_folds/wp-includes/cache.php on line 103

Deprecated: Assigning the return value of new by reference is deprecated in /home/nsdc/public_html/ventrix/code_folds/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/nsdc/public_html/ventrix/code_folds/wp-includes/theme.php on line 623
Playing sound on Android Emulator - Ventrix’s Code Folds
Ventrix’s Code Folds

Playing sound on Android Emulator

by ventrix on Nov.14, 2008, under android

The code is very simple and works perfectly, but nothing cames out of my speakers.

package gr.androiddev.test;

    import java.io.IOException;

    import android.app.Activity;
    import android.media.MediaPlayer;
    import android.os.Bundle;

    public class SoundTest extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        System.out.println("aloha1");
        MediaPlayer mp = new MediaPlayer();
        try {
		mp.setDataSource("http://ventrix.nsdc.gr/stuff/TERMITES_SKONH.mp3");
	        mp.prepare();
	        mp.start();
	        System.out.println("aloha2");
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalStateException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
    }
}

To be able to hear sound on your Android Emulator on Linux, you must go to the “Run configuration, find the field named “Addition Emulator Command Line Options” and append the “-audio oss” option.

:,
1 comment for this entry:
  1. paul

    Dosn’t work for me, all I get is the error “Emulator] ko:’oss’ is not a valid audio output backend.”

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Archives

All entries, chronologically...