Hello friends, If you want to play youtube video in full screen in default youtube player from your device by passing youtube video id , use following code. I hope it will work for you.
Button watch=(Button)findViewById(R.id.btn_watchnow);
watch.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
String id="IqZf2pj4oj8"; //Youtube video id
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" +id));
startActivity(i);
}
});
Try it. It works fine for me. Again in order to give option to open in browser, just use
Uri.parse("ytv://"+id)
No comments:
Post a Comment