Difference between revisions of "Android Studio: Video Player Sederhana"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) (Created page with " ==MainActivity.java== import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.MediaController; import...") |
Onnowpurbo (talk | contribs) |
||
Line 2: | Line 2: | ||
==MainActivity.java== | ==MainActivity.java== | ||
− | + | import androidx.appcompat.app.AppCompatActivity; | |
import android.net.Uri; | import android.net.Uri; | ||
− | |||
import android.os.Bundle; | import android.os.Bundle; | ||
import android.widget.MediaController; | import android.widget.MediaController; |
Revision as of 11:21, 17 March 2022
MainActivity.java
import androidx.appcompat.app.AppCompatActivity; import android.net.Uri; import android.os.Bundle; import android.widget.MediaController; import android.widget.VideoView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); VideoView videoView =(VideoView)findViewById(R.id.vdVw); //Set MediaController to enable play, pause, forward, etc options. MediaController mediaController= new MediaController(this); mediaController.setAnchorView(videoView); //Location of Media File Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.video1); //Starting VideView By Setting MediaController and URI videoView.setMediaController(mediaController); videoView.setVideoURI(uri); videoView.requestFocus(); videoView.start(); } }