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. Bluetooth SIM access profile support for Android

Hi,

I am planning to implement Bluetooth SIM access profile server role
for Bluez.
I was suggested by the open source community to have core
implementation as part of oFono.

If possible, I would like my implementation to be useful for Android
also.

Please let me know your comments.

Regards
Suraj

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: 

2. Patch IDM exclusif 5.xx

this is the last patch for internet download manager for all versions
5.xxx
http://www.megaupload.com/?d=47Q44OGP
/**/

-- 

3. problem with showing my live wallpaper

4. workshop about developing Android applications

5. How to enable dithering in SurfaceView?

6. Can't find maps.jar in sdk - add-on subdirectory missing?

7. Nobody can stop Androids MediaRecorder...