android-video -, sound hören, aber kein video

Ich habe versucht, mehrere unterschiedliche Beispiele, aber ich kann nicht jedes video zu zeigen. Ich höre Ton, aber kein video. Ich dachte, vielleicht hatte ich nur eine falsche video-format, so dass ich heruntergeladen eine fiat Werbung in 3gp-format und noch keine Freude. Ich bin mit dem Eclipse-Java-EE mit android sdk und meine app Ziele der 1.5-sdk (Api Level 3), ohne google api. Könnte jemand bitte posten Sie einen link zu einem video bekannt, in spielen android oder auf den Punkt zu meinem problem mit dem code. Ich habe versucht alles was ich denken konnte .. mit/ohne Vorbereitung .. verschiedene layouts etc.

Hier ist mein onCreate in der Aktivität

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

this.setContentView(R.layout.video_test);
    SurfaceView v = (SurfaceView) findViewById(R.id.surface_video); 
    SurfaceHolder holder = v.getHolder(); 
 //Set the transparency 
    //getWindow().setFormat(PixelFormat.UNKNOWN); 


    //Set a size for the video screen 
    //holder.addCallback(this); 
    holder.setFixedSize(400,300); 


    MediaPlayer mp = MediaPlayer.create(this, R.raw.fiat); 
    mp.setDisplay(holder);
    //mp.setAudioStreamType(2); 
    try {
        //mp.prepare();
        mp.start();
    } catch (IllegalStateException e) {
        //TODO Auto-generated catch block
        e.printStackTrace();
    }

Ihr ist das layout in video_test.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" 
> 
<SurfaceView android:id="@+id/surface_video" 
android:layout_width="250px" 
android:layout_height="250px"> 
</SurfaceView> 
<LinearLayout 
android:orientation="horizontal" 
android:layout_height="wrap_content" 
android:layout_width="fill_parent" 
android:padding="10dip" 
> 
</LinearLayout> 
</LinearLayout> 

> Blockquote

  • Ich hatte dieses problem auch mit einer VideoView aber wenn ich den Fokus, nachdem das video startet, dann funktioniert es.
InformationsquelleAutor slytron | 2010-02-02
Schreibe einen Kommentar