S2BEmitter
public final class S2BEmitter
Danmaku poster
-
Default emitter.
Declaration
Swift
public static let `default` = S2BEmitter()
-
Suggested cool time between sending danmaku in seconds. Number smaller than the default may result in ban or failure.
Declaration
Swift
public static let defaultDelay: Double = 3.5
-
Suggested cool time when received -636 (frequency too high) from bilibili. Number smaller than the default may result in ban or failure.
Declaration
Swift
public static let defaultLongDelay: Double = 5 * 60
-
Initalize a S2BEmitter with specified session and delay.
Declaration
Swift
public init(session: BKSession! = .shared, delay: Double = S2BEmitter.defaultDelay, longDelay: Double = S2BEmitter.defaultLongDelay)
Parameters
session
session containing cookie required for posting danmaku.
delay
cool time between sending danmaku in seconds.
longDelay
seconds between -636 and sending next danmaku.
-
Initalize a S2BEmitter with specified cookie to add to the default session and delay.
Declaration
Swift
public convenience init(cookie: BKCookie, delay: Double = S2BEmitter.defaultDelay, longDelay: Double = S2BEmitter.defaultLongDelay)
Parameters
cookie
cookie to be added to the default session.
delay
cool time between sending danmaku in seconds.
longDelay
seconds between -636 and sending next danmaku.
-
Result after trying to post a danmaku.
- success: danmaku was successfully posted.
- refused: bilibili refused to accept the postable danmaku.
- aborted: something else went wrong.
Declaration
Swift
public enum Result
-
To handle result after tring to post a danmaku.
Declaration
Swift
public typealias FailablePostCompletionHandler = (_ result: Result) -> Void
Parameters
result
result after trying to post a danmaku.
-
Try to post a danmaku.
Declaration
Swift
public func tryPost(danmaku: S2BDanmaku, toPage page: BKVideo.Page, completionHandler: FailablePostCompletionHandler? = nil)
Parameters
danmaku
danmaku to post.
completionHandler
task to perform once tried.
-
Task to perform once a single danmaku was posted.
Declaration
Swift
public typealias PostCompletionHandler = (_ posted: S2BPostedDanmaku) -> Void
Parameters
postable
danmaku posted.
-
Post a danmaku, auto retry if failed.
Declaration
Swift
public func post(danmaku: S2BDanmaku, toPage page: BKVideo.Page, completionHandler: PostCompletionHandler? = nil)
Parameters
danmaku
danmaku to post.
completionHandler
task to perform once the danmaku was successfully posted.
-
Task to perform once a danmaku in the queue was posted.
Declaration
Swift
public typealias ProgressReportHandler = (_ posted: S2BPostedDanmaku, _ progress: Progress) -> Void
Parameters
postable
danmaku posted.
progress
object tracking the current progress.
-
Post all contents within the subtile to video of given cid.
Declaration
Swift
public func post(subtitle: S2BSubtitle, toPage page: BKVideo.Page, configs: [S2BDanmaku.Config] = [.default], updateHandler: ProgressReportHandler? = nil, completionHandler: CompletionHandler? = nil)
Parameters
subtitle
subtitle to post.
cid
cid of the video to post to.
configs
configurations of danmakus.
updateHandler
task to perform once a danmaku was posted.
completionHandler
task to perform after all danmaku were posted.
-
Post all contents within the file to video of given cid.
Declaration
Swift
public func post(srt: S2BSubRipFile, toPage page: BKVideo.Page, configs: [S2BDanmaku.Config] = [.default], updateHandler: ProgressReportHandler? = nil, completionHandler: CompletionHandler? = nil)
Parameters
srt
SubRip file to post.
cid
cid of the video to post to.
configs
configurations of danmakus.
updateHandler
task to perform once a danmaku was posted.
completionHandler
task to perform after all danmaku were posted.