mp4 - cannot open play this video in VideoView from sd card -


hi trying play video phone's internal storage in videoview phone prompting "cannot play video". getting video path in main activity passing projector activity.

this path: '/storage/emulated/0/storage/emulated/0/snaptube/download/snaptube video/justin bieber - sorry (purpose _ movement).mp4'

oncreate code:

 @override      protected void oncreate(bundle savedinstancestate) {          super.oncreate(savedinstancestate);          setcontentview(r.layout.activity_projector);            intent intent = getintent();          string vidpath = intent.getextras().getstring("path");          p = (textview) findviewbyid(r.id.videopath);          p.settext(vidpath);            uri path= uri.parse(environment.getexternalstoragedirectory()+vidpath);            viewvid=(videoview) this.findviewbyid(r.id.videoview);          log.i("vidpath","here");          viewvid.setvideouri(path);          viewvid.start();          }

this how video path mainactivity:

 @override      protected void oncreate(bundle savedinstancestate) {          super.oncreate(savedinstancestate);          setcontentview(r.layout.activity_main);            getsupportactionbar().settitle("video projector");          gall = (button) findviewbyid(r.id.gallery);          gall.setonclicklistener(this);      }        @ override      public void onactivityresult(int requestcode, int resultcode, intent data) {          if (resultcode == result_ok) {              if (requestcode == select_video) {                  selectedvideopath = getpath(data.getdata());                  if(selectedvideopath == null) {                      finish();                  } else {                      toast.maketext(this,"a video selected",toast.length_long).show();                      intent = new intent(this,projector.class);                      i.putextra("path",selectedvideopath);                      startactivity(i);                  }              }          }          finish();      }        public string getpath(uri uri) {          string[] projection = { mediastore.images.media.data };          cursor cursor = getcontentresolver().query(uri, projection, null, null, null);          if(cursor!=null) {              int column_index = cursor.getcolumnindexorthrow(mediastore.video.media.data);              cursor.movetofirst();              return cursor.getstring(column_index);          }          else return null;      }            @override      public void onclick(view v) {          if (v==gall)          {              intent = new intent(intent.action_pick, android.provider.mediastore.video.media.external_content_uri);              startactivityforresult(i, select_video);          }      }

here log:

09 - 11 09: 48: 33.341 27291 - 27291 / com.example.tabish.vidprojector w / mediaplayer: couldn 't open /storage/emulated/0/storage/emulated/0/snaptube/download/snaptube video/justin bieber - sorry (purpose _ movement).mp4: java.io.filenotfoundexception: no content provider: /storage/emulated/0/storage/emulated/0/snaptube/download/snaptube video/justin bieber - sorry (purpose _ movement).mp4  09 - 11 09: 48: 33.342 27291 - 27291 / com.example.tabish.vidprojector / mediaplayer: setdatasource(/storage/emulated / 0 / storage / emulated / 0 / snaptube / download / snaptube video / justin bieber - sorry(purpose _ movement).mp4)  09 - 11 09: 48: 33.342 547 - 628 / ? / mediaplayerservice : setdatasource(/storage/emulated / 0 / storage / emulated / 0 / snaptube / download / snaptube video / justin bieber - sorry(purpose _ movement).mp4)  09 - 11 09: 48: 33.365 547 - 27641 / ? e / filesource : failed open file '/storage/emulated/0/storage/emulated/0/snaptube/download/snaptube video/justin bieber - sorry (purpose _ movement).mp4'.(no such file or directory)

solved: step1: use uri path=uri.fromfile(new file(vidpath)); step2: check storage permission app in application manager of phone


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -