views:

1764

answers:

2

Hi,

I am using Videoview to playback mp4 file from local machine using android emulator. I hear the audio, but the screen is blank and no video is seen. Android SDK 2.0.1

Does anyone have an idea what is missing here:

package com.hello;

import android.app.Activity;

import android.os.Bundle;

import android.widget.MediaController;

import android.widget.VideoView;

public class HelloAndroid extends Activity {

VideoView vv;

@Override

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);
    vv = (VideoView) findViewById(R.id.VideoView01);

    MediaController nc = new MediaController(this); 
    vv.setMediaController(nc); 


    vv.setVideoPath("/sdcard/yu.mp4");
   vv.requestFocus();
   vv.start();
}


public void onPause ()
{
 vv.stopPlayback();

}

}

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

<VideoView android:id="@+id/VideoView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></VideoView>
</LinearLayout>
A: 

Is it possible that your video itself is flawed? (yu.mp4?)

Your layout file is fine cuz I tried it on my own.

Actually I was working on video player too. I had 5 mp4 files, and only 3 played, 1 played only with audio, another one didn't play.

I downloaded other video players and used them and got the same result, so your code is probably fine, you should try out other mp4 files that you confirmed works on other video players.

If it's still your code that you think has a problem, then I'll send you the full source code of mine and compare them to yourself.

Hope this solves ur problem.

Hiro
+2  A: 

I am facing a same issue with 2.0.1.But my question is how come the same video link works well with 2.0 and lower versions...?

Update

There is a bug filed regarding this issue...

http://code.google.com/p/android/issues/detail?id=5696#makechanges

Rahul
Thanks Rahul !!
lava