Sample code "MediaPlayerDemo_Audio.java", Application Stopped Unexpectedly. Help

by cwj » Wed, 11 Nov 2009 23:37:30 GMT


Sponsored Links
 an anyone help me with this? The code seems no problem when i run it,
but it stop unexpectedly in the emulator. I read some answer in the
forum, i has to look at the logcat to see about the exception handler.
But i do not really understand the logcat output. Please, developers,
help me!.
Below are the coding and my logcat output. Please...

package com.example.testing;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import com.example.testing.R;


public class testing extends Activity {

private static final String TAG = "MediaPlayerDemo";
private MediaPlayer mMediaPlayer;
private static final String MEDIA = "media";
private static final int LOCAL_AUDIO = 1;
private static final int STREAM_AUDIO = 2;
private static final int RESOURCES_AUDIO = 3;
private static final int LOCAL_VIDEO = 4;
private static final int STREAM_VIDEO = 5;
private String path;

private TextView tx;

@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
tx = new TextView(this);
setContentView(tx);
Bundle extras = getIntent().getExtras();
playAudio(extras.getInt(MEDIA));
}

private void playAudio(Integer media) {
try {
switch (media) {
case LOCAL_AUDIO:
/**
* TODO: Set the path variable to a local
audio
file path.
*/
path = "/res/raw/test1";
if (path == "") {
// Tell the user to provide an audio
file
URL.
Toast
.makeText(
testing.this,
"Please edit
MediaPlayer_Audio Activity, "
+ "and set the
path
variable to your audio file path."
+ " Your audio
file
must be stored on sdcard.",
Toast.LENGTH_LONG).show
();

}
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(path);
mMediaPlayer.prepare();
mMediaPlayer.start();
break;
case RESOURCES_AUDIO:
/**
* TODO: Upload a audio file to res/raw
folder
and provide
* its resid in MediaPlayer.create()
method.
*/
mMediaPlayer = MediaPlayer.create(this,
R.raw.test1);
mMediaPlayer.start();

}
tx.setText("Playing audio...");

} catch (Exception e) {
Log.e(TAG, "error: " + e.getMessage(), e);
}

}




Other Threads

1. Bluetooth RFCOMM connection dying immediately after .connect()

Any Bluetooth fellow devs willing to try and give some hints maybe? :)

The updated version of this issue is at:
 http://www.***.com/ 

Cheers,
Max






-- 

2. Perbedaan Android dan iPhone

Wkwkwkwkwkwkwk  lucu bro...

Btw os4 katanya sudah bisa flazh. Cuma gak tau juga, blom pernah test sih.

--rc
What droid doesn't, Ultimate Droid does!!...
japri: android.nyet....@anjroid.net




hihihihihihihiiiiiiiiiiiiiii

-- 
Jus* || owner white google_one ||
HTCClay's CSDI_REMIX_SuperCSDI_X10 v1 update 4/12/2010
~ send using pc jang krik krik krik ~
$ www.cash-flowing.com $

-- 
"Indonesian Android Community [id-android]"

3. Reading "Name (phonetic)" field on Eclair

4. can i run .exe in android and what is opengl o/p format?

5. Images Reused in a ListView

6. Permission

7. Android emulator -dns-server usage