How to add video file at the startup of App in Android Programming? -
How to add video file at the startup of App in Android Programming? -
i need add together video file whenever start app showing details. need help that. need know how write code that.
save video file in raw
folder
give video file name in
path="android.resource://yourpackagename/"+r.raw.yourvideofilename;
see below class
public class homevideo 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.homevideo); path="android.resource://yourpackagename/"+r.raw.yourvideofilename; mvideoview = (videoview) findviewbyid(r.id.video); if (path == null || path.length() == 0) { toast.maketext(homevideo.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() { @override public void oncompletion(mediaplayer arg0) { intent in =new intent(homevideo.this,nextactivity.class); startactivity(in); finish(); } }); } }
xml
file this
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <videoview android:id="@+id/video" android:layout_width="fill_parent" android:layout_height="fill_parent" android:keepscreenon="true"> </videoview> </linearlayout>
in manifest file
<activity android:name=".homevideo" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity>
android
Comments
Post a Comment