Android video player plug-in – mxvideo




Android open source player based on dumpling player and kotlin, out of the box. Welcome to issue and pull request
Project address:MXVideo

Android video player plug-in - mxvideo

Small screen

Android video player plug-in - mxvideo

live broadcast

Functional characteristics

  • Any player kernel (including open source ijk, Google exo, Alibaba cloud, etc.)
  • For single case playback, only one program can be played at the same time
  • 0 code integrated full screen function
  • The volume and screen brightness can be adjusted
  • You can register the playback status listening callback
  • The player height can be automatically adjusted according to the video height
  • The player supports setting the aspect ratio. After setting the aspect ratio, the height is fixed.
  • Automatically save and restore playback progress (can be closed)
  • It supports circular playback, full screen vertical screen mode, fast forward and fast back function can be turned off, full screen function can be turned off, and traffic reminder in non WiFi environment can be turned off
1. Introducing mxvideo through dependency
    dependencies {
            implementation 'com.gitee.zhangmengxiong:MXVideo:x.x.x'
2. Page integration
            android:layout_height="wrap_content" />
3. Start playing
//Set playback bitmap

//Play from last progress by default
mxVideoStd. setSource(MXPlaySource(Uri.parse(" ")," title 1 "))

//Play from scratch
mxVideoStd. setSource(MXPlaySource(Uri.parse(" ")," title 1 "), seekto = 0)

//Play from the 10th second
mxVideoStd. setSource(MXPlaySource(Uri.parse(" ")," title 1 "), seekto = 10)

Description of mxplaysource optional parameters:

parameter explain Default value
title title “”
headerMap Network request header null
changeOrientationWhenFullScreen Whether the activity direction needs to be changed during full screen. If = null, it will be judged automatically according to the width and height of the video null
isLooping Loop play false
enableSaveProgress Whether to store and read the playback progress true
isLiveSource Whether the live broadcast source is available. During the live broadcast, the progress is not displayed, and the fast forward and rewind cannot be suspended false
4. Monitor playback progress
mxVideoStd.addOnVideoListener(object : MXVideoListener() {
            //Playback status change
            override fun onStateChange(state: MXState) {

            //Playback time change
            override fun onPlayTicket(position: Int, duration: Int) {
5. Full screen return + release resources

Here, mxvideo holds the currently playing mxvideostd by default. You can use static methods to exit the full screen and release resources.

You can also directly use viewid: mxvideostd isFullScreen(),mxVideoStd. isFullScreen(),mxVideoStd. Release () and other methods.

    override fun onBackPressed() {
        if (MXVideo.isFullScreen()) {

    override fun onDestroy() {

Functional correlation

  • Player kernel switching
//The default is mediaplayer player, and the library is built-in by default

//Google's exo player

//Ijk player

//Setting the playback source can set the kernel. The default = mxsystemplayer
mxVideoStd.setSource(MXPlaySource(Uri.parse("xxx"), "xxx"), player =
  • Video rendering rotation angle
//Default rotation angle = mxorientation DEGREE_ 0
  • Video fill rule
//Force fill width height mxscale FILL_ PARENT
//Adaptive width and height mxscale according to video size CENTER_ CROP

//Default fill rule = mxscale CENTER_ CROP
  • Mxvideostd control width height constraint

Add layout in the page XML_ Width is generally set to match_ Parent, height wrap_ content

        android:layout_height="wrap_content" />

You can set any aspect ratio. If you set the aspect ratio, the control height needs to be set to Android: layout_ Height = “wrap_content”, otherwise it will not take effect.

When unconstrained, mxvideo highly adaptive, fill rule = mxscale CENTER_ When crop, the height of the control will automatically fill the height according to the width and height of the video

//Mxvideostd control set aspect ratio = 16:9
mxVideoStd.setDimensionRatio(16.0 / 9.0)

//Mxvideostd control set aspect ratio = 4:3
mxVideoStd.setDimensionRatio(4.0 / 3.0)

  • Progress jump
//Progress unit: second, which can be called after starting playback, or before error or completion of playback
  • Unable to set fast forward or rewind
//Set before playback default = true
mxVideoStd.getConfig().canSeekByUser = false
  • Setting cannot be full screen
//Set before playback default = true
mxVideoStd.getConfig().canFullScreen = false
  • Sets the time when the upper right corner of the control is not displayed
//Set before playback default = true
mxVideoStd.getConfig().canShowSystemTime = false
  • Set not to display the electricity diagram in the upper right corner of the control
//Set before playback default = true
mxVideoStd.getConfig().canShowBatteryImg = false
  • Set the alert before turning off WiFi environment playback
//Set before playback default = true
mxVideoStd.getConfig().showTipIfNotWifi = false
  • Set to automatically exit the full screen after playback
//Set before playback default = true
mxVideoStd.getConfig().gotoNormalScreenWhenComplete = true
  • Automatically exit full screen after setting playback error
//Set before playback default = true
mxVideoStd.getConfig().gotoNormalScreenWhenError = true
  • Set the screen direction and automatically enter the full screen and small screen modes according to gravity induction
//Set before playback default = false
mxVideoStd.getConfig().autoRotateBySensor = true