Skip to content

直播礼物特效播放器,支持MP4(支持4个方向的透明通道)和WEBP。

Notifications You must be signed in to change notification settings

junixapp/LiveGiftPlayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Oct 14, 2021
489cfd1 · Oct 14, 2021

History

11 Commits
Oct 9, 2021
Sep 27, 2021
Oct 9, 2021
Oct 9, 2021
Sep 27, 2021
Oct 14, 2021
Sep 27, 2021
Oct 14, 2021
Sep 27, 2021
Sep 27, 2021
Sep 27, 2021
Sep 27, 2021
Sep 27, 2021

Repository files navigation

LiveGiftPlayer

直播礼物特效播放器,支持MP4(支持4个方向的透明通道)和WEBP。

特色

  • 队列播放
  • 支持4个方向的透明通道的MP4文件
  • 支持WEBP格式
  • 实现Lifecycle自动释放资源

效果

依赖

implementation 'com.github.li-xiaojun:LiveGiftPlayer:版本号'

使用

  1. 构造GiftPlayItem
data class GiftPlayItem(
    var path: String,  //文件路径
    var fileType: GiftFileType, //礼物文件类型
    var alphaPosition: AlphaPosition? = null //透明通道位置,MP4类型需要传
)
  1. 播放
LiveGiftPlayer.play(lifecycleOwner, giftItem, giftContainer)
  1. 监听
LiveGiftPlayer.playCallback = object : LiveGiftPlayer.PlayCallback{
    override fun onStart(gift: GiftPlayItem) {
        findViewById<TextView>(R.id.tvInfo).text = "开始播放 ${gift.path} 透明通道:${gift.alphaPosition}"
    }

    override fun onEnd(gift: GiftPlayItem) {
        findViewById<TextView>(R.id.tvInfo).text = "播放结束 ${gift.path} 透明通道:${gift.alphaPosition}"
    }

}

注意

  1. WEBP格式动画在低端机性能较低,可能会出现卡顿现象

About

直播礼物特效播放器,支持MP4(支持4个方向的透明通道)和WEBP。

Resources

Stars

Watchers

Forks

Packages

No packages published