Ok here is my code:
i tried this with different 3gp and mp4 files ... this is really
driving me crazy ! i am currently downloading the source code hope i
can get the solution before i have to go through it
package org.esper.android.video;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.VideoView;
public class VideoMan extends Activity implements
SurfaceHolder.Callback,
MediaPlayer.OnBufferingUpdateListener,
MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener,
MediaPlayer.OnPreparedListener {
private static final String TAG = "VideoMAN";
final MediaPlayer p = new MediaPlayer();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
log("launched");
final VideoView vv = (VideoView) findViewById(R.id.video);
try {
vv.setEnabled(true);
vv.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent
event) {
if (event.getAction() ==
MotionEvent.ACTION_UP)
try {
p.setDataSource(VideoMan.this.getResources().openRawResourceFd(R.raw.my3gp)
.getFileDescriptor());
//
p.setDisplay(vv.getHolder()); uncommenting this line had no
effect
p.setOnBufferingUpdateListener(VideoMan.this);
p.setOnCompletionListener(VideoMan.this);
p.setOnErrorListener(VideoMan.this);
p.setOnPreparedListener(VideoMan.this);
log("clicked...");
p.prepareAsync();
vv.start();
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
});
vv.bringToFront();
vv.setClickable(true);
vv.getHolder().addCallback(this);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void surfaceChanged(SurfaceHolder holder, int format, int
width,
int height) {
log("surface changed");
}
public void surfaceCreated(SurfaceHolder holder) {
log("surface created");
}
public void surfaceDestroyed(SurfaceHolder holder) {
log("surface destroyed");
}
public void onBufferingUpdate(MediaPlayer mp, int percent) {
log("buffering: " + percent + "% done.");
}
public void onCompletion(MediaPlayer mp) {
log("complete");
}
public boolean onError(MediaPlayer mp, int what, int extra) {
log("error: (" + what + ":" + extra+")"); //always (-4,0)
p.reset();
return true;
}
public void onPrepared(MediaPlayer mp) {
log("prepared");
p.start();
}
private static void log(String msg) {
Log.w(TAG, msg);
}
}
On Oct 28, 11:22 am, "satheesh kumar" <[EMAIL PROTECTED]>
wrote:
> Post with your piece of codings fully.
>
> thanks,
> guna
>
> On Tue, Oct 28, 2008 at 10:55 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > yup I tried adding the call back (did nothing important in the call
> > back methods though, would like to know what should I do there?)
> > I also set the type of the holder to
> > getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); still
> > the same problem
> > my last try used the asynchronous version of the API which would
> > return with the error (-4,0) after trying to prepare too.
> > i looked for the meaning of the error codes every where but I couldn't
> > find anything :(
>
> > Thanks,
> > [EMAIL PROTECTED]
>
> > On Oct 28, 4:45 am, guna <[EMAIL PROTECTED]> wrote:
> >> Hi,
>
> >> Did you included addcallback method of the holder? Try setType of
> >> holder too...
>
> >> Thanks,
> >> Guna
>
> >> On Oct 26, 12:13 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> >> > Hi,
>
> >> > I've been trying to play videos obtained as a raw resource, here is
> >> > what I did
> >> > MediaPlayer mp = new MediaPlayer();
> >> > mp.setDisplay(getHolder());
> >> > mp.setDataSource(getContext().getResources().openRawResourceFd(R.raw.myvide
> >> > o).getFileDescriptor());
> >> > mp.setAudioStreamType(2);
> >> > mp.prepare();
> >> > mp.start();
> >> > ...
>
> >> > this is not the exact code (deleted my last trial after it became
> >> > horrendous)! but thats basically what I did
>
> >> > I always got this exception:
>
> >> > error: Prepare failed.: status=0xFFFFFFFC
> >> > java.io.IOException: Prepare failed.: status=0xFFFFFFFC
>
> >> > note that this worked perfectly with mp3s (without the setDisplay call
> >> > ofc)
>
> >> > I Googled the exception, found out that it was a common problem but
> >> > haven't found any clear solutions, the only lead i found was
> >> > a guy saying that it was a file format problem, however i tried this
> >> > with many different 3gp, mp4 files
>
> >> > was hoping anyone could help me with this issue... thanks in advance
> >> > and best regards to you all
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---