Swiftpack.co - jocoos-dev/FlipFlopSDK-Sample-iOS as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by jocoos-dev.
jocoos-dev/FlipFlopSDK-Sample-iOS 0.1.3
FlipFlop SDK Sample for IOS
โญ๏ธ 0
๐Ÿ•“ 3 weeks ago
iOS
.package(url: "https://github.com/jocoos-dev/FlipFlopSDK-Sample-iOS.git", from: "0.1.3")

FlipFlop SDK for IOS

Live Commerce IOS SDK

์š”๊ตฌ์‚ฌํ•ญ

  • iOS 12.0+
  • Xcode 12+
  • Swift 5.4+

์„ค์น˜

CocoaPods

target โ€˜YourProjectโ€™ do
    use_frameworks!

    # Pods for FlipFlopSDK
    pod 'FlipFlopSDK', '0.1.0'

end

๊ถŒํ•œ ์„ค์ •

์•„๋ž˜ ๊ถŒํ•œ๋“ค์„ info.plist์— ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”

Privacy - Bluetooth Always Usage Description      
Privacy - Camera Usage Description
Privacy - Microphone Usage Description

๋นŒ๋“œ ์„ค์ •

Build Settings > Build Options > Enable Bitcode ์˜ต์…˜์„ No๋กœ ์„ค์ •

์‚ฌ์šฉ๋ฒ•

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ดˆ๊ธฐํ™”

https://wwww.flipflop.tv ์—์„œ ๋ฐœ๊ธ‰๋ฐ›์€ appKey ์™€ appSecret์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”

// Initialize SDK
FlipFlop.initialize(appKey: APP_KEY, appSecret: APP_SECRET)

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ธ์ฆ

์ค‘๋ณต๋˜์ง€ ์•Š์€ userID๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”. userName๊ณผ avatarProfileURL์€ ์„ ํƒ์‚ฌํ•ญ์ž…๋‹ˆ๋‹ค. ์ธ์ฆ์— ์„ฑ๊ณตํ•˜๊ฒŒ ๋˜๋ฉด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

FlipFlop.authentication(userID: USER_ID, userName: USER_NAME, avatarProfileURL: AVATAR_PROFILE_URL) { (result) in
    switch result {
    case .failure(let error):
        // error
    case .success(let sdk):
        // success result is flipflop instance
    }
}

์œ ์ € ์ •๋ณด ์—…๋ฐ์ดํŠธ

sdk.updateUserInfo(userName: "Updated User") { (result) in
    switch result {
    case .failure(let error):
    case .success:
    }
}

๋ผ์ด๋ธŒ ๋ฐฉ์†ก ํ•˜๊ธฐ

// ๋ผ์ด๋ธŒ ๋ฐฉ์†ก ๊ฐ์ฒด ์ƒ์„ฑ
let streamer = sdk.getStreamer()
// ๋ผ์ด๋ธŒ ๋ฐฉ์†ก ์ด๋ฒคํŠธ ์ฝœ๋ฐฑ ๋“ฑ๋ก
streamer.delegate = self

// ์นด๋ฉ”๋ผํ”„๋ฆฌ๋ทฐ ๋ฐ ๋งˆ์ดํฌ ์‹œ์ž‘ ๋ฐ ๋ฐฉ์†ก ์ค€๋น„
streamer.prepare(preview: UIView, config: FlipFlopSDK.FFStreamerConfig = FFStreamerConfig())

// ๋ฐฉ์†ก์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค. ๋ฐฉ์†ก ํƒ€์ดํ‹€๊ณผ ๋‚ด์šฉ ์ž…๋ ฅ. onPrepared ์ดํ›„์— ํ˜ธ์ถœํ•ด์•ผ ํ•จ
streamer.start(sdk: FlipFlopSDK.FlipFlop, streamkey: String, livekey: String)

// ๋ฐฉ์†ก์„ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค.
streamer.stop()

// ๋ผ์ด๋ธŒ ๋ฐฉ์†ก ๊ฐ์ฒด ๋ฉ”๋ชจ๋ฆฌ ํ•ด์ œ
streamer.reset()

// ์นด๋ฉ”๋ผ ๋ณ€๊ฒฝ
streamer.switchCamera()

// ์ฑ„ํŒ… ์ผ๋ฐ˜๋ฉ”์‹œ์ง€ ๋ณด๋‚ด๊ธฐ
streamer.sendMessage(text: String, data: String? = nil, customType: String? = nil)
// ์ฑ„ํŒ… ๊ท“์†๋ง ๋ณด๋‚ด๊ธฐ
streamer.sendWhispher(receiver: String, text: String, data: String? = nil, customType: String? = nil)
// ์ฑ„ํŒ… ๋ช…๋ นํ˜• ๋ฉ”์‹œ์ง€ ๋ณด๋‚ด๊ธฐ
streamer.sendCommand(text: String, data: String? = nil, customType: String? = nil)
// ์นด๋ฉ”๋ผ ์ขŒ์šฐ ๋ฐ˜์ „
streamer.videoMirror(mirror: Bool)
// ์นด๋ฉ”๋ผ ์คŒ
streamer.zoom(factor: CGFloat)
// ์˜์ƒ ์‚ฌ์ง„ pip ๊ธฐ๋Šฅ. ์˜ค๋ฅธ์ชฝ ์ƒ๋‹จ์— ์นด๋ฉ”๋ผ ์˜์ƒ์ด ๋…ธ์ถœ๋˜๋ฉฐ ํฌ๊ธฐ๋Š” scale๋กœ ์กฐ์ ˆ
streamer.setBackground(backgroundImage: UIImage?, scale: CGFloat = 0.25)
// ์นด๋ฉ”๋ผ ํ•„ํ„ฐ 
streamer.setFilter(filter: FlipFlopSDK.VideoFilter)
// gif ํ”Œ๋ ˆ์ด
streamer.playGif(named: String, completion: (() -> Void)?) throws
// ์˜ค๋””์˜ค ๋ฌต์Œ
streamer.mute(on: Bool)
// ์นด๋ฉ”๋ผ ์ˆ˜๋™ ํฌ์ปค์Šค
streamer.setPointOfInterest(focus: CGPoint)
// ์นด๋ฉ”๋ผ ์ˆ˜๋™ ๋…ธ์ถœ
streamer.setPointOfInterest(exposure: CGPoint)

VideoFilter

public enum VideoFilter {
    case none
    case sephia(value: Float)
    case blendMaks(overlayImage: CIImage, maskImage: CIImage)
    case sourceOverComposit(overlayImage: CIImage)
    case colorOverlay(color: UIColor)
    case custom(effect: VideoEffect)
}

Streamer Property

    
    var chatHeartbitTime: Double
    // ์ž๋™ ์นด๋ฉ”๋ผ ์˜คํ† ํฌ์ปค์Šค true / false ( default false)
    var continuousAutofocus: Bool
    // ์ž๋™ ์นด๋ฉ”๋ผ ๋…ธ์ถœ true / false ( default false)
    var continuousExposure: Bool
    // ์นด๋ฉ”๋ผ ๋…ธ์ถœ bias (minExposureTargetBias ~ maxExposureTargetBias)
    var exposureTargetBias: Float
    // ๋””๋ฐ”์ด์Šค ์ตœ์†Œ ์นด๋ฉ”๋ผ ๋…ธ์ถœ bais
    var minExposureTargetBias: Float { get }
    // ๋””๋ฐ”์ด์Šค ์ตœ๋Œ€ ์นด๋ฉ”๋ผ ๋…ธ์ถœ bais
    var maxExposureTargetBias: Float { get }
    // ํ˜„์žฌ ์„ค์ • ๋œ ๋น„ํŠธ๋ ˆ์ดํŠธ
    var currentBitrate: Int { get }
    // ๋ฐฉ์†ก ์ค‘ bitrate๋ณ€๊ฒฝ ์‹œ ํ˜ธ์ถœ (bps)
    var videoBitrateOnFly: Int
    // adaptive bitrate true / false (default false)
    var adaptiveBitrate: Bool

๋ผ์ด๋ธŒ ๋ฐฉ์†ก ์ด๋ฒคํŠธ ์ฝœ๋ฐฑ

public protocol FFStreamerDelegate: class { {
    
    // ๋ฐฉ์†ก ์ค€๋น„ ์ด๋ฒคํŠธ
    func onPrepared()
    // ๋ฐฉ์†ก ์‹œ์ž‘ ์ด๋ฒคํŠธ
    func onStarted()
    // ๋ฐฉ์†ก ์ค‘์ง€ ์ด๋ฒคํŠธ
    func onStopped()
    // ๋ฐฉ์†ก ์ข…๋ฃŒ ์ด๋ฒคํŠธ
    func onCompleted()
    // ๋ฐฉ์†ก ์ฑ„ํŒ… ๋ฉ”์‹œ์ง€ ์ด๋ฒคํŠธ
    func onChatMessgeReceived(message: FFMessage)
    // ๋ฐฉ์†ก ์—๋Ÿฌ ์ด๋ฒคํŠธ
    func onError(error: FFError)
    // ์ŠคํŠธ๋ฆผ ์ •๋ณด ์ด๋ฒคํŠธ
    func onStreamStatus(notification: Notification)
    // bandwidth๊ฐ€ ๋ถ€์กฑํ• ๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์ด๋ฒคํŠธ
    func onInSufficentBW()
    // bandwidth๊ฐ€ ๋‹ค์‹œ ์ถฉ๋ถ„ํ•ด ์กŒ์„๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์ด๋ฒคํŠธ
    func onSufficentBW()
    // ๋น„ํŠธ๋ ˆ์ดํŠธ๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์„๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์ด๋ฒคํŠธ
    func onVideoBitrateChanged(newBitrate: Int)
}

๋ฐฉ์†ก ๋ณด๊ธฐ

// ํ”Œ๋ ˆ์ด์–ด ๊ฐ์ฒด ์ƒ์„ฑ
let player = sdk.getPlayer(videoKey: VIDEO_KEY)

// ํ”Œ๋ ˆ์ด์–ด ์ค€๋น„
player.prepare(view: playerView)

// ํ”Œ๋ ˆ์ด์–ด ์‹œ์ž‘. onPrepared ์ดํ›„ ํ˜ธ์ถœ
player.start()

// ํ”Œ๋ ˆ์ด์–ด ์ค‘์ง€
player.stop()

// ํ”Œ๋ ˆ์ด์–ด ๊ฐ์ฒด ๋ฉ”๋ชจ๋ฆฌ ํ•ด์ œ
player.reset()

// ์ฑ„ํŒ… ๋ณด๋‚ด๊ธฐ
player.sendMessage(text: "Blar Blar Blar....")

// ์ฑ„ํŒ… ํžˆ์Šคํ† ๋ฆฌ ๊ฐ€์ ธ์˜ค๊ธฐ
player.getChatHistory { (result) in
    switch result {
    case .failure(let error):
    case .success(let messages):
    }
}

// ๋น„๋””์˜ค seek
player.seekTo(percent: 0.5)

๋ฐฉ์†ก ๋ณด๊ธฐ ์ด๋ฒคํŠธ ์ฝœ๋ฐฑ

 public protocol FFPlayerDelegate {
     // ์•ฑ์ด ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ง„์ž…ํ–ˆ์„๋•Œ
    func onBackground(player: FFPlayer)
    // ์•ฑ์ด ํฌ๊ทธ๋ผ์šด๋“œ ์ง„์ž…ํ–ˆ์„๋•Œ
    func onForeground(player: FFPlayer)
    // ๋ฐฉ์†ก ์ค€๋น„ ์ด๋ฒคํŠธ
    func onPrepared(player: FFPlayer)
    // ๋ฐฉ์†ก ์‹œ์ž‘ ์ด๋ฒคํŠธ
    func onStarted(player: FFPlayer)
    // ๋ฐฉ์†ก ์ž„์‹œ ์ •์ง€ ์ด๋ฒคํŠธ
    func onPaused(player: FFPlayer)
    // ๋ฐฉ์†ก ์ผ์‹œ ์ •์ง€ ํ›„ ๋‹ค์‹œ ์‹œ์ž‘ ์ด๋ฒคํŠธ
    func onResumed(player: FFPlayer)
    // ๋ฐฉ์†ก ์ค‘์ง€ ์ด๋ฒคํŠธ
    func onStopped(player: FFPlayer)
    // ๋ฐฉ์†ก ์ข…๋ฃŒ ์ด๋ฒคํŠธ
    func onCompleted(player: FFPlayer)
    // ๋ฐฉ์†ก ์ง„ํ–‰ ์ƒํƒœ ์ด๋ฒคํŠธ
    func onProgressUpdated(player: FFPlayer, mSec: UInt64)
    // ๋ฐฉ์†ก ํƒ์ƒ‰ ์™„๋ฃŒ ์ด๋ฒคํŠธ
    func onSeekCompleted(player: FFPlayer, mSec: UInt64)
    // ๋ฐฉ์†ก ์—๋Ÿฌ ์ด๋ฒคํŠธ
    func onError(player: FFPlayer, error: FFError)
    // ๋ฐฉ์†ก ์ฑ„ํŒ… ๋ฉ”์‹œ์ง€ ์ด๋ฒคํŠธ
    func onChatMessgeReceived(message: FFMessage)
    // ๋ฐฑ๊ทธ๋ผ์šด๋“œ๋กœ ์ง„์ž… ์ด๋ฒคํŠธ
    func onBackground(player: FFPlayer)
    // ํฌ๊ทธ๋ผ์šด๋“œ๋กœ ์ง„์ž… ์ด๋ฒคํŠธ
    func onForeground(player: FFPlayer)
}

๋น„๋””์˜ค ๋ฆฌ์ŠคํŠธ ๊ฐ€์ ธ์˜ค๊ธฐ

๋น„๋””์˜ค ๋ฆฌ์ŠคํŠธ๋กœ๋”๋ฅผ ์ด์šฉํ•˜์—ฌ next ํ•จ์ˆ˜ ํ˜ธ์ถœ์‹œ ๋น„๋””์˜ค ๋ฆฌ์ŠคํŠธ๋ฅผ ๊ฐ€์ ธ์˜ด ๋” ์ด์ƒ ๊ฐ€์ ธ์˜ฌ ๋น„๋””์˜ค๊ฐ€ ์—†์œผ๋ฉด ๋นˆ ๋ฐฐ์—ด์ด ๋‚ด๋ ค์˜ด

let loader = sdk.getVideoListLoader()
loader.next {(videoResult) in
        switch videoResult {
        case .failure(let error):
            // error
        case .success(let videos):
            // If there are no more, the count is zero.
        }
    }
}

๋น„๋””์˜ค ์ •๋ณด ๋ณ€๊ฒฝํ•˜๊ธฐ

๋น„๋””์˜ค ํƒ€์ดํ‹€๊ณผ ๋‚ด์šฉ์„ ๋ณ€๊ฒฝํ•œ๋‹ค.

sdk.editVideo(videoKey: VIDEO_KEY, title: "New Title", content: "New Content") {
    switch result {
    case .failure(let error):
    case .success:
    }
}

๋น„๋””์˜ค ๋น„๊ณต๊ฐœํ•˜๊ธฐ

visibility๋Š” 'public'๋˜๋Š” 'private'๋งŒ ํ—ˆ์šฉ๋ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ๊ฐ’์€ 'public'์ž…๋‹ˆ๋‹ค

sdk.editVideo(videoKey: VIDEO_KEY, visibility: "private") {
    switch result {
    case .failure(let error):
    case .success:
    }
}

๋น„๋””์˜ค ์‚ญ์ œํ•˜๊ธฐ

๋น„๋””์˜ค ์‚ญ์ œํ•œ๋‹ค.

sdk.deleteVideo(videoKey: VIDEO_KEY) { (result) in
    switch result {
    case .failure(let error):
    case .success:
    }
}

License

MIT

GitHub

link
Stars: 0
Last commit: 3 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

0.1.3
3 weeks ago

change inSufficientBW to be called also in static bitrate

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics