VideoView in Android using Kotlin:

VideoView:–
With the help of VideoView you can insert video in your application.
Steps to use VideoView in an application in android using kotlin.
Srep 1. Add a VideoView in your layout (XML file) and set it’s constraints.
Step 2. Create Raw file.
        Res->new->directory
Purpose of raw file :-
  It can store media file like audio and video in binary form and bind it with apk. It becomes a part of your application.

Step 3. Create instance of media controller in KT file :-
Val mediacontroller=Mediacontroller (this)
Mediacontroller.setAnchorView(VideoView)
VideoView.setmediacontroller(Mediacontroller)
Var uri=”android.resources://”+packagename+”/”+R.raw.calendarview
VideoView.setvideoURI(uri.parse(uri))
VideoView.start()
VideoView.setOnCompleteonlistener{
Toast.maketext(this@mainactivity,”video is completed”)
Toast.LENGTH_LONG).show()}
VideoView.setOnErrorListener(MediaPlayer.onerrorlistener{ Mediaplayer,i,i2->
Toast.maketext(this@mainactivity,”Error in video playing”,toast.Length_long).show()true)}


Finish

Leave a Reply

Your email address will not be published. Required fields are marked *