https://github.com/junixapp/livegiftplayer
直播礼物特效播放器,支持MP4(支持4个方向的透明通道)和WEBP。
https://github.com/junixapp/livegiftplayer
Last synced: 11 months ago
JSON representation
直播礼物特效播放器,支持MP4(支持4个方向的透明通道)和WEBP。
- Host: GitHub
- URL: https://github.com/junixapp/livegiftplayer
- Owner: junixapp
- Created: 2021-09-27T16:13:31.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-10-14T13:12:19.000Z (over 4 years ago)
- Last Synced: 2025-04-02T14:02:15.485Z (about 1 year ago)
- Language: Java
- Size: 16.6 MB
- Stars: 26
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LiveGiftPlayer
直播礼物特效播放器,支持MP4(支持4个方向的透明通道)和WEBP。
# 特色
- 队列播放
- 支持4个方向的透明通道的MP4文件
- 支持WEBP格式
- 实现Lifecycle自动释放资源
# 效果

# 依赖
[](https://jitpack.io/#li-xiaojun/LiveGiftPlayer)
```
implementation 'com.github.li-xiaojun:LiveGiftPlayer:版本号'
```
# 使用
1. 构造GiftPlayItem
```kotlin
data class GiftPlayItem(
var path: String, //文件路径
var fileType: GiftFileType, //礼物文件类型
var alphaPosition: AlphaPosition? = null //透明通道位置,MP4类型需要传
)
```
2. 播放
```kotlin
LiveGiftPlayer.play(lifecycleOwner, giftItem, giftContainer)
```
3. 监听
```kotlin
LiveGiftPlayer.playCallback = object : LiveGiftPlayer.PlayCallback{
override fun onStart(gift: GiftPlayItem) {
findViewById(R.id.tvInfo).text = "开始播放 ${gift.path} 透明通道:${gift.alphaPosition}"
}
override fun onEnd(gift: GiftPlayItem) {
findViewById(R.id.tvInfo).text = "播放结束 ${gift.path} 透明通道:${gift.alphaPosition}"
}
}
```
# 注意
1. WEBP格式动画在低端机性能较低,可能会出现卡顿现象