Example of video subtitle and horizontal and vertical screen switching for Android

Some video formats of the system's own videoview are not supported, so we can use the videoview implemented by a third party to replace the system's to play video. The more popular ones are ijkplayer and vitamio.

Recently, there is a need to add subtitles to the video. In fact, it is very simple. The common format of subtitles is SRT. In fact, it is text. Analyze it and display it according to time. In addition, even if the rotary button is turned off, the horizontal and vertical screen can be switched according to the direction sensor.

This paper uses the system videoview, and then plays the video in the SD card as a demonstration (the source code contains f2.mp4 and f2.srt, which can be copied to the SD card at runtime). Here is a brief introduction to the source code:

Mainactivity includes displaying subtitles and how to switch between horizontal and vertical screens:

Srtparser is an algorithm for parsing subtitle files:

Operation effect diagram:

Project source code, click download

The above example of video subtitle subtitle and horizontal and vertical screen switching implemented by Android is all the content shared by Xiaobian. I hope it can give you a reference and support more programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>