How to play online videos in Android? -



How to play online videos in Android? -

i developing sample media player app in android play online videos, have developed code play videos. plays video sd card well, facing 2 issues in respect.

1- when open app online videos shows video not play video , after while displays alert dialog having message "sorry, video cannot played".

2- have code "progress bar", don't know set code when video downloading internet.

here code can check it. in advance.

myvideoview = (videoview) findviewbyid(r.id.surface_view); seek { myvideoview.setvideouri(uri.parse("http://www.my_domain_name.com/videos/video1.mp4")); myvideoview.setmediacontroller(new mediacontroller(this)); myvideoview.requestfocus(); myvideoview.start(); } catch(exception e) { toast.maketext(getapplicationcontext(), "no media found", toast.length_long).show(); }

try this

videoview v; mediacontroller mediacontroller; progressdialog progressdialog;

then

public void playvideo(string videopath) { log.e("entered", "playvide"); log.e("path is", "" + videopath); seek { progressdialog = progressdialog.show(videoplay.this, "", "buffering video...", false); progressdialog.setcancelable(true); getwindow().setformat(pixelformat.translucent); mediacontroller = new mediacontroller(videoplay.this); uri video = uri.parse(videopath); v.setmediacontroller(mediacontroller); v.setvideouri(video); v.setonpreparedlistener(new onpreparedlistener() { public void onprepared(mediaplayer mp) { progressdialog.dismiss(); v.start(); } }); } grab (exception e) { progressdialog.dismiss(); system.out.println("video play error :" + e.getmessage()); } }

if still has problem "this video cannot played" seek alter video format , hope help u.

android video-streaming

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -