/* * File: videoPlayer.java * This file is part of Tico, an application to create and perform * interactive communication boards to be used by people with * severe motor disabilities. * * Author: Eduardo Ferrer * * Date: Nov, 2011 * * Company: Dept. of Computer Sciences and Systems Engineering, Universidad de Zaragoza, Spain * * * License: * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package android.TICO; import android.app.Activity; //import android.content.Intent; import android.content.res.Configuration; import android.media.MediaPlayer; import android.os.Bundle; import android.view.MotionEvent; import android.view.ViewGroup.LayoutParams; import android.widget.RelativeLayout; import android.widget.VideoView; /** * The class that defines the activity for video playing in TICO projects */ public class videoPlayer extends Activity{ @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); } @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); String ruta; Bundle extras = getIntent().getExtras(); if(extras !=null) { ruta = extras.getString("ruta"); VideoView mVideoView=new VideoView(this); mVideoView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); RelativeLayout rl=new RelativeLayout(this); rl.addView(mVideoView); ((android.widget.RelativeLayout.LayoutParams) mVideoView.getLayoutParams()).addRule(RelativeLayout.CENTER_VERTICAL); ((android.widget.RelativeLayout.LayoutParams) mVideoView.getLayoutParams()).addRule(RelativeLayout.CENTER_HORIZONTAL); setContentView(rl); //setContentView(mVideoView); mVideoView.setVideoPath(ruta); mVideoView.requestFocus(); mVideoView.start(); mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { // TODO Auto-generated method stub finish(); } }); } } //al pulsar cerramos el video /** * When the screen is touched in the videoPlayer activity we finish this activity returning to the main TICO activity */ @Override public boolean onTouchEvent (MotionEvent ev){ if(ev.getAction() == MotionEvent.ACTION_DOWN){ finish(); } return true; } }