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. AlertDialog.Buillder

I need to setItems from a generated ArrayList.

Eclipse gives me an error that the setItems must be a int source. I
have made it work with a stored Array from R.array.xxxx. How do I
change my arraylist to a format accepted by the AlertDialog.Builder
setItems command?

This code works with a pre-defined array in arrays.xml ('test'):

                new AlertDialog.Builder(this)

                .setTitle(R.string.new_defn)
                .setItems(R.array.test,
                new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialoginterface,
                        int i) {
                                showDefn(i);
                                }
                        })


                .show();
                }

But I want to replace 'R.array.test' with 'results' - a code generated
arraylist

--~--~---------~--~----~------------~-------~--~----~

2. Creating Context Menus

Hi,

I was wondering if there was a way to create a context menu (or any
menu for that matter) in response to something like a button click
versus hooking into the phone's menu press or a push and hold event? I
need to be able to create a context menu and show that menu when the
user clicks on a button in the activity.

Thanks In Advance,
Dan

--~--~---------~--~----~------------~-------~--~----~

3. About gnu-ld version

4. TextView Widget - OnResume

5. Touch events lost during garbage collection, need kernel-level buffering

6. ANR after service has been stopped.

7. Running Dalvikvm on x86