video viewing problem

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

Sponsored Links

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

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.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) {
mPreview = (SurfaceView) findViewById(;
holder = mPreview.getHolder();
extras = getIntent().getExtras();


private void playVideo(Integer Media) {
try {

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

* TODO: Set path variable to progressive
streamable mp4 or
* 3gpp format URL. Http protocol should be used.
* Mediaplayer can only play "progressive
* 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. I thought you could Build in Flash, and Port to Android with a click?

I am a little confused here. I thought we could create an application
in say, Flash CS5 and port it over to the Android with a simple click
or short command. Is this possible? I have been looking around, and
see that there may be a way to do it with AIR, but haven't found
anything concrete.

Any help would be greatly appreciated.



2. How to update one of views(setText, setImage) in item already added on ListView

Hi, all

* I have a ListView that using my layout document, to simplest, it
goes  like this ...
<!-- itemraw.xml -->
<LinearLayout id="ll_parent" orient="vertical">
  <TextView id="tv_1" text="hello_1"/>
  <TextView id="tv_2" text="hello_2" />
  <TextView id="tv_3" text="hello_3" />
</ LinearLayout>

* then I populate the items to the ListView...
ListView lv = (ListView)findViewById(;
ArrayAdapter<String> aa = new ArrayAdapter<String>(this,
R.layout.itemraw,, m_MyStringArray);

* OK, the item is really populated like I think. Now I'd like to do
setText() to one of the TextView of one of ListView item...
LinearLayout ll = (LinearLayout)aa.getView(0, null, null);
TextView tv = (TextView)ll.findViewById(;

* Just like the program code, i set 3rd TextView with text "HAHAHAHA"
of first item, but nothing happened.

* My question is, an item has been already added to a ListView, can I
still update the UI?


3. What changed in Gingerbread as far as the app widgets?

4. display data from database in proper order

5. Problem in Browser App

6. help: keluar dari FTM Mode gmn? urgent

7. [WTS]Samsung Galaxy S dan Galaxy Tab Case/Screen Guard/Dock Charger+Sync etc