English 中文(简体)
Android Videoview video not seen
原标题:

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>
最佳回答

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

问题回答

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.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签