How can we add subtitles in video view in android 4.2.2? -
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.videoview_main); mediaplayer mp=new mediaplayer(); videoview = (videoview) findviewbyid(r.id.videoview); } pdialog = new progressdialog(videoviewactivity.this); // set progressbar title pdialog.settitle("android video streaming tutorial"); // set progressbar message pdialog.setmessage("buffering..."); pdialog.setindeterminate(false); pdialog.setcancelable(false); // show progressbar pdialog.show(); try { mediacontroller mediacontroller = new mediacontroller( videoviewactivity.this); mediacontroller.setanchorview(videoview); uri video = uri.parse(videourl); videoview.setmediacontroller(mediacontroller); videoview.setvideouri(video); inputstream = getapplicationcontext().getresources().openrawresource(r.raw.test); videoview.addsubtitlesource(i ,mediaformat.createsubtitleformat("text/srt",locale.english.getlanguage())); videoview.start(); } catch (exception e) { log.e("error", e.getmessage()); e.printstacktrace(); } videoview.requestfocus(); } }
the above code showing java.lang.nosuchmethoderror: when try run on android 4.2 version. other way can use subtitles in video view in android?
do not use default android media player. use ijkplayer, there vlc lib, vitamo , many other media players android. not sure tho if every 1 of mentioned players have subtitle adding feature.
Comments
Post a Comment