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
)
Here's my code:
Using java Syntax Highlighting
- package com.guidokessels.Video;
- import android.app.Activity;
- import android.graphics.PixelFormat;
- import android.net.Uri;
- import android.os.Bundle;
- import android.view.Window;
- import android.widget.MediaController;
- import android.widget.VideoView;
- /**
- * By Guido Kessels for driezesnul, 2008
- *
- * Tested with .3gp and .mp4 files
- * Place files in /data/files/
- */
- public class GuidoVideo extends Activity {
- VideoView videoHolder;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- // Hide title bar.
- getWindow().requestFeature(Window.FEATURE_NO_TITLE);
- // Set window format.
- getWindow().setFormat(PixelFormat.TRANSLUCENT);
- setContentView(R.layout.main);
- videoHolder = (VideoView) findViewById(R.id.videoHolder);
- // Create video play-back.
- videoHolder.setMediaController(new MediaController(this));
- // Hard-coded this path for the moment being.
- videoHolder.setVideoURI(Uri.parse("file:///data/data/kungpow.3gp"));
- videoHolder.requestFocus();
- videoHolder.start();
- }
- }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
And the XML:
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="#000">
- <VideoView
- android:id="@+id/videoHolder"
- android:layout_gravity="center"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="#000" />
- </LinearLayout>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4
Thanks in advance for your help!
Regards,
Guido

