video viewing problem

by manoj » Thu, 05 Mar 2009 21:49:56 GMT


Sponsored Links
 i,

I have written the following code which plays the media file(.mp4).
Its working fine but,

I have two problems:
1. While trying to play a video file for the first time, video is not
getting played but the audio is playing(audible). Now if i try to play
the same video again in the application or if i restart the phone
(switch off and on ) i can see both video playing as well as the
audio.

2. I can play video if it is h.264 format. but if the video is of
encoding mpeg4, the app is unable to play the video.

can any one please suggest me to solve these two problems.



public class MediaPlayerDemo_Video extends Activity implements
MediaPlayer.OnBufferingUpdateListener,
MediaPlayer.OnCompletionListener,
MediaPlayer.OnPreparedListener, SurfaceHolder.Callback {

private static final String TAG = "MediaPlayerDemo";
private int mVideoWidth;
private int mVideoHeight;
private MediaPlayer mMediaPlayer;
private SurfaceView mPreview;
private SurfaceHolder holder;
private String path;
private Bundle extras;
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;

/**
*
* Called when the activity is first created.
*/
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.mediaplayer_2);
mPreview = (SurfaceView) findViewById(R.id.surface);
holder = mPreview.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
extras = getIntent().getExtras();

}

private void playVideo(Integer Media) {
try {

switch (Media) {
case LOCAL_VIDEO:
/*
* TODO: Set the path variable to a local media
file path.
*/
path = "";
if (path == "") {
// Tell the user to provide a media file URL.
Toast
.makeText(
MediaPlayerDemo_Video.this,
"Please edit
MediaPlayerDemo_Video Activity, "
+ "and set the path
variable to your media file path."
+ " Your media file
must be stored on sdcard.",
Toast.LENGTH_LONG).show();

}
break;
case STREAM_VIDEO:
/*
* TODO: Set path variable to progressive
streamable mp4 or
* 3gpp format URL. Http protocol should be used.
* Mediaplayer can only play "progressive
streamable
* contents" which basically means: 1. the movie
atom has to
* precede all the media data atoms. 2. The clip
has to be
* reasonably interleaved.
*
*/

path = extras.getString("MediaFileName&quo



Other Threads

1. Want a background Service to show Toasts on Device Screen

Hi

I have a background service component which is reacting to changes in
network connectivity.
I would like to alert the user that a a connectivity change event has
occurred by popping
up a Toast View on the device screen.

Is this possible ? Can it be done even though a Service component does
not have a
UI associated with it ?

Thanks for any pointers

Graeme

--~--~---------~--~----~------------~-------~--~----~

2. Problem compiling Master and/or Cupcake, before and after the merge, targeting HTC Dream

I've seen that happen on (I think) recent cupcake.

Right now my priority is to get master to build "out of the box" (i.e.
without local changes), first for the emulator and then for dream. I
can't promise that I'll have time to look at cupcake-on-dream.

JBQ

On Fri, Mar 20, 2009 at 2:38 PM, abqm...@googlemail.com





-- 
Jean-Baptiste M. "JBQ" Queru
Android Engineer, Google.

Questions sent directly to me that have no reason for being private
will likely get ignored or forwarded to a public forum with no further
warning.

--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

3. What are people's thoughts on flood of themes on market?

4. Scheduling a repeating task and being notified

5. How to achieve iPhone like transition effect between screens?

6. Why can not edit /init.rc on adp1 with firmware 1.1?

7. where is the link to buy adp1?