Android Studio: Video Player Sederhana
Revision as of 11:21, 17 March 2022 by 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...")
MainActivity.java
import android.net.Uri; import android.support.v7.app.AppCompatActivity; 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(); } }