VideoView - Audio works, but no video

All your problems with Audio, Video and Images.

VideoView - Audio works, but no video

Postby Nuladion » Sun Jan 11, 2009 1:54 pm

Hello everyone,
I'm trying to play video using a VideoView. I'm able to get the sound to work, but I don't see any video. It used to work before, but for some reason I don't know it stopped showing anything.

- Tried with .mp4 and .3gp files (a .mp4 file used to work)
- The videos are < 1MB (as I heard there's an emulator bug that prevents files > 1MB to work)
- Files are in /data/files/ and /data/data/

Also, is there any way to always show the playback controls? At the moment they only show up when you click the video (or rather, where the video should be :P)

Here's my code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.guidokessels.Video;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6.  
  7. import android.graphics.PixelFormat;
  8.  
  9. import android.net.Uri;
  10.  
  11. import android.os.Bundle;
  12.  
  13. import android.view.Window;
  14.  
  15. import android.widget.MediaController;
  16.  
  17. import android.widget.VideoView;
  18.  
  19.  
  20.  
  21. /**
  22.  
  23.  * By Guido Kessels for driezesnul, 2008
  24.  
  25.  *
  26.  
  27.  *  Tested with .3gp and .mp4 files
  28.  
  29.  *  Place files in /data/files/
  30.  
  31.  */
  32.  
  33.  
  34.  
  35. public class GuidoVideo extends Activity {
  36.  
  37.         VideoView videoHolder;
  38.  
  39.        
  40.  
  41.     @Override
  42.  
  43.     public void onCreate(Bundle savedInstanceState) {
  44.  
  45.         super.onCreate(savedInstanceState);
  46.  
  47.        
  48.  
  49.         // Hide title bar.
  50.  
  51.         getWindow().requestFeature(Window.FEATURE_NO_TITLE);
  52.  
  53.        
  54.  
  55.         // Set window format.
  56.  
  57.         getWindow().setFormat(PixelFormat.TRANSLUCENT);
  58.  
  59.  
  60.  
  61.         setContentView(R.layout.main);
  62.  
  63.  
  64.  
  65.         videoHolder = (VideoView) findViewById(R.id.videoHolder);
  66.  
  67.        
  68.  
  69.         // Create video play-back.
  70.  
  71.         videoHolder.setMediaController(new MediaController(this));
  72.  
  73.        
  74.  
  75.         // Hard-coded this path for the moment being.
  76.  
  77.         videoHolder.setVideoURI(Uri.parse("file:///data/data/kungpow.3gp"));
  78.  
  79.         videoHolder.requestFocus();
  80.  
  81.         videoHolder.start();
  82.  
  83.        
  84.  
  85.     }
  86.  
  87. }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


And the XML:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:layout_width="fill_parent"
  6.  
  7.    android:layout_height="fill_parent"
  8.  
  9.    android:background="#000">
  10.  
  11.    
  12.  
  13.     <VideoView
  14.  
  15.         android:id="@+id/videoHolder"
  16.  
  17.                 android:layout_gravity="center"
  18.  
  19.                 android:layout_width="fill_parent"
  20.  
  21.                 android:layout_height="fill_parent"
  22.  
  23.        android:background="#000" />
  24.  
  25. </LinearLayout>
  26.  
  27.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Thanks in advance for your help!

Regards,
Guido
Nuladion
Developer
Developer
 
Posts: 26
Joined: Mon Jun 23, 2008 12:23 pm
Location: Maastricht, Netherlands

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 14 guests