1 package com
.owncloud
.android
.ui
.activity
;
3 import android
.app
.Activity
;
4 import android
.media
.MediaPlayer
;
5 import android
.media
.MediaPlayer
.OnCompletionListener
;
6 import android
.media
.MediaPlayer
.OnPreparedListener
;
7 import android
.os
.Bundle
;
8 import android
.view
.MotionEvent
;
9 import android
.widget
.VideoView
;
11 import com
.owncloud
.android
.R
;
13 public class VideoActivity
extends Activity
implements OnCompletionListener
, OnPreparedListener
{
15 public static final String EXTRA_PATH
= "PATH";
17 private VideoView mVideoPlayer
;
18 private String mPathToFile
;
20 /** Called when the activity is first created. */
22 public void onCreate(Bundle savedInstanceState
) {
23 super.onCreate(savedInstanceState
);
24 setContentView(R
.layout
.video_layout
);
26 mPathToFile
= getIntent().getExtras().getString(EXTRA_PATH
);
28 mVideoPlayer
= (VideoView
) findViewById(R
.id
.videoPlayer
);
29 mVideoPlayer
.setOnPreparedListener(this);
30 mVideoPlayer
.setOnCompletionListener(this);
31 mVideoPlayer
.setKeepScreenOn(true
);
32 mVideoPlayer
.setVideoPath(mPathToFile
);
35 /** This callback will be invoked when the file is ready to play */
37 public void onPrepared(MediaPlayer vp
) {
41 /** This callback will be invoked when the file is finished playing */
43 public void onCompletion(MediaPlayer mp
) {
47 /** Use screen touches to toggle the video between playing and paused. */
49 public boolean onTouchEvent (MotionEvent ev
){
50 if(ev
.getAction() == MotionEvent
.ACTION_DOWN
){
51 if(mVideoPlayer
.isPlaying()){