Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hansemannn/facebook-live-ios
📺 A Swift utility "FBSDKLiveVideo" to stream Facebook Live videos on iOS
https://github.com/hansemannn/facebook-live-ios
facebook-login facebook-sdk ios sample
Last synced: about 2 months ago
JSON representation
📺 A Swift utility "FBSDKLiveVideo" to stream Facebook Live videos on iOS
- Host: GitHub
- URL: https://github.com/hansemannn/facebook-live-ios
- Owner: hansemannn
- License: mit
- Created: 2017-03-08T14:47:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-10-04T10:45:16.000Z (almost 3 years ago)
- Last Synced: 2024-05-01T20:22:44.501Z (5 months ago)
- Topics: facebook-login, facebook-sdk, ios, sample
- Language: Swift
- Homepage:
- Size: 1.31 MB
- Stars: 55
- Watchers: 8
- Forks: 21
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Â Facebook Live iOS
A custom Swift utility "FBSDKLiveVideo" to stream Facebook Live videos on iOS.## Example
The following example would create a full-screen live video preview that is started when the user taps
the trigger button linked in your Storyboard.```swift
class ViewController: UIViewController {
var liveVideo: FBSDKLiveVideo!override func viewDidLoad() {
super.viewDidLoad()
// Create the live video service
liveVideo = FBSDKLiveVideo(
delegate: self,
previewSize: self.view.bounds,
videoSize: CGSize(width: 1280, height: 720)
)
// Optional: Configure the live-video (see the source for all options)
liveVideo.privacy = .me // or .friends, .friendsOfFriends, .custom
liveVideo.audience = "me" // or your user-id, page-id, event-id, group-id, ...
// Optional: Add the preview view of the stream to your container view.
    myView.addSubView(liveVideo.preview)
}
@IBAction func recordButtonTapped() {
liveVideo.start()
}@IBAction func stopButtonTapped() {
liveVideo.stop();
}@IBAction func adBreakButtonTapped() {
liveVideo.adBreakStartNow = true
liveVido.update();
}@IBAction func deleteButtonTapped() {
liveVido.delete();
}
}extension ViewController: FBSDKLiveVideoDelegate {
func liveVideo(_ liveVideo: FBSDKLiveVideo, didStartWith session: FBSDKLiveVideoSession) {
// Live video started
}func liveVideo(_ liveVideo: FBSDKLiveVideo, didStopWith session: FBSDKLiveVideoSession) {
// Live video ended
}func liveVideo(_ liveVideo: FBSDKLiveVideo, didErrorWith: Error) {
// Live video errored
}func liveVideo(_ liveVideo: FBSDKLiveVideo, didChange sessionState: FBSDKLiveVideoSessionState) {
// Live video changed session state
// One of: .none, .previewStarted, .starting, .started, .ended, .error
}func liveVideo(_ liveVideo: FBSDKLiveVideo, didAdd cameraSource: FBSDKLiveVideoSession) {
// New camera source added to the stream
}func liveVideo(_ liveVideo: FBSDKLiveVideo, didUpdate session: FBSDKLiveVideoSession) {
// Live video was updated through update()
}func liveVideo(_ liveVideo: FBSDKLiveVideo, didDelete session: FBSDKLiveVideoSession) {
// Live video was deleted through delete()
}
}
```## Build
* Run `pod install` to install the required dependencies (Facebook SDK + VideoCore)
* Open the `facebook-live-ios-sample.xcworkspace` file in Xcode
* Change the app-id inside the `Info.plist` to match your app. Ensure to configure the App-ID correctly
* Run the project on your iOS device! By default, it will only start a live-stream to your private audience ("Only me")## License
MIT - Try it out, modify it, use it!## Author
Hans Knöchel ([@hansemannnn](https://twitter.com/hansemannnn))## Contributions
Code contributions are greatly appreciated, please submit a new [Pull Request](https://github.com/hansemannn/facebook-live-ios/pull/new/master)!