www.pudn.com > videoplayer.rar > Amplayer.java, change:2011-03-10,size:2827b


package com.amlogic.amplayer;

import android.app.Activity;
import android.os.Bundle;

import android.content.Intent;
import android.util.Log;

import android.net.Uri;

public class Amplayer extends Activity
{
    private static final String TAG = "Amplayer";

    static final int FILE_PICKER_REQUEST_CODE = 0;
    static final int PLAY_VIDEO_REQUEST_CODE = 1;
    static final int WEB_VIDEO_REQUEST_CODE = 2;

    /** implemented by libavjni.so */
    public static native int native_startcmd(String filename);
    public static native int native_sendcmd(String cmd);
    //private native int native_reqstate();
    public static native int native_setglobalalpha(int alpha);
    public static native int native_getosdbpp();
    public static native int native_enablecolorkey(short key_rgb565);
    public static native int native_disablecolorkey();

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

	Uri  luri = getIntent().getData();
	if (luri != null)
	{
		String filename = luri.toString();
		Intent playintent = new Intent(Amplayer.this, PlayVideo.class);
                playintent.putExtra("PATH", filename);
                Amplayer.this.startActivityForResult(playintent, WEB_VIDEO_REQUEST_CODE);
	}
	else
	{
        	Intent pickerIntent = new Intent(Amplayer.this, FileList.class);
        	Amplayer.this.startActivityForResult(pickerIntent, FILE_PICKER_REQUEST_CODE);
	}
    }

    /** load our native library */
    static {;
        System.loadLibrary("avjni");
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent intent) 
    {
        if (requestCode == FILE_PICKER_REQUEST_CODE)
        {
            if (resultCode == RESULT_OK && 
                intent != null && intent.hasExtra("PATH"))
            {
                Bundle hpath = intent.getExtras();
                String filename = (String)hpath.get("PATH");
                if(filename != null)
                {
                    Log.d(TAG,"file chosen:" + filename);
                    Intent playintent = new Intent(Amplayer.this, PlayVideo.class);
                    playintent.putExtra("PATH", filename);
                    Amplayer.this.startActivityForResult(playintent, PLAY_VIDEO_REQUEST_CODE);
                }
                else
                {
                    finish();
                }
            }
            else {
                finish();
            }
        }
        else if (requestCode == PLAY_VIDEO_REQUEST_CODE) 
        {
            Intent pickerIntent = new Intent(Amplayer.this, FileList.class);
            Amplayer.this.startActivityForResult(pickerIntent, FILE_PICKER_REQUEST_CODE);
        }
        else if (requestCode == WEB_VIDEO_REQUEST_CODE) 
        {
            finish();
        }
    }
}