Hey there.
In this lecture I want to tell you about the use of video in Android applications.
Let's create a new project and name it using redo
Next.
Next Finnish and wait for the project to build.
Well now let's go to the activity in main tap and large the screen delete the text.
Hello world.
And in order to display the video in our application we need to use a widget such as a video view
let's drag it to the screen straight it to full screen full screen size and set constraints
next.
Go to our activity main or rather main activity and create a variable of the video view class call it
video view and bind it with all video view in the layout our I.D. video view
it is also called a sissy
Next we need in fact we do a file that we will play in our Video View we can play a file that is on
the Internet or a file that is in our application.
Let's start by playing the file that is in our application in order to save the video file in the application.
It must be saved in the raw folder.
These are all folder needs to be placed in the race folder.
This way.
Right click on arrays new and directory.
And here we are right.
Raw folder name.
And then we need to move our file there.
I we will use the file that I will attach to the lecture and you will use it too.
Or you can use any other file as you wish.
And now you need to copy the file to the roll folder.
Let's see.
Everything is fine.
It is displayed.
And now we need to specify the path to these file.
This is done so we write.
We don't view set video path.
And here we specify the path from the beginning when spare specify this name space.
Since the file is in our Android application the namespace will be Android dot resource.
Call on and double flash next.
We need to get the name of our package.
This is done as follows The get package name method is called then slash is added and then we specify
our file with our resources.
Then they are all folder and our file demo file name.
You see the raw folder is displays displayed in red.
In order for androids to do to see my created folder in the resources it is necessary to rebuild the
project with the gradual builder.
This is done with this green hammer or with the help the build menu and also then make project this
with a green hammer.
Let's click and wait until the project is rebuilt and as soon as the project is rebuilt their name or
the roll folder is displayed correctly next for our video to start you need to run the method a video
view start let's run the application and let's see what we got.
And as you can see the video immediately starts playing.
Everything is great but we can't influence the video in any way.
We cannot stop it or a wired date to do this.
We need to add media control so-called to our Quote.
It is done like this.
We create a variable of mid air controller class
and assign it and you object of this class.
New media controller in the constructor of the class we specify these.
This is the context in which this made the controller will act.
That is it.
That is our main activity since the media controller will control the video in our main activity.
And next we can connect our media controller with our Video View as follows.
Video controller.
Set our view.
And it sets our made our controller in our Video View and so also we need to associate video view with
the video media controller.
This is done as follows.
VIDEO OF YOU SET ME THERE controller.
And here we specify our media control.
Then start video of you met at the school and let's around the app and see what we get
so click on the video.
Great.
We can now control the video.