Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add video playback and resource to android application

I have got problem with my idea on andriod app. I'd like to play video in it, but I don't want to download it from interenet. In other case, I want to have it on device.

So, person is download it from android market and can play video without downloading it. I have came up with some solutions for it but none is good.

First one was adding it to application resources, but you can't have video in there.

Second one was adding or better creating folder during install (more specyfic first onCreate method) and then copying there video from app. Well, not so bad option (you can for example download then one time only video from web using background service) but I have no idea how to delete in on uninstall since your app don`t know when it is unistalled.

So does anyone know or have any idea on it?

like image 278
sebap123 Avatar asked Dec 25 '11 12:12

sebap123


1 Answers

You can put a video into app resources - just put it into res/raw folder. You can play it like this:

VideoView videoview = (VideoView) findViewById(R.id.videoview);

Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.splash);

videoview.setVideoURI(uri);
videoview.start();

The main thing to consider here is the size of your video. As video files can be quite large, your resulting apk file can also get unacceptably large. Personally, I would rarely want to download an app from the market that weighs in at 10 meg (there are exceptions, of course).

like image 139
Aleks G Avatar answered Nov 05 '22 18:11

Aleks G