Guest User

MainActivity.java

a guest
Mar 29th, 2017
9,796
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.okedroid.contohaplikasi;
  2.  
  3. import android.net.Uri;
  4. import android.os.Bundle;
  5. import android.support.v7.app.AppCompatActivity;
  6. import android.widget.MediaController;
  7. import android.widget.VideoView;
  8.  
  9.  
  10. /*
  11. Fathurrahman (okedroid.com)
  12.  */
  13. public class MainActivity extends AppCompatActivity {
  14.  
  15.     VideoView videoView;
  16.   //deklarasi obj
  17.  
  18.     @Override
  19.     protected void onCreate(Bundle savedInstanceState) {
  20.         super.onCreate(savedInstanceState);
  21.         setContentView(R.layout.activity_main);
  22.  
  23.         getSupportActionBar().setTitle("Contoh VideoView");
  24.         getSupportActionBar().setSubtitle("Belajar di okedroid.com");
  25.  
  26.         videoView = (VideoView) findViewById(R.id.videoView);
  27.         //inisialisasi object videoView
  28.         videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.contoh_video));
  29.         //digunakan untuk mengidentifikasi resource seperti lokasi video
  30.         videoView.setMediaController(new MediaController(this));
  31.       //menampilkan media controller video
  32.         videoView.start();
  33.         //memulai video
  34.  
  35.     }
  36.  
  37. }
RAW Paste Data