local videos on android not playing when device resolution is lower

290 views Asked by At

I'm working on an android app that needs to display some videos. My client gave me some mp4 videos (that have one of the accepted android formats) and they play normally on a Nexus 5.

But when I tried with devices that have lower resolutions, they don't have image anymore (they're black) and only sound is playing. A pop up also says "Cannot play this video". The videos then only work if I lower their resolution (it seems like they cannot be above the device resolution)

What would be the best strategy to make sure that all videos would play to at least devices that have resolution ~480x800 ? Make different versions of them and place them in the dpi folders ? Or convince my client to stream them online ?

I'm using a videoview to display them and place them in the raw folder of the resources. My code looks like this:

setContentView(R.layout.videoActivity);
VideoView videoView = (VideoView) findViewById(R.id.videoView);
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);

videoView.setVideoPath("android.resource://" + getPackageName() + "/" + R.raw.asset1);
videoView.requestFocus();
videoView.start();
1

There are 1 answers

0
Mick On

As a general rule, unless you absolutely need them to work offline for instance, it is 'nicer' to stream videos than 'build' them into your app. I realise that is not a very technical term, and needs for different solutions will vary, but keeping the video on the server side reduces the application size and also allows the video be updated easily without having the upgrade the app.

Common streaming techniques will support multiple resolutions and bit rates also.

As an aside, are you sure the mp4 videos are not using 'mainline profile' - older and lower powered Android devices can often only support 'baseline profile'? You can check fairly easily on mist platforms by looking at the properties or getting info on the video file.