Android Open Source - video Main Activity






From Project

Back to project page video.

License

The source code is released under:

Apache License

If you think the Android project video listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package edu.cs4730.videocapture;
/*from w  ww .  ja  v a  2s .  c o  m*/
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;

public class MainActivity extends Activity {
  int REQUEST_VIDEO_CAPTURE = 1;
  VideoView mVideoView;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    
    mVideoView = (VideoView)findViewById(R.id.videoView1);
    mVideoView.setMediaController(new MediaController(this));
    
    //setup the button take a video.
    Button btn1 = (Button)findViewById(R.id.button1);
        btn1.setOnClickListener( new View.OnClickListener(){
      @Override
      public void onClick(View v) {
        //create an intent to have the default video record take a video.
          Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
          if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
              startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
          }

      }
        });
    
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (requestCode == REQUEST_VIDEO_CAPTURE && resultCode == RESULT_OK) {
          Uri videoUri = data.getData();
          Log.v("return", "Video saved to: " + data.getData());

          mVideoView.setVideoURI(videoUri);
          mVideoView.start();
          
      }
  }
}




Java Source Code List

edu.cs4730.PicCapture.PicCapture.java
edu.cs4730.PicCapture.PicCapture.java
edu.cs4730.VideoCap2.CaptureSurface.java
edu.cs4730.VideoCap2.VideoCapture.java
edu.cs4730.VideoCap.CaptureSurface.java
edu.cs4730.VideoCap.VideoCapture.java
edu.cs4730.VideoPlay.videoPlay.java
edu.cs4730.VideoPlay.videoPlay.java
edu.cs4730.piccapture2.CameraPreview.java
edu.cs4730.piccapture2.CameraPreview.java
edu.cs4730.piccapture2.MainActivity.java
edu.cs4730.piccapture2.MainActivity.java
edu.cs4730.piccapture3.MainActivity.java
edu.cs4730.piccapture3.MainActivity.java
edu.cs4730.videocapture3.MainActivity.java
edu.cs4730.videocapture3.MainActivity.java
edu.cs4730.videocapture.MainActivity.java
edu.cs4730.videocapture.MainActivity.java