Home » » Dosen Pengampu : Iwan Fitrianto Rahmad M.Kom

Dosen Pengampu : Iwan Fitrianto Rahmad M.Kom

Kali ini kami akan memposting tugas dari Bapak Iwan Fitrianto M.Kom tentang membuat Galeri Video yang merupakan gabungan dari tugas Target(link to) dan Video Player   di eclipse berikut langkah2nya :

1.Pertama buat project baru dengan nama Galeri Video dengan :

Build Target : Android 2.2
Aplication Name : Galeri Videoku
Package Name : tugas.vlog.topek
Min SDK Version : 8
Create Activity : Main

Iwan Fitrianto Rahmad M.Kom




Beri nama Class sesuai dengan fungsi dari class yang akan digunakan. Pada contoh ini nama class adalah video 1 .buat hingga 3 class dengan nama video 2 dan video 3. 


2. Kemudian klik kanan pada res->pilih new->Android xml file kemudian isi nama file tsd dengan video2 buat hingga 3 layout dengan nama video 2 dan video 3

3.kemudian copy kan script berikut di Main.Java

package tugas.vlog.topek;
import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class Main extends Activity {
private Button video1, video2, video3;
/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        video1 = (Button)findViewById(R.id.video1);
        video1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        Intent i=new Intent(getApplicationContext(),video1.class);
        startActivity(i);
        }
        });
        video2 = (Button)findViewById(R.id.video2);
        video2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        Intent i=new Intent(getApplicationContext(), video2.class);
        startActivity(i);
        }
        });
        video3 = (Button)findViewById(R.id.video3);
        video3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        Intent i=new Intent(getApplicationContext(), video3.class);
        startActivity(i);
        }
        });
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    return true;
    }
}
4.Copy Script dibawah ini ke video1.Java
package tugas.vlog.topek;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.VideoView;
public class video1 extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.video1);
       
        VideoView video = (VideoView) findViewById(R.id.Video1);
        Uri lokasiVideo = Uri.parse("android.resource://" +
        getPackageName()
        + "/" + R.raw.lo);
        video.setVideoURI(lokasiVideo);
        video.start();
    }
}
4.copy kode tadi di video 2, dan video 3 ,ganti text video1 (pada public class)dan Video 1 (pada menjadi video2 dan Video2

5.Copykan script berikut di main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
     android:background="@drawable/images"
    >
<Button
    android:id="@+id/video1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Video1"
    />
<Button
    android:id="@+id/video2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Video2"
    />
<Button
    android:id="@+id/video3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Video3"
    />
</LinearLayout>
4. copykan script dibawah ini ke video1  Iwan Fitrianto Rahmad M.Kom<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Contoh Video" />
<VideoView
android:id="@+id/Video1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" >
</VideoView>
<MediaController
android:id="@+id/MediaController01"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</MediaController>
</LinearLayout>

5.copykan script dibawah ini ke manifest.android
.<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="tugas.vlog.topek"
      android:versionCode="1"
      android:versionName="1.0">
     
                        <uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
     
            <application
            android:icon="@drawable/images"
android:allowBackup="true" >
     
<activity
android:name="tugas.vlog.topek.Main"
android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
<activity android:name="video1"></activity>
<activity android:name="video2"></activity>
<activity android:name="video3"></activity>

    </application>
</manifest> 

Demikian script diatas ini yang diperoleh dari bpk Iwan Fitrianto Rahmad M.Kom

Nama Kelompok : Enti Letianis
                           Lilani Widya Putri
                           Maulia Agustina
                           Putri Devi
                           Taufik Hidayat


SI D Malam Semester 5 
Fakultas Ilmu & Teknik Komputer 
Universitas Potensi Utama

0 comments:

Post a Comment

Enter your email address:

Delivered by FeedBurner