How to add a video file when starting an android app -


i want play video file while starting android application. i've tried it's not working properly. i've got error message , tells video can't played. i've saved video(.mp4 extension) in raw folder. i've set path such following:

path = "android.resource://com.easy.video/" + r.raw.myvideo; 

this java file.

package com.easy.video;  import android.media.mediaplayer; import android.media.mediaplayer.oncompletionlistener; import android.os.bundle; import android.app.activity; import android.content.intent; import android.view.menu; import android.widget.toast; import android.widget.videoview;  @suppresswarnings("unused") public class mainactivity extends activity {      private videoview videoview;     string extstoragedirectory;     protected static final int play = 0x101;     protected static final int stop = 0x102;     protected static final int pause = 0x103;     int state;     private string current;      private string path;     private videoview mvideoview;      @override     public void oncreate(bundle icicle) {         super.oncreate(icicle);         setcontentview(r.layout.activity_main);         path = "android.resource://com.easy.video/" + r.raw.myvideo;         mvideoview = (videoview) findviewbyid(r.id.video);         if (path == null || path.length() == 0) {             toast.maketext(mainactivity.this, "file url/path empty",                     toast.length_long).show();          } else {             // if path has not changed, start media player             if (path.equals(current) && mvideoview != null) {                 mvideoview.start();                 mvideoview.requestfocus();                 return;             }             current = path;             mvideoview.setvideopath(path);             mvideoview.start();             mvideoview.requestfocus();         }         mvideoview.setoncompletionlistener(new oncompletionlistener() {             public void oncompletion(mediaplayer arg0) {                  intent in = new intent(mainactivity.this, nextactivity.class);                 startactivity(in);                 finish();             }         });     }  } 

actually not sure whether correct or not. grateful if can kind enough explain how ?

when using raw file resource id, please use uri.parse() , mvideoview.setvideouri( uri.parse(path));


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -