Android na veia

    Featured Posts

Usando VideoView

Android developer

Rodar um video dentro de um view no android é muito simples, abaixo exemplo de como montar o layout e o código java.

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">
<VideoView android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/VideoView"/>
</LinearLayout>

Video.java

package com.image;

import java.net.URI;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class image extends Activity {
private static final String TAG = "PRANJAL";
private boolean isImage = false;
private String reviewImageLink;
private MediaController mc;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView vd = (VideoView) findViewById(R.id.VideoView);

Uri uri = Uri.parse("android.resource://" + getPackageName() + "nome do video na pasta  raw");

mc = new MediaController(this);
vd.setMediaController(mc);

vd.setVideoURI(uri);
vd.start();
}

}

author

Rodrigo Macedo

Sou desenvolvedor android e há mais de 5 anos trabalho com dispositivos móveis.

para Receba atualizações grátis!

www.CodeNirvana.in

Related Posts Plugin for WordPress, Blogger...
Copyright © Android na veia