Question

I am working in a project for streaming videos . I need to develop a view which can run the video from internet i googled for this and find some views but i cant decide which is best and why, so please help me to find a best view to play video.

And it should work from API level 8.

Was it helpful?

Solution

Your biggest constrain is your need for API level 8 support. This basically excludes TextureView and low-level Media APIs, and you can only use MediaPlayer + Surface/SurfaceView or VideoView. VideoView is basically a SurfaceView with an attached MediaPlayer. Alternately, you can manage the Surface separately from the MediaPlayer. MediaPlayer supports only rtsp and progressive http playback, but not 100% certain that these were present at API 8. It also supports limited HLS support since API 11.

The ability to play media on an arbitrary Surface using MediaPlayer was added in API 16, but you can use setDisplay in API 8. When playing media on a Surface, there are certain limitations, such as that a Surface(View) cannot be animated. TextureView would make the most flexible user interface, but it was added in API 14, so it is out. Note, that TextureView is not suitable for protected content.

The low-level Media* interfaces (MediaCodec, MediaExtractor) were added in API 16, so they are also out. These would provide you the most flexibility as to playing most kinds of videos. MediaExtractor supports a few streaming protocols (rtsp and progressive http) and a few containers. Otherwise, you could implement your own stream extractor and use only MediaCodec APIs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top