All Projects → react-native-studio → react-native-android-danmaku

react-native-studio / react-native-android-danmaku

Licence: other
react native弹幕插件(android)基于哔哩哔哩弹幕插件

Programming Languages

java
68154 projects - #9 most used programming language
javascript
184084 projects - #8 most used programming language
python
139335 projects - #7 most used programming language

react-native-android-danmaku npm version

第一步

工程目录下运行 npm install --save react-native-android-danmaku 或者 yarn add react-native-android-danmaku(已经安装了yarn)

注意:

version 0.1.1适用于大于等于rn0.44和小于0.47
version 0.2.1适用于rn0.47及以上

第二步

运行 react-native link react-native-android-danmaku

第三部使用

在工程中导入:

import DanmakuView from 'react-native-android-danmaku';
<DanmakuView style={{flex:1}} speed={1.2} maxLines={5} ref={ref=>this.danmaView=ref}/>
this.danmakuView.pause(); //暂停弹幕
this.danmakuView.resume(); //重启弹幕
this.danmakuView.hide(); //隐藏弹幕
this.danmakuView.show(); //显示弹幕
this.danmakuView.addDanmaku({text:'000000',color:'red',padding:2,isLive:true,time:2000,fontSize:36})
//发送弹幕

注意在使用中时应设置组件的宽高;

属性:

1 speed 弹幕的速度 2 maxLines 弹幕的最大行数

方法

pause()暂停弹幕
resume() 重启弹幕
hide() 隐藏弹幕
show() 显示弹幕
addDanmaku(params) 发送弹幕
params为:{text, isLive, fontSize, padding, color, time}
text:弹幕内容, isLive:是否为直播, fontSize:弹幕字体大小, padding:弹幕的内边距, color:弹幕颜色, time:弹幕出现时间,

示例

图片名称

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].