Another MediaPlayer problem- Sound but no video

All your problems with Audio, Video and Images.

Another MediaPlayer problem- Sound but no video

Postby roguetreasure » Mon Feb 01, 2010 3:26 pm

I know this problem has been posted many times and I have tried several different examples but I cannot get any video to show. I hear sound but no video. I thought maybe I just had a incorrect video format so I downloaded a fiat commercial in 3gp format and still no joy. I am using the eclipse JEE with android sdk and my app targets the 1.5 sdk (3) without google api. Could someone please post a link to a video known to play in android or point out my problem with the code. I have tried all I could think of .. with/without prepare .. different layouts etc.

Here is my on create
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.     @Override
  3.  
  4.     public void onCreate(Bundle savedInstanceState)
  5.  
  6.     {
  7.  
  8.         super.onCreate(savedInstanceState);
  9.  
  10.        
  11.  
  12.            
  13.  
  14.             this.setContentView(R.layout.video_test);
  15.  
  16.         SurfaceView v = (SurfaceView) findViewById(R.id.surface_video);
  17.  
  18.         SurfaceHolder holder = v.getHolder();
  19.  
  20.      // Set the transparency
  21.  
  22.         getWindow().setFormat(PixelFormat.UNKNOWN);
  23.  
  24.  
  25.  
  26.  
  27.  
  28.         // Set a size for the video screen
  29.  
  30.         holder.addCallback(this);
  31.  
  32.         holder.setFixedSize(400,300);
  33.  
  34.  
  35.  
  36.  
  37.  
  38.         MediaPlayer mp = MediaPlayer.create(this, R.raw.fiat);
  39.  
  40.         mp.setDisplay(holder);
  41.  
  42.         try {
  43.  
  44.                         mp.prepare();
  45.  
  46.                 mp.start();
  47.  
  48.                 } catch (IllegalStateException e) {
  49.  
  50.                         // TODO Auto-generated catch block
  51.  
  52.                         e.printStackTrace();
  53.  
  54.                 } catch (IOException e) {
  55.  
  56.                         // TODO Auto-generated catch block
  57.  
  58.                         e.printStackTrace();
  59.  
  60.                 }
  61.  
  62. }
  63.  
  64.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


here is my test layout
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6. android:orientation="vertical"
  7.  
  8. android:layout_width="fill_parent"
  9.  
  10. android:layout_height="fill_parent"
  11.  
  12. >
  13.  
  14. <SurfaceView android:id="@+id/surface_video"
  15.  
  16. android:layout_width="250px"
  17.  
  18. android:layout_height="250px">
  19.  
  20. </SurfaceView>
  21.  
  22. <LinearLayout
  23.  
  24. android:orientation="horizontal"
  25.  
  26. android:layout_height="wrap_content"
  27.  
  28. android:layout_width="fill_parent"
  29.  
  30. android:padding="10dip"
  31.  
  32. >
  33.  
  34. </LinearLayout>
  35.  
  36. </LinearLayout>
  37.  
  38.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
roguetreasure
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Feb 01, 2010 3:12 pm
Location: Oklahoma City, OK

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Exabot [Bot] and 7 guests