Firekast

firekast.io empowers live video streaming in few lines of code.

It’s easy, 100% documented and needs no video knowledge.

Prerequisites

Min iOS Deployment target: 8.0

Installation

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

use_frameworks!

target '<Your Target Name>' do
  # First time install may be long, so please be patient :)
  # Set the same version name X.Y.Z. for both Firekast and VideoCore pod. Here 1.1.1.
  pod 'Firekast', :podspec => 'http://firekast.io/sdk/ios/v1.1.1/Firekast.podspec'
  pod 'VideoCore', :git => 'https://github.com/Firekast-io/VideoCore.git', :tag => 'fk-1.1.1'
end

Usage

Initialization

  1. Sign up and create an app on Firekast Dashboard.
  2. In your app Info.plist specify the reason for your app to access the device’s camera NSCameraUsageDescription and microphone NSMicrophoneUsageDescription.
  3. In your AppDelegate initialize the SDK with your Firekast app credentials.
// Swift
import Firekast

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    Firekast.initialize(clientKey: "%ACCOUNT%", applicationId: "%APP%")
    return true
}
// Objective-C
#import "Firekast/Firekast-Swift.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [Firekast initializeWithClientKey:@"%ACCOUNT%" applicationId:@"%APP%"];
    return YES;
}

Live streaming

In your view controller, initialize a Firekast Streamer and call showCamera to start and display the device’s camera. To live stream you need first to request for a stream (requestStream), then call startStreaming whenever you are ready.

Call stopStreaming to… stop streaming 🤠. Remember to call this function in viewWillDisappear in case you user leaves the screen while streaming.

To access camera feature (flash, switch front/back, microphone) use the Camera object returned by calling showCamera.

@IBOutlet weak var container: UIView!
var streamer: Streamer!
var camera: Camera!

override func viewDidLoad() {
    super.viewDidLoad()

    streamer = Streamer()
    camera = streamer.showCamera(.front, in: container)
}
streamer.requestStream { (stream, error) in
    guard let stream = stream {
        print("Request stream failed: \(error!)")
        return
    }
    self.streamer.startStreaming(on: stream, delegate: self)
}
streamer.stopStreaming()
// MARK: - Streamer Delegate
func streamer(_ streamer: Streamer, willStartOn stream: Firekast.Stream?, unless error: Firekast.Error?) {}
func streamer(_ streamer: Streamer, didStopOn stream: Firekast.Stream?, error: Firekast.Error?) {}
func streamer(_ streamer: Streamer, networkQualityDidUpdate rating: Float) {}

Push your live to other live streaming platforms simultaneously

Firekast allows to push your live stream to several Live Streaming Platform, such as Facebook or Youtube, simultaneously.

Defines the list of live streaming platforms where you want to push your live and request for a stream.

let media = [
        LiveStreamingPlatform.facebook(accessToken: "your-fb-access-token"),
        LiveStreamingPlatform.youtube(accessToken: "your-yt-access-token", title: "My Live with firekast.io")
]

streamer.requestStream(outputs: media) { (stream, error) in
    <#code#>
}

Play a stream

In your view controller, initialize a Firekast Player and display it by calling show. Then call play with the id of the stream you want to watch.

Call stop if needed.

@IBOutlet weak var container: UIView!
var player: Player!

override func viewDidLoad() {
    super.viewDidLoad()

    player = Player()
    player.show(in: container)
}
player.play(streamId: "dot38gxkr2zkt9m18", delegate: self)
player.stop()
// MARK: - Player Delegate
func player(_ player: Player, willPlay stream: Firekast.Stream?, unless error: Error?) {}
func player(_ player: Player, stateDidChanged state: Player.State) {} // optional
func player(_ player: Player, videoDurationIsAvailable duration: TimeInterval) {} // optional

Troubleshooting

  • For Objective-C project, enable Always Embed Swift Standard Libraries option under Build Settings, otherwise you will get an dyld: Library not loaded error.
  • 'Error' is ambiguous for type lookup in this context. You have to specify the module from which to lookup object type. Call Firekast.Error.
  • 'Stream' is ambiguous for type lookup in this context. You have to specify the module from which to lookup object type. Call Firekast.Stream.

Release Notes

v1.1.1

Built with Swift 4.1 (Xcode 9.3).

Whats’s new:

  • Minor fixes

v1.1.0

Built with Swift 4.0.3 (Xcode 9.2).

What’s new:

  • 100% documented.
  • Refactoring, Streamer and Player, functions and parameters should be more straight forward.
  • Live stream on Facebook and/or Youtube and Firekast simultaneous. See LiveStreamingPlatform.
  • Use camera features by enabling torch, microphone, choosing your device’s camera. See Camera.

v1.0.0

Built with Swift 3.1

First release of FirekastStreamer and FirekastPlayer to stream and play video with its streamId.