Friday, July 10, 2015

Android Video Recording Apps (Source You Tube,Mobile Application Tutorials)

The code for  Layout file activity_main file.xml  is as follows 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"    android:paddingRight="@dimen/activity_horizontal_margin"    android:paddingTop="@dimen/activity_vertical_margin"    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Play"        android:id="@+id/playButton"        android:layout_alignParentBottom="true"        android:layout_alignParentLeft="true"        android:layout_alignParentStart="true" />

    <Button        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Record"        android:id="@+id/recordButton"        android:layout_alignParentBottom="true"        android:layout_alignRight="@+id/videoView"        android:layout_alignEnd="@+id/videoView" />

    <VideoView        android:layout_width="wrap_content"        android:layout_height="420dp"        android:id="@+id/videoView"        android:layout_alignParentTop="true"        android:layout_alignParentRight="true"        android:layout_alignParentEnd="true" />
</RelativeLayout>


The Code for MainActivity.java is as follows

package com.example.saroj.videorecorder;

import android.app.Activity;
import android.content.Intent;
import android.provider.MediaStore;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.VideoView;

import java.net.URI;
import android.net.Uri;


public class MainActivity extends Activity {

    private Button mRecordView, mPlayView;
    private VideoView mVideoView;
    private int ACTIVITY_START_CAMERA_APP=0;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mRecordView=(Button) findViewById(R.id.recordButton);
        mPlayView=(Button) findViewById(R.id.playButton);
        mVideoView=(VideoView) findViewById(R.id.videoView);



        mRecordView.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View v) {
                Intent CallVideoAppInent=new Intent();
                CallVideoAppInent.setAction(MediaStore.ACTION_VIDEO_CAPTURE);


                startActivityForResult(CallVideoAppInent,ACTIVITY_START_CAMERA_APP);

            }
        });

        mPlayView.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View v) {
                mVideoView.start();

            }
        });
    }

    protected  void onActivityResult(int requestCode,int resultCode,Intent data)
    {
        if(requestCode==ACTIVITY_START_CAMERA_APP && resultCode==RESULT_OK)
        {
             Uri videoUri=data.getData();
             mVideoView.setVideoURI(videoUri);
        }
    }
    @Override    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will        // automatically handle clicks on the Home/Up button, so long        // as you specify a parent activity in AndroidManifest.xml.        int id = item.getItemId();

        //noinspection SimplifiableIfStatement        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}


1 comment:

  1. Your post is wonderful and this video recording app is superb! I am now using Total Recall call recorder which has the high quality sound recording and this app is now offering half off price offer too. Check this app!

    ReplyDelete