video - Android VideoView won't Play -
so i'm trying play basic avi video in android, seems run fine on windows media player, vlc, etc. doesn't it's requiring complicated codecs. have video view in app , that's it, , have video in resources directory under:
res/raw/my_video.avi
this code i'm using load video:
setcontentview(r.layout.activity_main); videoview videoview = (videoview) findviewbyid(r.id.videoview1); uri video = uri.parse("android.resource://" + getpackagename() + "/" + r.raw.my_video); videoview.setvideouri(video); videoview.start();
and not work. popup saying "can't play video" along logcat message:
03-10 01:42:12.102: e/(185): failed open file 'android.resource://com.securespaces.android.bootstrap/2130968576'. (no such file or directory) 03-10 01:42:12.102: e/mediaplayer(9737): error (1, -2147483648) 03-10 01:42:12.142: e/mediaplayer(9737): error (1,-2147483648)
i'm running on nexus 5 running 4.4.2 stock way. i'm following instructions found in other stack on flow questions here: how play videos in android assets folder or raw folder? minor tweaks using videoview grab layout file.
i'm stumped why isn't working. i've browsed through few questions on subject, feels should duplicate. i'm running on nexus 5 running 4.4.2 stock way.
to clarify question, i'm wondering doing wrong, or there alternative playing simple avi video?
implement :
public static void getvideofromraw(string rawpath) { try { // start mediacontroller mediacontroller mediacontroller = new mediacontroller(mcontext); mediacontroller.setanchorview(mvideoview); // url string videourl uri mvideo = uri.parse(rawpath); mvideoview.setmediacontroller(mediacontroller); mvideoview.setvideouri(mvideo); } catch (exception e) { log.e("error", e.getmessage()); e.printstacktrace(); } mvideoview.requestfocus(); mvideoview.setonpreparedlistener(new onpreparedlistener() { // close progress bar , play video public void onprepared(mediaplayer mp) { mvideoview.start(); } }); mvideoview.setoncompletionlistener(new oncompletionlistener() { public void oncompletion(mediaplayer mp) { } }); }
thanks
Comments
Post a Comment