Hello,
I have many problems trying to get a simple mp3 to play in MediaPlayer on 
my 2.3.5 Samsung T679 Exhibit 4G. I am pretty sure that I just don't 
undersand Java well enough to figure out how to place the listener code in 
my program.  I started with the simple Hello World and ended up with the 
following.  The code works great if I let the lines commented out go and 
delete the setOnPreparedListener.  
The symptom is the sound will play for a very short time (500ms) then 
stop.  With my thread.sleep it plays just fine;  but they are tuned to one 
specific sound and will not work in general.
 
Can someone show me how the listeners need to be coded including the 
subtlties of any import or declarations?  I have found many examples that 
just don't work.
Is the Oreilly Android Cookbook worth buying?
 
I am an old engineer that used computers to solve problems in from 1971-now 
in many languages and OS but am finding the Android Java a bit strange.
 
this snip is called from: onCreate(Bundle savedInstanceState)
 
    public void playsound(){
        try {
         path = "/sdcard/media/Snd.mp3";
         mp = new MediaPlayer();
         mp.reset();
         mp.setDataSource(path);
         mp.prepare();
//         Thread.sleep(250, 0);
//         mp.start();
//         Thread.sleep(1500, 0);
        } catch (Exception e) {
            Log.e(TAG, "error: " + e.getMessage(), e);
        }
        mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 
            @Override 
            public void onPrepared(MediaPlayer mp) { 
             mp.start();
            } 
        });
    }
 
Thank you,
Steve

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to