0% found this document useful (0 votes)
50 views2 pages

Application: Video Player: Design

The document describes a video player application created in Android. It includes two sections - the design and code for the activity_main.xml layout file which contains a VideoView widget, and the MainActivity.java class file which sets up the VideoView to play a video from resources on creation of the activity. It initializes the VideoView, sets a media controller, sets the video URI and starts playback of the video.

Uploaded by

Kaveri zanzane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views2 pages

Application: Video Player: Design

The document describes a video player application created in Android. It includes two sections - the design and code for the activity_main.xml layout file which contains a VideoView widget, and the MainActivity.java class file which sets up the VideoView to play a video from resources on creation of the activity. It initializes the VideoView, sets a media controller, sets the video URI and starts playback of the video.

Uploaded by

Kaveri zanzane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Application : Video Player

1. Activity_main.xml

 Design :

 Code :
<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">

<VideoView
android:layout_width="wrap_content"
android:layout_height="300dp"
android:id="@+id/videoView"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true" />

</RelativeLayout>

BOTTON OPERATIONS 1
2. MainActivity.java
package com.example.d00admin.videoplayer;

import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;

import android.net.Uri;

public class MainActivity extends AppCompatActivity {


VideoView v1;
MediaController mc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Uri UriPath=
Uri.parse("android.resource://com.example.d00admin.videoplayer/" +
R.drawable.cnt);
v1 = (VideoView)findViewById(R.id.videoView);
mc = new MediaController(MainActivity.this);
v1.setMediaController(mc);
v1.setVideoURI(UriPath);
v1.requestFocus();
v1.start();

@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);
}
}

BOTTON OPERATIONS 2

You might also like