android - play Video in VideoView -
in activity trying play video stored in raw folder. below activity. in first button not getting error can't play video, black screen appears. while clicking second button getting message can't play video. below activity
package com.example.college; import android.app.activity; import android.net.uri; import android.os.bundle; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.mediacontroller; import android.widget.videoview; public class firstyear extends activity { button cse,it,ece,eee; videoview vv; mediacontroller mc; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.first_year); cse=(button)findviewbyid(r.id.button1); it=(button)findviewbyid(r.id.button2); ece=(button)findviewbyid(r.id.button3); eee=(button)findviewbyid(r.id.button4); vv=(videoview)findviewbyid(r.id.videoview1); mc=new mediacontroller(this); mc.setanchorview(vv); cse.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub vv.setvideouri(uri.parse("android.resource://com.example.college/"+r.raw.c)); vv.start(); } }); it.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub vv.setvideouri(uri.parse("android.resource://com.example.college/"+r.raw.k)); vv.start(); } }); ece.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub vv.setvideouri(uri.parse("android.resource://com.example.college/"+r.raw.a)); vv.start(); } }); eee.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub vv.setvideouri(uri.parse("android.resource://com.example.college/"+r.raw.s)); vv.start(); } }); } }
the code correct. errors related video resolution. have replaced video different resolution , , working
Comments
Post a Comment