Play Video via "VideoView" from source file though the emulator

by Valentino XM » Sat, 12 Dec 2009 16:52:23 GMT


Sponsored Links
 Hello fellow Androids!

I have been attempting, in vain, to play video via "VideoView" using
the code below and several variations there of.
Of course i am a new!.. but waiting for any assistance to come from
"beginners" has proven to be an exaperational pause in my effort to
learn something new. We were all newbees at one point, so what do you
say;   little help!? All I would like to do at this point is to play
video from source file. I am using Eclipse, Android 2.1

TIA

Cheers


package info.shouraig.com;

import android.R.raw;
import android.app.Activity;
import android.content.res.AssetFileDescriptor;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class XSO4 extends Activity {
        private static final String TAG = "XSO4";
        VideoView videoXSO4;

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

        VideoView = (VideoView)findViewById(R.id.videoXSO4);



        AssetFileDescriptor afd = getResources().openRawResourceFd
(R.raw);

        // Create a new media player and set the listeners

        MediaPlayer.setDataSource(R.raw.XSCycling.mp4);
        MediaPlayer.setDisplay(Holder);
        MediaPlayer.prepare();

        mMediaPlayer.setOnBufferingUpdateListener(this);
        mMediaPlayer.setOnCompletionListener(this);
        mMediaPlayer.setOnPreparedListener(this);
        mMediaPlayer.setAudioStreamType



       setDataSource(afd.getFileDescriptor(),
afd.getStartOffset(), afd.getLength());

VideoView video = (VideoView)findViewById(R.id.videoXSO4);



Uri uri = Uri.parse("android.resource://info.shouraig.com/" +
R.raw.toString());
video.setVideoURI(uri);
video.setMediaController(new MediaController(this));
video.requestFocus();
video.setOnCompletionListener((OnCompletionListener) this);
video.start();


    }
}

--



Other Threads

1. virtual keyboard problem

Hi All,

I am new in android, i am having problem in Virtual Keyboard.

I am having text field. if user click the text field then virtual
keyboard need to appear. how to do this.

please help me....

Thanks
C.Rajesh

-- 

2. Web Browser die when request cached geolocation position.

Interesting log "de{*filter*}d committing suicide to free the zombie! "

You can report this as an issue. Seems to be a memory problem to be.

Thanks and Regards,
Kumar Bibek




-- 

3. Odin error Log

4. Top 3 sites for discovering Android apps

5. Fastest and most reliable Location provider

6. CM 5.0.6 test1 for Nexus One

7. World war error