The source code has been open sourced to Github: SuperVideoView , interested friends can fork, by the way, remember star ~
I saw someone in the group discussing the use of Android VideoView before and found that everyone has several common problems. For the convenience of everyone in the future and for your own convenience, the unnecessary pits are also reduced. With today's content, the Android VideoView player is functionally packaged. The following briefly introduces the functions added by the library and the existence of the resolved VideoView. Bug issue. .
1. Functional advantages
(1) Play progress control
(2) Progress reminder
(3) Screen switching
(4) Volume adjustment
(5) Screen brightness
(6) Gesture sliding control
Second, the bug solution
Solve the problem that the video cannot switch to the full screen and black block problem when switching the screen when VideoView is playing video.
3. How to use
(1) Source code import
(2) Set in the layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.song.supervideoview.MainActivity">
<com.song.supervideoview.SuperVideoView
android:id="@+id/supervideo"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
(3) Reference in Activity or Frament:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
videoView.register(this);// 注册宿主
videoView.setVideoPath(mVideoUriPath); //设置媒体路径,网络媒体和本地媒体路径都使用此方法设置
}
@Override
protected void onPause() {
super.onPause();
videoView.onPause();
}
@Override
protected void onResume() {
super.onResume();
videoView.onResume();
}
(4) The code provides external interfaces such as modification styles. You can check the source code for details.
Four, renderings
(1) Vertical screen
(2) Horizontal screen
(3) Slide up and down to adjust the volume
(4) Slide left and right to adjust the brightness