--- /dev/null
+package com.owncloud.android.ui.activity;
+
+import android.app.Activity;
+import android.media.MediaPlayer;
+import android.media.MediaPlayer.OnCompletionListener;
+import android.media.MediaPlayer.OnPreparedListener;
+import android.os.Bundle;
+import android.view.MotionEvent;
+import android.widget.VideoView;
+
+import com.owncloud.android.R;
+
+public class VideoActivity extends Activity implements OnCompletionListener, OnPreparedListener {
+
+ public static final String EXTRA_PATH = "PATH";
+
+ private VideoView mVideoPlayer;
+ private String mPathToFile;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.video_layout);
+
+ mPathToFile = getIntent().getExtras().getString(EXTRA_PATH);
+
+ mVideoPlayer = (VideoView) findViewById(R.id.videoPlayer);
+ mVideoPlayer.setOnPreparedListener(this);
+ mVideoPlayer.setOnCompletionListener(this);
+ mVideoPlayer.setKeepScreenOn(true);
+ mVideoPlayer.setVideoPath(mPathToFile);
+ }
+
+ /** This callback will be invoked when the file is ready to play */
+ @Override
+ public void onPrepared(MediaPlayer vp) {
+ mVideoPlayer.start();
+ }
+
+ /** This callback will be invoked when the file is finished playing */
+ @Override
+ public void onCompletion(MediaPlayer mp) {
+ this.finish();
+ }
+
+ /** Use screen touches to toggle the video between playing and paused. */
+ @Override
+ public boolean onTouchEvent (MotionEvent ev){
+ if(ev.getAction() == MotionEvent.ACTION_DOWN){
+ if(mVideoPlayer.isPlaying()){
+ mVideoPlayer.pause();
+ } else {
+ mVideoPlayer.start();
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
import android.widget.MediaController;\r
import android.widget.TextView;\r
import android.widget.Toast;\r
+import android.widget.VideoView;\r
\r
import com.actionbarsherlock.app.SherlockFragment;\r
import com.owncloud.android.AccountUtils;\r
import com.owncloud.android.ui.activity.FileDetailActivity;\r
import com.owncloud.android.ui.activity.FileDisplayActivity;\r
import com.owncloud.android.ui.activity.TransferServiceGetter;\r
+import com.owncloud.android.ui.activity.VideoActivity;\r
import com.owncloud.android.ui.dialog.EditNameDialog;\r
import com.owncloud.android.ui.dialog.EditNameDialog.EditNameDialogListener;\r
import com.owncloud.android.utils.OwnCloudVersion;\r
private Handler mHandler;\r
private RemoteOperation mLastRemoteOperation;\r
private DialogFragment mCurrentDialog;\r
+ \r
private MediaServiceBinder mMediaServiceBinder = null;\r
private MediaController mMediaController = null;\r
private MediaServiceConnection mMediaServiceConnection = null;\r
\r
@Override\r
public boolean onTouch(View v, MotionEvent event) {\r
- if (v == mPreview && event.getAction() == MotionEvent.ACTION_DOWN && mFile != null && mFile.isDown() && mFile.isAudio()) {\r
- if (!mMediaServiceBinder.isPlaying(mFile)) {\r
- Log.d(TAG, "starting playback of " + mFile.getStoragePath());\r
- mMediaServiceBinder.start(mAccount, mFile);\r
- // this is a patch; need to synchronize this with the onPrepared() coming from MediaPlayer in the MediaService\r
- mMediaController.postDelayed(new Runnable() {\r
- @Override\r
- public void run() {\r
- mMediaController.show(0);\r
- }\r
- } , 300);\r
- } else {\r
- mMediaController.show(0);\r
+ if (v == mPreview && event.getAction() == MotionEvent.ACTION_DOWN && mFile != null && mFile.isDown()) {\r
+ if (mFile.isAudio()) {\r
+ if (!mMediaServiceBinder.isPlaying(mFile)) {\r
+ Log.d(TAG, "starting playback of " + mFile.getStoragePath());\r
+ mMediaServiceBinder.start(mAccount, mFile);\r
+ // this is a patch; need to synchronize this with the onPrepared() coming from MediaPlayer in the MediaService\r
+ mMediaController.postDelayed(new Runnable() {\r
+ @Override\r
+ public void run() {\r
+ mMediaController.show(0);\r
+ }\r
+ } , 300);\r
+ } else {\r
+ mMediaController.show(0);\r
+ }\r
+ \r
+ } else if (mFile.isVideo()) {\r
+ startVideoActivity();\r
}\r
}\r
return false;\r
}\r
\r
\r
+ private void startVideoActivity() {\r
+ Intent i = new Intent(getActivity(), VideoActivity.class);\r
+ i.putExtra(VideoActivity.EXTRA_PATH, mFile.getStoragePath());\r
+ startActivity(i);\r
+ \r
+ // TODO THROW AN ACTIVTIY JUST FOR PREVIEW VIDEO\r
+ /*\r
+ if (mMediaController == null) {\r
+ mMediaController = new MediaController(getActivity());\r
+ mMediaController.setAnchorView(mVideoPreview);\r
+ //mMediaController.setEnabled(true);\r
+ }\r
+ //mMediaController.setMediaPlayer(mMediaServiceBinder);\r
+ if (!mVideoPreviewIsLoaded) {\r
+ mVideoPreviewIsLoaded = true;\r
+ mMediaController.setMediaPlayer(mVideoPreview);\r
+ mVideoPreview.setMediaController(mMediaController);\r
+ mVideoPreview.setVideoPath(mFile.getStoragePath());\r
+ mVideoPreview.start();\r
+ //mMediaController.show(0);\r
+ } else {\r
+ mMediaController.show(0);\r
+ }*/\r
+ }\r
+\r
+\r
private void bindMediaService() {\r
Log.d(TAG, "Binding to MediaService...");\r
if (mMediaServiceConnection == null) {\r