📜 ⬆️ ⬇️

Features of working with VideoView

Familiar picture?
Can't play video

Recently it happened to develop a mobile application that was supposed to play video supplied by one service. And I had to face some problems that I want to report.

Firstly, the video from the Internet is not played on the emulator. All attempts resulted only in the “Cannot play video” error. This, of course, unpleasant, but not fatal.
Much worse than the second: VideoView turned out to be capricious VideoView to require a connection. Hardly that - showed that on a picture. Most often this happened on prepare, but it also happened during playback.
In addition, strange things happened with buffering. Even with 100% buffering, if you scroll the video back, the buffer is reset to the position where we moved.

I had to try different solutions. The best was completely download the video and play from a local file. But with a file size of> 20 MB, it took a long time, so this idea also had to be abandoned.
')
Of course, I wondered if this is a common problem for an android or is it something I'm doing wrong. I had to conduct a review of similar software.

Youtube native app


It works well for me, no problems have been noticed. However, the network revealed a lot of complaints about unstable work and periodic falls of the player with a poor connection. Here are some examples:


Giantbomb


Client application for some GiantBomb service. The application was especially attracted by the fact that its sources are open (http://code.google.com/p/giantbomb-android/). But, unfortunately, I never managed to watch at least one video with it - there were only crashes with the indicated error (by the way, the screenshot is just from this application).

SPB TV 2


It worked stably, no departures were noticed. True, the plots there are not more than a minute.

And how did it all end?


Right now VideoView working in my application, but everywhere they are crammed with checks that it is buffered enough. I had to change the tariff from the provider and the error no longer repeated. However, with a poor connection, the problem still sometimes appears.

And the purpose of this article is to warn those who are going to work with VideoView , and get comments from those who have relevant experience.

Source: https://habr.com/ru/post/112140/


All Articles