Pesquisar




Author Image
Desenvolvimento em Foco Programação Contact Me

AIDE - VideoView simples










Método - VideoView

final String path = String.valueOf(R.raw.intro);
final EditText songpath = (EditText)findViewById(R.id.songpath);
songpath.setText(path);
zerar = (Button) findViewById(R.id.zerar);
zerar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
songpath.setText(path);

}
});
tube = (Button) findViewById(R.id.tube);
tube.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
songpath.setText("https://www.youtube.com/watch?v=RpE_VJ_rBek");

}
});

play = (Button) findViewById(R.id.play);
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(songpath.getText().toString().contains(".youtube")){
videoView.setVideoURI(Uri.parse(String.valueOf(songpath.getText())));
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(String.valueOf(songpath.getText()))));
}else {
videoView.setMediaController(new MediaController(MainActivity.this));
videoView = (VideoView) findViewById(R.id.video);
videoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + songpath.getText()));
videoView.setBackgroundResource(0);
videoView.start();
}


}
});
stop = (Button) findViewById(R.id.stop);
stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
videoView.stopPlayback();

}
});


//////////////////////////////////////////////////////////////////////



Nenhum comentário:

Postar um comentário

Obrigado por comentar, volte sempre!

Seguidores

Não encontrou o que procura ?