GithubHelp home page GithubHelp logo

###DanmukuMaster-iOS

####预览效果

####简介:

弹幕引擎,使用coretext编写。比一般的UILabel要节省内存空间。经测试10秒内显示1000条弹幕可行。

####Feature:

1、可以挑选动画样式,分别是滚动、顶部停留、底部停留。
2、停留动画的弹幕计算了显示位置,不会叠加显示。
3、简单易用,内容解耦,可修改性强。

####使用方法

1.首先定义一个全局变量:  
RiverRunCommentManager *_manger;  
2.初始化弹幕
 _manger = [[RiverRunCommentManager alloc]initWithComments:_commentArray delegate:self andPresentView:self.view videoSize:self.view.bounds.size screenSize:self.view.bounds.size isLandscape:UIInterfaceOrientationIsLandscape(self.interfaceOrientation)];
3.写好回调方法,返回值为当前播放时间,以s为单位
- (CGFloat)willShowComments:(BOOL)seek {
    return _commentNUM;
}
4.开启屏幕翻转时适应
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    [_manger setupPresentView:self.view
                    videoSize:self.view.bounds.size
                   screenSize: self.view.bounds.size
                  isLandscape:UIInterfaceOrientationIsLandscape(self.interfaceOrientation)];
}
5.开启弹幕
    [_manger start];
6.暂时关闭弹幕 
   [_manger stop];
   [_manger deleteAllCommentLayer];
7.重新开启
    _manger.comments = _commentArray;(更新弹幕)
    [_manger start];
8.退出时调用的方法
 [_manger stop];
 _manger = nil;

####弹幕的相关参数

/*
参数的含义:
vpos:是开始出现的时间,以毫秒为单位,和服务器返回数据格式相反   数据类型int
body:弹幕内容 数据类型string
position:固定string字符,top或者bottom是停留在屏幕上下两端的,其他是正常飘过的弹幕  
“top” 	
“bottom” 
fontSize:字体大小,数据类型int
color:颜色,格式:#ffffff, 数据类型string
duration:动画时间 数据类型float
“”(其他)  
*/
举例:  NSDictionary *commentInfo = @{
                                      @"vpos": @(vpos),
                                      @"body": @“Hello World!!!",
                                      @"position": @([RiverRunCommentUtil commentPosition:[self getPosition]]),
                                      @"fontSize": @([RiverRunCommentUtil commentSize:[self getFontSize]]),
                                      @"color": @"#ffffff",
                                      @"duration":@(3.f),
                                      };

####已知bug

存在部分的内存泄漏问题

#####其他:

定义的随机数相关
获得位置的随机数可用[RiverRunCommentUtil getPosition],
如 @"position": @([RiverRunCommentUtil commentPosition:[RiverRunCommentUtil getPosition]])
获得fontsize随机数可用[RiverRunCommentUtil getFontSize]
如:@"fontSize": @([RiverRunCommentUtil commentSize:[RiverRunCommentUtil getFontSize]])

CrazyPeter's Projects

autoproxy icon autoproxy

一个用于scrapy爬虫的自动代理中间件

cordova-base64-to-gallery icon cordova-base64-to-gallery

:warning: this project is not longer maintained - Cordova plugin to save base64 data as a png image into the device

cordova-hot-code-push icon cordova-hot-code-push

[DEPRECATED] - This plugin provides functionality to perform automatic updates of the web based content in your application.

docsify icon docsify

🃏 A magical documentation site generator.

duobaoserver icon duobaoserver

一元夺宝的服务器端的前台夺宝和后台管理,纯属模仿.

emuthreeds icon emuthreeds

Nintendo 3DS emulator for Apple devices based on Citra.

gm-crypt icon gm-crypt

国密算法JS实现。Implement of Chinese encrypt algorithm in JavaScript.

krkrv icon krkrv

プレイステーションヴィータ用吉里吉里 / Kirikiri for Playstation Vita

onscripter-en-steam icon onscripter-en-steam

A version of ONScripter-EN designed to work with the Steam API, OpenGL, and other upgrades

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.